Merge lp:~renamer-developers/renamer/documentation into lp:renamer
- documentation
- Merge into trunk
Proposed by
Jonathan Jacobs
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Tristan Seligmann | ||||
Approved revision: | 133 | ||||
Merged at revision: | 88 | ||||
Proposed branch: | lp:~renamer-developers/renamer/documentation | ||||
Merge into: | lp:renamer | ||||
Diff against target: |
1095 lines (+942/-94) 10 files modified
.bzrignore (+1/-0) docs/Makefile (+130/-0) docs/code/plugins_command.py (+42/-0) docs/conf.py (+216/-0) docs/index.rst (+16/-0) docs/make.bat (+155/-0) docs/manual.rst (+247/-0) docs/plugins.rst (+134/-0) docs/rn.1 (+0/-93) renamer/plugins/undo.py (+1/-1) |
||||
To merge this branch: | bzr merge lp:~renamer-developers/renamer/documentation | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tristan Seligmann | Approve | ||
Review via email: mp+39450@code.launchpad.net |
Commit message
Description of the change
Move to using Sphinx for documentation purposes. HTML versions of the documentation are conveniently available for proofreading at <http://
To post a comment you must log in.
- 132. By Jonathan Jacobs
-
Merge trunk.
Revision history for this message
Jonathan Jacobs (jjacobs) wrote : | # |
- 133. By Jonathan Jacobs
-
Merge trunk.
Revision history for this message
Tristan Seligmann (mithrandi) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2009-05-07 10:45:13 +0000 | |||
3 | +++ .bzrignore 2010-11-01 08:51:04 +0000 | |||
4 | @@ -1,1 +1,2 @@ | |||
5 | 1 | dropin.cache | 1 | dropin.cache |
6 | 2 | _build | ||
7 | 2 | 3 | ||
8 | === added file 'docs/Makefile' | |||
9 | --- docs/Makefile 1970-01-01 00:00:00 +0000 | |||
10 | +++ docs/Makefile 2010-11-01 08:51:04 +0000 | |||
11 | @@ -0,0 +1,130 @@ | |||
12 | 1 | # Makefile for Sphinx documentation | ||
13 | 2 | # | ||
14 | 3 | |||
15 | 4 | # You can set these variables from the command line. | ||
16 | 5 | SPHINXOPTS = | ||
17 | 6 | SPHINXBUILD = sphinx-build | ||
18 | 7 | PAPER = a4 | ||
19 | 8 | BUILDDIR = _build | ||
20 | 9 | |||
21 | 10 | # Internal variables. | ||
22 | 11 | PAPEROPT_a4 = -D latex_paper_size=a4 | ||
23 | 12 | PAPEROPT_letter = -D latex_paper_size=letter | ||
24 | 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . | ||
25 | 14 | |||
26 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest | ||
27 | 16 | |||
28 | 17 | help: | ||
29 | 18 | @echo "Please use \`make <target>' where <target> is one of" | ||
30 | 19 | @echo " html to make standalone HTML files" | ||
31 | 20 | @echo " dirhtml to make HTML files named index.html in directories" | ||
32 | 21 | @echo " singlehtml to make a single large HTML file" | ||
33 | 22 | @echo " pickle to make pickle files" | ||
34 | 23 | @echo " json to make JSON files" | ||
35 | 24 | @echo " htmlhelp to make HTML files and a HTML help project" | ||
36 | 25 | @echo " qthelp to make HTML files and a qthelp project" | ||
37 | 26 | @echo " devhelp to make HTML files and a Devhelp project" | ||
38 | 27 | @echo " epub to make an epub" | ||
39 | 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" | ||
40 | 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" | ||
41 | 30 | @echo " text to make text files" | ||
42 | 31 | @echo " man to make manual pages" | ||
43 | 32 | @echo " changes to make an overview of all changed/added/deprecated items" | ||
44 | 33 | @echo " linkcheck to check all external links for integrity" | ||
45 | 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" | ||
46 | 35 | |||
47 | 36 | clean: | ||
48 | 37 | -rm -rf $(BUILDDIR)/* | ||
49 | 38 | |||
50 | 39 | html: | ||
51 | 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html | ||
52 | 41 | @echo | ||
53 | 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." | ||
54 | 43 | |||
55 | 44 | dirhtml: | ||
56 | 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml | ||
57 | 46 | @echo | ||
58 | 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." | ||
59 | 48 | |||
60 | 49 | singlehtml: | ||
61 | 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml | ||
62 | 51 | @echo | ||
63 | 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." | ||
64 | 53 | |||
65 | 54 | pickle: | ||
66 | 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle | ||
67 | 56 | @echo | ||
68 | 57 | @echo "Build finished; now you can process the pickle files." | ||
69 | 58 | |||
70 | 59 | json: | ||
71 | 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json | ||
72 | 61 | @echo | ||
73 | 62 | @echo "Build finished; now you can process the JSON files." | ||
74 | 63 | |||
75 | 64 | htmlhelp: | ||
76 | 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp | ||
77 | 66 | @echo | ||
78 | 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ | ||
79 | 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." | ||
80 | 69 | |||
81 | 70 | qthelp: | ||
82 | 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp | ||
83 | 72 | @echo | ||
84 | 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ | ||
85 | 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" | ||
86 | 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Renamer.qhcp" | ||
87 | 76 | @echo "To view the help file:" | ||
88 | 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Renamer.qhc" | ||
89 | 78 | |||
90 | 79 | devhelp: | ||
91 | 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp | ||
92 | 81 | @echo | ||
93 | 82 | @echo "Build finished." | ||
94 | 83 | @echo "To view the help file:" | ||
95 | 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/Renamer" | ||
96 | 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Renamer" | ||
97 | 86 | @echo "# devhelp" | ||
98 | 87 | |||
99 | 88 | epub: | ||
100 | 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub | ||
101 | 90 | @echo | ||
102 | 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." | ||
103 | 92 | |||
104 | 93 | latex: | ||
105 | 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||
106 | 95 | @echo | ||
107 | 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." | ||
108 | 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ | ||
109 | 98 | "(use \`make latexpdf' here to do that automatically)." | ||
110 | 99 | |||
111 | 100 | latexpdf: | ||
112 | 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||
113 | 102 | @echo "Running LaTeX files through pdflatex..." | ||
114 | 103 | make -C $(BUILDDIR)/latex all-pdf | ||
115 | 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." | ||
116 | 105 | |||
117 | 106 | text: | ||
118 | 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text | ||
119 | 108 | @echo | ||
120 | 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." | ||
121 | 110 | |||
122 | 111 | man: | ||
123 | 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man | ||
124 | 113 | @echo | ||
125 | 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." | ||
126 | 115 | |||
127 | 116 | changes: | ||
128 | 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes | ||
129 | 118 | @echo | ||
130 | 119 | @echo "The overview file is in $(BUILDDIR)/changes." | ||
131 | 120 | |||
132 | 121 | linkcheck: | ||
133 | 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck | ||
134 | 123 | @echo | ||
135 | 124 | @echo "Link check complete; look for any errors in the above output " \ | ||
136 | 125 | "or in $(BUILDDIR)/linkcheck/output.txt." | ||
137 | 126 | |||
138 | 127 | doctest: | ||
139 | 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest | ||
140 | 129 | @echo "Testing of doctests in the sources finished, look at the " \ | ||
141 | 130 | "results in $(BUILDDIR)/doctest/output.txt." | ||
142 | 0 | 131 | ||
143 | === added directory 'docs/code' | |||
144 | === added file 'docs/code/plugins_command.py' | |||
145 | --- docs/code/plugins_command.py 1970-01-01 00:00:00 +0000 | |||
146 | +++ docs/code/plugins_command.py 2010-11-01 08:51:04 +0000 | |||
147 | @@ -0,0 +1,42 @@ | |||
148 | 1 | import os | ||
149 | 2 | import string | ||
150 | 3 | import time | ||
151 | 4 | |||
152 | 5 | from renamer.plugin import RenamingCommand | ||
153 | 6 | from renamer.errors import PluginError | ||
154 | 7 | |||
155 | 8 | |||
156 | 9 | class ReadableTimestamps(RenamingCommand): | ||
157 | 10 | # The name of our command, as it will be used from the command-line. | ||
158 | 11 | name = 'timestamp' | ||
159 | 12 | |||
160 | 13 | # A brief description of the command's purpose, displayed in --help output. | ||
161 | 14 | description = 'Rename files with POSIX timestamps to human-readble times.' | ||
162 | 15 | |||
163 | 16 | # Command-line parameters we support. | ||
164 | 17 | optParameters = [ | ||
165 | 18 | ('format', 'f', '%Y-%m-%d %H-%M-%S', 'strftime format.')] | ||
166 | 19 | |||
167 | 20 | # The default name template to use if no name template is specified via the | ||
168 | 21 | # command-line or configuration file. | ||
169 | 22 | defaultNameTemplate = string.Template('$time') | ||
170 | 23 | |||
171 | 24 | # IRenamerCommand | ||
172 | 25 | |||
173 | 26 | def processArgument(self, arg): | ||
174 | 27 | # The extension is not needed as it will be determined from the | ||
175 | 28 | # original file name. | ||
176 | 29 | name, ext = arg.splitext() | ||
177 | 30 | try: | ||
178 | 31 | # Try convert the filename to a floating point number. | ||
179 | 32 | timestamp = float(name) | ||
180 | 33 | except (TypeError, ValueError): | ||
181 | 34 | # If it is not a floating point number then we raise an exception | ||
182 | 35 | # to stop the process. | ||
183 | 36 | raise PluginError('%r is not a valid timestamp' % (name,)) | ||
184 | 37 | else: | ||
185 | 38 | # Convert and format the timestamp according to the "format" | ||
186 | 39 | # command-line parameter. | ||
187 | 40 | t = time.localtime(timestamp) | ||
188 | 41 | return { | ||
189 | 42 | 'time': time.strftime(self['format'], t)} | ||
190 | 0 | 43 | ||
191 | === added file 'docs/conf.py' | |||
192 | --- docs/conf.py 1970-01-01 00:00:00 +0000 | |||
193 | +++ docs/conf.py 2010-11-01 08:51:04 +0000 | |||
194 | @@ -0,0 +1,216 @@ | |||
195 | 1 | # -*- coding: utf-8 -*- | ||
196 | 2 | # | ||
197 | 3 | # Renamer documentation build configuration file, created by | ||
198 | 4 | # sphinx-quickstart on Thu Oct 21 09:53:03 2010. | ||
199 | 5 | # | ||
200 | 6 | # This file is execfile()d with the current directory set to its containing dir. | ||
201 | 7 | # | ||
202 | 8 | # Note that not all possible configuration values are present in this | ||
203 | 9 | # autogenerated file. | ||
204 | 10 | # | ||
205 | 11 | # All configuration values have a default; values that are commented out | ||
206 | 12 | # serve to show the default. | ||
207 | 13 | |||
208 | 14 | import sys, os | ||
209 | 15 | |||
210 | 16 | # If extensions (or modules to document with autodoc) are in another directory, | ||
211 | 17 | # add these directories to sys.path here. If the directory is relative to the | ||
212 | 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. | ||
213 | 19 | #sys.path.insert(0, os.path.abspath('.')) | ||
214 | 20 | |||
215 | 21 | # -- General configuration ----------------------------------------------------- | ||
216 | 22 | |||
217 | 23 | # If your documentation needs a minimal Sphinx version, state it here. | ||
218 | 24 | #needs_sphinx = '1.0' | ||
219 | 25 | |||
220 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions | ||
221 | 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. | ||
222 | 28 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage'] | ||
223 | 29 | |||
224 | 30 | # Add any paths that contain templates here, relative to this directory. | ||
225 | 31 | templates_path = ['templates'] | ||
226 | 32 | |||
227 | 33 | # The suffix of source filenames. | ||
228 | 34 | source_suffix = '.rst' | ||
229 | 35 | |||
230 | 36 | # The encoding of source files. | ||
231 | 37 | #source_encoding = 'utf-8-sig' | ||
232 | 38 | |||
233 | 39 | # The master toctree document. | ||
234 | 40 | master_doc = 'index' | ||
235 | 41 | |||
236 | 42 | # General information about the project. | ||
237 | 43 | project = u'Renamer' | ||
238 | 44 | copyright = u'2010, Jonathan Jacobs, Tristan Seligmann, Andrew Snowden' | ||
239 | 45 | |||
240 | 46 | # The version info for the project you're documenting, acts as replacement for | ||
241 | 47 | # |version| and |release|, also used in various other places throughout the | ||
242 | 48 | # built documents. | ||
243 | 49 | # | ||
244 | 50 | # The short X.Y version. | ||
245 | 51 | version = '0.1.0' | ||
246 | 52 | # The full version, including alpha/beta/rc tags. | ||
247 | 53 | release = '0.1.0' | ||
248 | 54 | |||
249 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation | ||
250 | 56 | # for a list of supported languages. | ||
251 | 57 | #language = None | ||
252 | 58 | |||
253 | 59 | # There are two options for replacing |today|: either, you set today to some | ||
254 | 60 | # non-false value, then it is used: | ||
255 | 61 | #today = '' | ||
256 | 62 | # Else, today_fmt is used as the format for a strftime call. | ||
257 | 63 | #today_fmt = '%B %d, %Y' | ||
258 | 64 | |||
259 | 65 | # List of patterns, relative to source directory, that match files and | ||
260 | 66 | # directories to ignore when looking for source files. | ||
261 | 67 | exclude_patterns = ['_build'] | ||
262 | 68 | |||
263 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. | ||
264 | 70 | #default_role = None | ||
265 | 71 | |||
266 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. | ||
267 | 73 | #add_function_parentheses = True | ||
268 | 74 | |||
269 | 75 | # If true, the current module name will be prepended to all description | ||
270 | 76 | # unit titles (such as .. function::). | ||
271 | 77 | #add_module_names = True | ||
272 | 78 | |||
273 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the | ||
274 | 80 | # output. They are ignored by default. | ||
275 | 81 | #show_authors = False | ||
276 | 82 | |||
277 | 83 | # The name of the Pygments (syntax highlighting) style to use. | ||
278 | 84 | pygments_style = 'sphinx' | ||
279 | 85 | |||
280 | 86 | # A list of ignored prefixes for module index sorting. | ||
281 | 87 | #modindex_common_prefix = [] | ||
282 | 88 | |||
283 | 89 | |||
284 | 90 | # -- Options for HTML output --------------------------------------------------- | ||
285 | 91 | |||
286 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for | ||
287 | 93 | # a list of builtin themes. | ||
288 | 94 | html_theme = 'default' | ||
289 | 95 | |||
290 | 96 | # Theme options are theme-specific and customize the look and feel of a theme | ||
291 | 97 | # further. For a list of options available for each theme, see the | ||
292 | 98 | # documentation. | ||
293 | 99 | #html_theme_options = {} | ||
294 | 100 | |||
295 | 101 | # Add any paths that contain custom themes here, relative to this directory. | ||
296 | 102 | #html_theme_path = [] | ||
297 | 103 | |||
298 | 104 | # The name for this set of Sphinx documents. If None, it defaults to | ||
299 | 105 | # "<project> v<release> documentation". | ||
300 | 106 | #html_title = None | ||
301 | 107 | |||
302 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. | ||
303 | 109 | #html_short_title = None | ||
304 | 110 | |||
305 | 111 | # The name of an image file (relative to this directory) to place at the top | ||
306 | 112 | # of the sidebar. | ||
307 | 113 | #html_logo = None | ||
308 | 114 | |||
309 | 115 | # The name of an image file (within the static path) to use as favicon of the | ||
310 | 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 | ||
311 | 117 | # pixels large. | ||
312 | 118 | #html_favicon = None | ||
313 | 119 | |||
314 | 120 | # Add any paths that contain custom static files (such as style sheets) here, | ||
315 | 121 | # relative to this directory. They are copied after the builtin static files, | ||
316 | 122 | # so a file named "default.css" will overwrite the builtin "default.css". | ||
317 | 123 | html_static_path = ['static'] | ||
318 | 124 | |||
319 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, | ||
320 | 126 | # using the given strftime format. | ||
321 | 127 | #html_last_updated_fmt = '%b %d, %Y' | ||
322 | 128 | |||
323 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to | ||
324 | 130 | # typographically correct entities. | ||
325 | 131 | #html_use_smartypants = True | ||
326 | 132 | |||
327 | 133 | # Custom sidebar templates, maps document names to template names. | ||
328 | 134 | #html_sidebars = {} | ||
329 | 135 | |||
330 | 136 | # Additional templates that should be rendered to pages, maps page names to | ||
331 | 137 | # template names. | ||
332 | 138 | #html_additional_pages = {} | ||
333 | 139 | |||
334 | 140 | # If false, no module index is generated. | ||
335 | 141 | #html_domain_indices = True | ||
336 | 142 | |||
337 | 143 | # If false, no index is generated. | ||
338 | 144 | #html_use_index = True | ||
339 | 145 | |||
340 | 146 | # If true, the index is split into individual pages for each letter. | ||
341 | 147 | #html_split_index = False | ||
342 | 148 | |||
343 | 149 | # If true, links to the reST sources are added to the pages. | ||
344 | 150 | #html_show_sourcelink = True | ||
345 | 151 | |||
346 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. | ||
347 | 153 | #html_show_sphinx = True | ||
348 | 154 | |||
349 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. | ||
350 | 156 | #html_show_copyright = True | ||
351 | 157 | |||
352 | 158 | # If true, an OpenSearch description file will be output, and all pages will | ||
353 | 159 | # contain a <link> tag referring to it. The value of this option must be the | ||
354 | 160 | # base URL from which the finished HTML is served. | ||
355 | 161 | #html_use_opensearch = '' | ||
356 | 162 | |||
357 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). | ||
358 | 164 | #html_file_suffix = None | ||
359 | 165 | |||
360 | 166 | # Output file base name for HTML help builder. | ||
361 | 167 | htmlhelp_basename = 'Renamerdoc' | ||
362 | 168 | |||
363 | 169 | |||
364 | 170 | # -- Options for LaTeX output -------------------------------------------------- | ||
365 | 171 | |||
366 | 172 | # The paper size ('letter' or 'a4'). | ||
367 | 173 | #latex_paper_size = 'letter' | ||
368 | 174 | |||
369 | 175 | # The font size ('10pt', '11pt' or '12pt'). | ||
370 | 176 | #latex_font_size = '10pt' | ||
371 | 177 | |||
372 | 178 | # Grouping the document tree into LaTeX files. List of tuples | ||
373 | 179 | # (source start file, target name, title, author, documentclass [howto/manual]). | ||
374 | 180 | latex_documents = [ | ||
375 | 181 | ('index', 'Renamer.tex', u'Renamer Documentation', | ||
376 | 182 | u'Jonathan Jacobs, Tristan Seligmann, Andrew Snowden', 'manual'), | ||
377 | 183 | ] | ||
378 | 184 | |||
379 | 185 | # The name of an image file (relative to this directory) to place at the top of | ||
380 | 186 | # the title page. | ||
381 | 187 | #latex_logo = None | ||
382 | 188 | |||
383 | 189 | # For "manual" documents, if this is true, then toplevel headings are parts, | ||
384 | 190 | # not chapters. | ||
385 | 191 | #latex_use_parts = False | ||
386 | 192 | |||
387 | 193 | # If true, show page references after internal links. | ||
388 | 194 | #latex_show_pagerefs = False | ||
389 | 195 | |||
390 | 196 | # If true, show URL addresses after external links. | ||
391 | 197 | #latex_show_urls = False | ||
392 | 198 | |||
393 | 199 | # Additional stuff for the LaTeX preamble. | ||
394 | 200 | #latex_preamble = '' | ||
395 | 201 | |||
396 | 202 | # Documents to append as an appendix to all manuals. | ||
397 | 203 | #latex_appendices = [] | ||
398 | 204 | |||
399 | 205 | # If false, no module index is generated. | ||
400 | 206 | #latex_domain_indices = True | ||
401 | 207 | |||
402 | 208 | |||
403 | 209 | # -- Options for manual page output -------------------------------------------- | ||
404 | 210 | |||
405 | 211 | # One entry per manual page. List of tuples | ||
406 | 212 | # (source start file, name, description, authors, manual section). | ||
407 | 213 | man_pages = [ | ||
408 | 214 | ('manual', 'rn', u'an extensible mass file renamer', | ||
409 | 215 | [u'Jonathan Jacobs', u'Tristan Seligmann', u'Andrew Snowden'], 1) | ||
410 | 216 | ] | ||
411 | 0 | 217 | ||
412 | === added file 'docs/index.rst' | |||
413 | --- docs/index.rst 1970-01-01 00:00:00 +0000 | |||
414 | +++ docs/index.rst 2010-11-01 08:51:04 +0000 | |||
415 | @@ -0,0 +1,16 @@ | |||
416 | 1 | Renamer |version| documentation | ||
417 | 2 | =============================== | ||
418 | 3 | |||
419 | 4 | Contents: | ||
420 | 5 | |||
421 | 6 | .. toctree:: | ||
422 | 7 | :maxdepth: 3 | ||
423 | 8 | |||
424 | 9 | manual | ||
425 | 10 | plugins | ||
426 | 11 | |||
427 | 12 | Indices and tables | ||
428 | 13 | ================== | ||
429 | 14 | |||
430 | 15 | * :ref:`genindex` | ||
431 | 16 | * :ref:`search` | ||
432 | 0 | 17 | ||
433 | === added file 'docs/make.bat' | |||
434 | --- docs/make.bat 1970-01-01 00:00:00 +0000 | |||
435 | +++ docs/make.bat 2010-11-01 08:51:04 +0000 | |||
436 | @@ -0,0 +1,155 @@ | |||
437 | 1 | @ECHO OFF | ||
438 | 2 | |||
439 | 3 | REM Command file for Sphinx documentation | ||
440 | 4 | |||
441 | 5 | if "%SPHINXBUILD%" == "" ( | ||
442 | 6 | set SPHINXBUILD=sphinx-build | ||
443 | 7 | ) | ||
444 | 8 | set BUILDDIR=_build | ||
445 | 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . | ||
446 | 10 | if NOT "%PAPER%" == "" ( | ||
447 | 11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% | ||
448 | 12 | ) | ||
449 | 13 | |||
450 | 14 | if "%1" == "" goto help | ||
451 | 15 | |||
452 | 16 | if "%1" == "help" ( | ||
453 | 17 | :help | ||
454 | 18 | echo.Please use `make ^<target^>` where ^<target^> is one of | ||
455 | 19 | echo. html to make standalone HTML files | ||
456 | 20 | echo. dirhtml to make HTML files named index.html in directories | ||
457 | 21 | echo. singlehtml to make a single large HTML file | ||
458 | 22 | echo. pickle to make pickle files | ||
459 | 23 | echo. json to make JSON files | ||
460 | 24 | echo. htmlhelp to make HTML files and a HTML help project | ||
461 | 25 | echo. qthelp to make HTML files and a qthelp project | ||
462 | 26 | echo. devhelp to make HTML files and a Devhelp project | ||
463 | 27 | echo. epub to make an epub | ||
464 | 28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter | ||
465 | 29 | echo. text to make text files | ||
466 | 30 | echo. man to make manual pages | ||
467 | 31 | echo. changes to make an overview over all changed/added/deprecated items | ||
468 | 32 | echo. linkcheck to check all external links for integrity | ||
469 | 33 | echo. doctest to run all doctests embedded in the documentation if enabled | ||
470 | 34 | goto end | ||
471 | 35 | ) | ||
472 | 36 | |||
473 | 37 | if "%1" == "clean" ( | ||
474 | 38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i | ||
475 | 39 | del /q /s %BUILDDIR%\* | ||
476 | 40 | goto end | ||
477 | 41 | ) | ||
478 | 42 | |||
479 | 43 | if "%1" == "html" ( | ||
480 | 44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html | ||
481 | 45 | echo. | ||
482 | 46 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. | ||
483 | 47 | goto end | ||
484 | 48 | ) | ||
485 | 49 | |||
486 | 50 | if "%1" == "dirhtml" ( | ||
487 | 51 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml | ||
488 | 52 | echo. | ||
489 | 53 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. | ||
490 | 54 | goto end | ||
491 | 55 | ) | ||
492 | 56 | |||
493 | 57 | if "%1" == "singlehtml" ( | ||
494 | 58 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml | ||
495 | 59 | echo. | ||
496 | 60 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. | ||
497 | 61 | goto end | ||
498 | 62 | ) | ||
499 | 63 | |||
500 | 64 | if "%1" == "pickle" ( | ||
501 | 65 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle | ||
502 | 66 | echo. | ||
503 | 67 | echo.Build finished; now you can process the pickle files. | ||
504 | 68 | goto end | ||
505 | 69 | ) | ||
506 | 70 | |||
507 | 71 | if "%1" == "json" ( | ||
508 | 72 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json | ||
509 | 73 | echo. | ||
510 | 74 | echo.Build finished; now you can process the JSON files. | ||
511 | 75 | goto end | ||
512 | 76 | ) | ||
513 | 77 | |||
514 | 78 | if "%1" == "htmlhelp" ( | ||
515 | 79 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp | ||
516 | 80 | echo. | ||
517 | 81 | echo.Build finished; now you can run HTML Help Workshop with the ^ | ||
518 | 82 | .hhp project file in %BUILDDIR%/htmlhelp. | ||
519 | 83 | goto end | ||
520 | 84 | ) | ||
521 | 85 | |||
522 | 86 | if "%1" == "qthelp" ( | ||
523 | 87 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp | ||
524 | 88 | echo. | ||
525 | 89 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ | ||
526 | 90 | .qhcp project file in %BUILDDIR%/qthelp, like this: | ||
527 | 91 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Renamer.qhcp | ||
528 | 92 | echo.To view the help file: | ||
529 | 93 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Renamer.ghc | ||
530 | 94 | goto end | ||
531 | 95 | ) | ||
532 | 96 | |||
533 | 97 | if "%1" == "devhelp" ( | ||
534 | 98 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp | ||
535 | 99 | echo. | ||
536 | 100 | echo.Build finished. | ||
537 | 101 | goto end | ||
538 | 102 | ) | ||
539 | 103 | |||
540 | 104 | if "%1" == "epub" ( | ||
541 | 105 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub | ||
542 | 106 | echo. | ||
543 | 107 | echo.Build finished. The epub file is in %BUILDDIR%/epub. | ||
544 | 108 | goto end | ||
545 | 109 | ) | ||
546 | 110 | |||
547 | 111 | if "%1" == "latex" ( | ||
548 | 112 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex | ||
549 | 113 | echo. | ||
550 | 114 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. | ||
551 | 115 | goto end | ||
552 | 116 | ) | ||
553 | 117 | |||
554 | 118 | if "%1" == "text" ( | ||
555 | 119 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text | ||
556 | 120 | echo. | ||
557 | 121 | echo.Build finished. The text files are in %BUILDDIR%/text. | ||
558 | 122 | goto end | ||
559 | 123 | ) | ||
560 | 124 | |||
561 | 125 | if "%1" == "man" ( | ||
562 | 126 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man | ||
563 | 127 | echo. | ||
564 | 128 | echo.Build finished. The manual pages are in %BUILDDIR%/man. | ||
565 | 129 | goto end | ||
566 | 130 | ) | ||
567 | 131 | |||
568 | 132 | if "%1" == "changes" ( | ||
569 | 133 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes | ||
570 | 134 | echo. | ||
571 | 135 | echo.The overview file is in %BUILDDIR%/changes. | ||
572 | 136 | goto end | ||
573 | 137 | ) | ||
574 | 138 | |||
575 | 139 | if "%1" == "linkcheck" ( | ||
576 | 140 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck | ||
577 | 141 | echo. | ||
578 | 142 | echo.Link check complete; look for any errors in the above output ^ | ||
579 | 143 | or in %BUILDDIR%/linkcheck/output.txt. | ||
580 | 144 | goto end | ||
581 | 145 | ) | ||
582 | 146 | |||
583 | 147 | if "%1" == "doctest" ( | ||
584 | 148 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest | ||
585 | 149 | echo. | ||
586 | 150 | echo.Testing of doctests in the sources finished, look at the ^ | ||
587 | 151 | results in %BUILDDIR%/doctest/output.txt. | ||
588 | 152 | goto end | ||
589 | 153 | ) | ||
590 | 154 | |||
591 | 155 | :end | ||
592 | 0 | 156 | ||
593 | === added file 'docs/manual.rst' | |||
594 | --- docs/manual.rst 1970-01-01 00:00:00 +0000 | |||
595 | +++ docs/manual.rst 2010-11-01 08:51:04 +0000 | |||
596 | @@ -0,0 +1,247 @@ | |||
597 | 1 | .. index:: manual, rn | ||
598 | 2 | |||
599 | 3 | Renamer manual | ||
600 | 4 | ============== | ||
601 | 5 | |||
602 | 6 | ======== | ||
603 | 7 | SYNOPSIS | ||
604 | 8 | ======== | ||
605 | 9 | |||
606 | 10 | rn [*options*] command [*options*] argument ... | ||
607 | 11 | |||
608 | 12 | |||
609 | 13 | =========== | ||
610 | 14 | DESCRIPTION | ||
611 | 15 | =========== | ||
612 | 16 | |||
613 | 17 | **rn** is a command line interface to Renamer, an extensible utility for | ||
614 | 18 | renaming files that also keeps a log of previous activities, which allows | ||
615 | 19 | actions to be reversed. | ||
616 | 20 | |||
617 | 21 | The required *command* argument selects which renamer command to execute. Most, | ||
618 | 22 | but not all, commands invoke the renaming process on the provided arguments, | ||
619 | 23 | the :ref:`undo` command is one example that differs. Consult ``--help`` for a | ||
620 | 24 | list of available commands and the :ref:`COMMANDS` section for descriptions of | ||
621 | 25 | the builtin commands. | ||
622 | 26 | |||
623 | 27 | Renamer can be extended with new commands via Python plugins. | ||
624 | 28 | |||
625 | 29 | |||
626 | 30 | ======= | ||
627 | 31 | OPTIONS | ||
628 | 32 | ======= | ||
629 | 33 | |||
630 | 34 | -g, --glob | ||
631 | 35 | Expand arguments as UNIX-style globs. | ||
632 | 36 | |||
633 | 37 | -x, --one-file-system | ||
634 | 38 | Don't cross filesystems. This is primarily useful for avoiding copy-delete | ||
635 | 39 | behavior when renaming will cross file-system boundaries. | ||
636 | 40 | |||
637 | 41 | -n, --no-act | ||
638 | 42 | Perform a trial run with no changes made. | ||
639 | 43 | |||
640 | 44 | --link-src | ||
641 | 45 | Create a symlink at the source. The file will be moved to its new location | ||
642 | 46 | and a symlink created at its original location. | ||
643 | 47 | |||
644 | 48 | --link-dst | ||
645 | 49 | Create a symlink at the destination. The original file will not be moved | ||
646 | 50 | but a symlink will be created at the new location. | ||
647 | 51 | |||
648 | 52 | -c file, --config=file | ||
649 | 53 | Read configuration defaults from *file*. The default configuration is read | ||
650 | 54 | from *~/.renamer/renamer.conf*. See the :ref:`CONFIGURATION` section for | ||
651 | 55 | more information. | ||
652 | 56 | |||
653 | 57 | -e template, --name=template | ||
654 | 58 | Formatted filename. See the :ref:`TEMPLATES` section for more information. | ||
655 | 59 | |||
656 | 60 | -p template, --prefix=template | ||
657 | 61 | Formatted path to prefix to files before renaming. See the :ref:`TEMPLATES` | ||
658 | 62 | section for more information. | ||
659 | 63 | |||
660 | 64 | -l number, --concurrent=number | ||
661 | 65 | Maximum number of asynchronous tasks to perform concurrently. The default | ||
662 | 66 | is 10. | ||
663 | 67 | |||
664 | 68 | --help | ||
665 | 69 | Display a help message describing Renamer's command-line options. | ||
666 | 70 | |||
667 | 71 | -q, --quiet | ||
668 | 72 | Suppress output. | ||
669 | 73 | |||
670 | 74 | --version | ||
671 | 75 | Display version information. | ||
672 | 76 | |||
673 | 77 | -v, --verbose | ||
674 | 78 | Increase output, use more times for greater effect. | ||
675 | 79 | |||
676 | 80 | |||
677 | 81 | .. index:: commands | ||
678 | 82 | |||
679 | 83 | .. _commands: | ||
680 | 84 | |||
681 | 85 | ======== | ||
682 | 86 | COMMANDS | ||
683 | 87 | ======== | ||
684 | 88 | |||
685 | 89 | Commands are the parts of Renamer that process arguments and make things | ||
686 | 90 | happen. Most commands will extract metadata from each argument in some fashion | ||
687 | 91 | and store that metadata in template variables which is used to rename the | ||
688 | 92 | files. | ||
689 | 93 | |||
690 | 94 | .. index:: tvrage | ||
691 | 95 | |||
692 | 96 | .. _tvrage: | ||
693 | 97 | |||
694 | 98 | tvrage | ||
695 | 99 | ------ | ||
696 | 100 | |||
697 | 101 | --series | ||
698 | 102 | Override the series name metadata. | ||
699 | 103 | |||
700 | 104 | --season | ||
701 | 105 | Override the season number metadata. | ||
702 | 106 | |||
703 | 107 | --episode | ||
704 | 108 | Override the episode number metadata. | ||
705 | 109 | |||
706 | 110 | Use TV episode metadata from filenames (such as ``Lost S01E01.avi``) to consult | ||
707 | 111 | the `TV Rage`_ database for detailed and accurate metadata used in renaming. | ||
708 | 112 | |||
709 | 113 | .. _TV Rage: http://tvrage.com/ | ||
710 | 114 | |||
711 | 115 | Renamer is able to extract metadata from a wide variety of filename structures. | ||
712 | 116 | Unfortunately, since useful metadata within the video container itself is | ||
713 | 117 | extremely rare, the only reliable way to extract information is from the | ||
714 | 118 | filename, meaning that filenames should be as clear as possible and contain as | ||
715 | 119 | much useful metadata as possible. | ||
716 | 120 | |||
717 | 121 | In the event a filename does not contain enough information to determine a | ||
718 | 122 | name, season and episode number you can use the override command-line options | ||
719 | 123 | ``--series``, ``--season`` and ``--episode``. Specifying any one of these will | ||
720 | 124 | accomplish two things: | ||
721 | 125 | |||
722 | 126 | 1. Override any detected metadata in the filename for that particular | ||
723 | 127 | component, and; | ||
724 | 128 | |||
725 | 129 | 2. Relax the filename detection techniques so that less specific filenames can | ||
726 | 130 | match when there is enough combined metadata between filenames and | ||
727 | 131 | overrides. For example: A file named ``House - 1.avi`` combined with | ||
728 | 132 | ``--season=2`` means that there is enough metadata to look up information | ||
729 | 133 | for the *first* episode of the *second* season of the show "House". | ||
730 | 134 | |||
731 | 135 | |||
732 | 136 | .. index:: audio | ||
733 | 137 | |||
734 | 138 | .. _audio: | ||
735 | 139 | |||
736 | 140 | audio | ||
737 | 141 | ----- | ||
738 | 142 | |||
739 | 143 | Use audio metadata from files for renaming. A wide variety of audio and audio | ||
740 | 144 | metadata formats are supported. | ||
741 | 145 | |||
742 | 146 | |||
743 | 147 | .. index:: undo | ||
744 | 148 | |||
745 | 149 | .. _undo: | ||
746 | 150 | |||
747 | 151 | undo | ||
748 | 152 | ---- | ||
749 | 153 | |||
750 | 154 | --ignore-errors | ||
751 | 155 | Do not stop the process when encountering OS errors. | ||
752 | 156 | |||
753 | 157 | |||
754 | 158 | Undo previous Renamer actions. | ||
755 | 159 | |||
756 | 160 | The ``action`` subcommand will undo individual actions while the ``changeset`` | ||
757 | 161 | subcommand will undo entire changesets, once an item has been undone it is | ||
758 | 162 | removed from the history. The ``forget`` subcommand will remove an item from | ||
759 | 163 | history without undoing it. | ||
760 | 164 | |||
761 | 165 | Use the ``list`` subcommand to find identifiers for the changesets or actions | ||
762 | 166 | to undo. | ||
763 | 167 | |||
764 | 168 | |||
765 | 169 | .. index:: templates | ||
766 | 170 | |||
767 | 171 | .. _templates: | ||
768 | 172 | |||
769 | 173 | ========= | ||
770 | 174 | TEMPLATES | ||
771 | 175 | ========= | ||
772 | 176 | |||
773 | 177 | A Python template string, as described by the Python `template documentation`_, | ||
774 | 178 | can contain variables that will be substituted with runtime values from Renamer | ||
775 | 179 | commands. | ||
776 | 180 | |||
777 | 181 | .. _template documentation: | ||
778 | 182 | http://docs.python.org/library/string.html#template-strings | ||
779 | 183 | |||
780 | 184 | For example the :ref:`tvrage` command provides variables containing TV episode | ||
781 | 185 | metadata; so a template such as:: | ||
782 | 186 | |||
783 | 187 | $series S${padded_season}E${padded_episode} - $title | ||
784 | 188 | |||
785 | 189 | Applied to episode 1 of season 1 of "Lost" (named "Pilot (1)") will result in:: | ||
786 | 190 | |||
787 | 191 | Lost S01E01 - Pilot (1) | ||
788 | 192 | |||
789 | 193 | The variables available will differ from command to command, consult the | ||
790 | 194 | ``--help`` output for the command to learn more. | ||
791 | 195 | |||
792 | 196 | |||
793 | 197 | .. index:: configuration, config file | ||
794 | 198 | |||
795 | 199 | .. _configuration: | ||
796 | 200 | |||
797 | 201 | ============= | ||
798 | 202 | CONFIGURATION | ||
799 | 203 | ============= | ||
800 | 204 | |||
801 | 205 | Configuration files follow a basic INI syntax. Sections are named after their | ||
802 | 206 | command names, as listed in ``--help``, the global configuration section is | ||
803 | 207 | named ``renamer``. Configuration options are derived from their long | ||
804 | 208 | command-line counterparts without the ``--`` prefix. Flags can be turned on or | ||
805 | 209 | off with values such as: ``true``, ``yes``, ``1``, ``false``, ``no``, ``0``. | ||
806 | 210 | |||
807 | 211 | For example the command line:: | ||
808 | 212 | |||
809 | 213 | rn --concurrent=5 --link-src --prefix=~/stuff somecommand --no-thing | ||
810 | 214 | |||
811 | 215 | can be specified in a configuration file:: | ||
812 | 216 | |||
813 | 217 | [renamer] | ||
814 | 218 | concurrent=5 | ||
815 | 219 | link-src=yes | ||
816 | 220 | prefix=~/stuff | ||
817 | 221 | |||
818 | 222 | [somecommand] | ||
819 | 223 | no-thing=yes | ||
820 | 224 | |||
821 | 225 | It is also possible to specify global configuration options in a command | ||
822 | 226 | section to override them only for that specific command. | ||
823 | 227 | |||
824 | 228 | Arguments specified on the command line will override values in the | ||
825 | 229 | configuration file. | ||
826 | 230 | |||
827 | 231 | |||
828 | 232 | ==== | ||
829 | 233 | BUGS | ||
830 | 234 | ==== | ||
831 | 235 | |||
832 | 236 | Please report any bugs to the `Renamer Launchpad project`_ | ||
833 | 237 | ``<http://launchpad.net/renamer/>``. | ||
834 | 238 | |||
835 | 239 | .. _Renamer Launchpad project: http://launchpad.net/renamer/ | ||
836 | 240 | |||
837 | 241 | |||
838 | 242 | ===== | ||
839 | 243 | FILES | ||
840 | 244 | ===== | ||
841 | 245 | |||
842 | 246 | ~/.renamer/renamer.conf | ||
843 | 247 | Contains the user's default configuration. | ||
844 | 0 | 248 | ||
845 | === added file 'docs/plugins.rst' | |||
846 | --- docs/plugins.rst 1970-01-01 00:00:00 +0000 | |||
847 | +++ docs/plugins.rst 2010-11-01 08:51:04 +0000 | |||
848 | @@ -0,0 +1,134 @@ | |||
849 | 1 | .. index:: plugins | ||
850 | 2 | |||
851 | 3 | Creating a Renamer Plugin | ||
852 | 4 | ========================= | ||
853 | 5 | |||
854 | 6 | Introduction | ||
855 | 7 | ------------ | ||
856 | 8 | |||
857 | 9 | Renamer plugins are Python code, discovered by Twisted's `plugin | ||
858 | 10 | system`_, that extends Renamer's functionality without having to modify the | ||
859 | 11 | core of Renamer. | ||
860 | 12 | |||
861 | 13 | .. _plugin system: | ||
862 | 14 | http://twistedmatrix.com/documents/current/core/howto/plugin.html | ||
863 | 15 | |||
864 | 16 | There are two kinds of pluggable code in Renamer: | ||
865 | 17 | |||
866 | 18 | 1. Commands that perform actions unrelated to directly renaming a file. An | ||
867 | 19 | example of this would be the `undo` command. | ||
868 | 20 | |||
869 | 21 | 2. Renaming commands that determine new filenames from existing files and | ||
870 | 22 | ultimately result in an input being renamed. An example of this would be the | ||
871 | 23 | :ref:`tvrage` command. | ||
872 | 24 | |||
873 | 25 | Since the topic of creating commands that are not directly related to renaming | ||
874 | 26 | is so broad, this document will primarily focus on creating a command that | ||
875 | 27 | performs renaming. | ||
876 | 28 | |||
877 | 29 | |||
878 | 30 | Foundations | ||
879 | 31 | ----------- | ||
880 | 32 | |||
881 | 33 | Renamer commands are simply Twisted `Options`_ subclasses with a few extra bits | ||
882 | 34 | thrown in, so all the usual Options attributes (such as ``optParameters``) are | ||
883 | 35 | available for use and should be how you expose additional options for your | ||
884 | 36 | command. | ||
885 | 37 | |||
886 | 38 | .. _Options: | ||
887 | 39 | http://twistedmatrix.com/documents/current/core/howto/options.html | ||
888 | 40 | |||
889 | 41 | In almost all cases you will want to inherit from the ``RenamingCommand`` base | ||
890 | 42 | class, as it ensure your subclass provides all the right interfaces as well as | ||
891 | 43 | invoking your command and performing the actual file renaming. | ||
892 | 44 | |||
893 | 45 | At the heart of a renaming command is ``processArgument`` which accepts one | ||
894 | 46 | argument and returns a Python dictionary. That dictionary is then used to | ||
895 | 47 | perform `template substitution`_ on the ``name`` and ``prefix`` command-line | ||
896 | 48 | options (or, if they're not given, command-specific defaults.) This process of | ||
897 | 49 | calling ``processArgument`` is repeated for each argument given, letting your | ||
898 | 50 | command process one argument at a time. | ||
899 | 51 | |||
900 | 52 | .. _template substitution: | ||
901 | 53 | http://docs.python.org/library/string.html#template-strings | ||
902 | 54 | |||
903 | 55 | |||
904 | 56 | Deferreds | ||
905 | 57 | --------- | ||
906 | 58 | |||
907 | 59 | If your command performs a long-running task, such as fetching data from a web | ||
908 | 60 | server, you can return a `Deferred`_ from ``processArgument`` that should | ||
909 | 61 | ultimately return with a Python dictionary to be used in assembling the | ||
910 | 62 | destination filename. | ||
911 | 63 | |||
912 | 64 | .. _Deferred: | ||
913 | 65 | http://twistedmatrix.com/documents/current/core/howto/deferredindepth.html | ||
914 | 66 | |||
915 | 67 | |||
916 | 68 | Sample command | ||
917 | 69 | -------------- | ||
918 | 70 | |||
919 | 71 | Below is the complete source code of a command that renames files named as | ||
920 | 72 | POSIX timestamps (e.g. ``1287758780.4690211.txt``) to a human-readable | ||
921 | 73 | representation of the timestamp (e.g. ``2010-10-22 16-46-20.txt``). | ||
922 | 74 | |||
923 | 75 | .. literalinclude:: code/plugins_command.py | ||
924 | 76 | :linenos: | ||
925 | 77 | |||
926 | 78 | |||
927 | 79 | Installing the plugin | ||
928 | 80 | --------------------- | ||
929 | 81 | |||
930 | 82 | Now that we've constructed our command we need to make it available to Renamer. | ||
931 | 83 | This process consists of the following simple steps: | ||
932 | 84 | |||
933 | 85 | 1. Create a directory for your plugins such as ``MyRenamerPlugins`` wherever you | ||
934 | 86 | usually put your source code, beneath this create a directory named | ||
935 | 87 | ``renamer`` and beneath that a directory named ``plugins``. | ||
936 | 88 | |||
937 | 89 | Your directory tree should look like:: | ||
938 | 90 | |||
939 | 91 | . | ||
940 | 92 | |-- MyRenamerPlugins | ||
941 | 93 | | `-- renamer | ||
942 | 94 | | | `-- plugins | ||
943 | 95 | |||
944 | 96 | 2. Add your directory (``MyRenamerPlugins`` in the previous step) to sys.path | ||
945 | 97 | (typically by adding it to the PYTHONPATH environment variable.) | ||
946 | 98 | |||
947 | 99 | 3. Put your plugin source code file (with a ``.py`` extension) in the | ||
948 | 100 | ``MyRenamerPlugins/renamer/plugins`` directory. It is important to note that | ||
949 | 101 | this directory must **not** be a Python package (i.e. it must not contain | ||
950 | 102 | ``__init__.py``) and will be skipped (i.e. no plugins will be loaded) if it is | ||
951 | 103 | one. | ||
952 | 104 | |||
953 | 105 | 4. You can verify that your plugin is visible by running an interactive Python | ||
954 | 106 | prompt and doing something similar to:: | ||
955 | 107 | |||
956 | 108 | >>> from renamer.plugins.timestamp import ReadableTimestamps | ||
957 | 109 | >>> | ||
958 | 110 | |||
959 | 111 | (This obviously assumes that you used the ``ReadableTimestamps`` example and | ||
960 | 112 | stored it in a file called ``timestamp.py``.) | ||
961 | 113 | |||
962 | 114 | If your plugin is installed correctly there should be no errors importing | ||
963 | 115 | the module. | ||
964 | 116 | |||
965 | 117 | |||
966 | 118 | Using the plugin | ||
967 | 119 | ---------------- | ||
968 | 120 | |||
969 | 121 | After your plugin has been installed correctly you can use it:: | ||
970 | 122 | |||
971 | 123 | $ touch 1287758780.4690211.txt | ||
972 | 124 | $ rn timestamp 1287758780.4690211.txt | ||
973 | 125 | $ ls | ||
974 | 126 | 2010-10-22 16-46-20.txt | ||
975 | 127 | |||
976 | 128 | It is possible that you may need to regenerate the Twisted plugin cache if you | ||
977 | 129 | notice nonsensical errors related to your plugin objects, especially if you're | ||
978 | 130 | actively developing a plugin and testing it. Refer to the Twisted documentation | ||
979 | 131 | regarding `plugin caching`_. | ||
980 | 132 | |||
981 | 133 | .. _plugin caching: | ||
982 | 134 | http://twistedmatrix.com/documents/current/core/howto/plugin.html#auto3 | ||
983 | 0 | 135 | ||
984 | === removed file 'docs/rn.1' | |||
985 | --- docs/rn.1 2009-05-06 10:15:24 +0000 | |||
986 | +++ docs/rn.1 1970-01-01 00:00:00 +0000 | |||
987 | @@ -1,93 +0,0 @@ | |||
988 | 1 | .TH RN 1 2009-05-04 "version 1.0.0" "USER COMMANDS" | ||
989 | 2 | |||
990 | 3 | .SH NAME | ||
991 | 4 | rn \- scriptable and extensible mass file renamer | ||
992 | 5 | |||
993 | 6 | .SH SYNOPSYS | ||
994 | 7 | .B rn | ||
995 | 8 | .RB [\| \-g \|] | ||
996 | 9 | .RB [\| \-m \|] | ||
997 | 10 | .RB [\| \-R \|] | ||
998 | 11 | .RB [\| \-s | ||
999 | 12 | .IR file \|] | ||
1000 | 13 | .RB [\| \-S | ||
1001 | 14 | .IR sort \|] | ||
1002 | 15 | .RB [\| \-t \|] | ||
1003 | 16 | .RB [\| \-q \|] | ||
1004 | 17 | .RB [\| \-v \|] | ||
1005 | 18 | .RI [\| argument \|] | ||
1006 | 19 | \&\.\.\. | ||
1007 | 20 | |||
1008 | 21 | .SH DESCRIPTION | ||
1009 | 22 | .B rn | ||
1010 | 23 | is a command line interface to Renamer, a utility designed to rename files | ||
1011 | 24 | according to a set of user-provided instructions, generally residing in a | ||
1012 | 25 | script file. | ||
1013 | 26 | |||
1014 | 27 | .SH OPTIONS | ||
1015 | 28 | If no arguments are provided, | ||
1016 | 29 | .B rn | ||
1017 | 30 | is invoked in interactive mode. | ||
1018 | 31 | .TP | ||
1019 | 32 | .B \-g, \-\-glob | ||
1020 | 33 | Expand arguments according to UNIX-style globs. | ||
1021 | 34 | .TP | ||
1022 | 35 | .B \-m, \-\-move | ||
1023 | 36 | Enable \(lqmove mode\(rq, this allows scripts to perform file move operations. | ||
1024 | 37 | .TP | ||
1025 | 38 | .B \-R, \-\-reverse | ||
1026 | 39 | Reverse the sorting order of the arguments. | ||
1027 | 40 | .TP | ||
1028 | 41 | .BI \-s\ file ,\ \-\-script= file | ||
1029 | 42 | Execute | ||
1030 | 43 | .I file\c | ||
1031 | 44 | , as a script, for each argument. Each argument is invoked in its own script | ||
1032 | 45 | environment, meaning that the stack is not retained between executions and | ||
1033 | 46 | any stored variables are not persisted. | ||
1034 | 47 | .TP | ||
1035 | 48 | .BI \-S\ sort ,\ \-\-sort= sort | ||
1036 | 49 | Sort arguments according to criteria: | ||
1037 | 50 | .BR name , \ size , \ time . | ||
1038 | 51 | .TP | ||
1039 | 52 | .B \-t, \-\-dry-run | ||
1040 | 53 | Perform a dry-run, meaning that no permanent operations are performed, such | ||
1041 | 54 | as file renaming. | ||
1042 | 55 | .TP | ||
1043 | 56 | .B \-q, \-\-quiet | ||
1044 | 57 | Reduce verbosity level. | ||
1045 | 58 | .TP | ||
1046 | 59 | .B \-v, \-\-verbose | ||
1047 | 60 | Increase verbosity level. | ||
1048 | 61 | |||
1049 | 62 | .SH SCRIPTING | ||
1050 | 63 | Renamer operates in a stack based environment. Command line arguments, | ||
1051 | 64 | function return values and function parameters are all pushed and popped | ||
1052 | 65 | from the stack. | ||
1053 | 66 | .PP | ||
1054 | 67 | Function arguments are an exception: any arguments passed inline to a function | ||
1055 | 68 | are subtracted from the total number of arguments required and appended to | ||
1056 | 69 | the arguments popped from the stack. For example: | ||
1057 | 70 | .PP | ||
1058 | 71 | .nf | ||
1059 | 72 | rn> push "foo bar baz" | ||
1060 | 73 | rn> split " " | ||
1061 | 74 | rn> stack | ||
1062 | 75 | --> ['foo', 'bar', 'baz'] | ||
1063 | 76 | .fi | ||
1064 | 77 | .PP | ||
1065 | 78 | Renamer's interactive mode should prove valuable in exploring the behaviour | ||
1066 | 79 | of Renamer's commands, particularly the | ||
1067 | 80 | .I help | ||
1068 | 81 | and | ||
1069 | 82 | .I commands | ||
1070 | 83 | functions. | ||
1071 | 84 | |||
1072 | 85 | .SH FILES | ||
1073 | 86 | .TP | ||
1074 | 87 | .I ~/.renamer/scripts/ | ||
1075 | 88 | Directory containing user-provided scripts | ||
1076 | 89 | .TP | ||
1077 | 90 | .I ~/.renamer/plugin_name/config | ||
1078 | 91 | Config file for configuring | ||
1079 | 92 | .B plugin_name | ||
1080 | 93 | individually | ||
1081 | 94 | 0 | ||
1082 | === added directory 'docs/static' | |||
1083 | === added directory 'docs/templates' | |||
1084 | === modified file 'renamer/plugins/undo.py' | |||
1085 | --- renamer/plugins/undo.py 2010-10-24 17:46:32 +0000 | |||
1086 | +++ renamer/plugins/undo.py 2010-11-01 08:51:04 +0000 | |||
1087 | @@ -27,7 +27,7 @@ | |||
1088 | 27 | 27 | ||
1089 | 28 | class _UndoMixin(object): | 28 | class _UndoMixin(object): |
1090 | 29 | optFlags = [ | 29 | optFlags = [ |
1092 | 30 | ('ignore-errors', None, 'Do not stop the process when encountering OS errors')] | 30 | ('ignore-errors', None, 'Do not stop the process when encountering OS errors.')] |
1093 | 31 | 31 | ||
1094 | 32 | 32 | ||
1095 | 33 | def undoActions(self, options, changeset, actions): | 33 | def undoActions(self, options, changeset, actions): |
Conflicts between this branch and trunk have been resolved.