From d264c145504bf51dc248de9a86155fd759dac9f2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 26 Apr 2017 08:33:54 +0530 Subject: [PATCH] String changes --- manual/creating_plugins.rst | 8 ++++---- manual/gui.rst | 4 ++-- src/calibre/debug.py | 6 +++--- src/calibre/ebooks/conversion/plumber.py | 2 +- src/calibre/gui2/dialogs/metadata_bulk.py | 6 +++--- src/calibre/gui2/preferences/create_custom_column.py | 2 +- src/calibre/gui2/preferences/template_functions.ui | 2 +- src/calibre/gui2/tweak_book/search.py | 2 +- src/calibre/utils/formatter_functions.py | 9 ++++++--- 9 files changed, 22 insertions(+), 19 deletions(-) diff --git a/manual/creating_plugins.rst b/manual/creating_plugins.rst index 6b402971b1..9572b0aba5 100644 --- a/manual/creating_plugins.rst +++ b/manual/creating_plugins.rst @@ -17,7 +17,7 @@ Here, we will teach you how to create your own plugins to add new features to ca Anatomy of a calibre plugin --------------------------- -A calibre plugin is very simple, it's just a zip file that contains some python code +A calibre plugin is very simple, it's just a zip file that contains some Python code and any other resources like image files needed by the plugin. Without further ado, let's see a basic example. @@ -70,11 +70,11 @@ The first thing to note is that this zip file has a lot more files in it, explai The prefix ``calibre_plugins`` must always be present. ``some_name`` comes from the filename of the empty text file. ``some_module`` refers to :file:`some_module.py` file inside the zip file. Note that this importing is just as - powerful as regular python imports. You can create packages and subpackages of .py modules inside the zip file, + powerful as regular Python imports. You can create packages and subpackages of .py modules inside the zip file, just like you would normally (by defining __init__.py in each sub-directory), and everything should Just Work. The name you use for ``some_name`` enters a global namespace shared by all plugins, **so make it as unique as possible**. - But remember that it must be a valid python identifier (only alphabets, numbers and the underscore). + But remember that it must be a valid Python identifier (only alphabets, numbers and the underscore). **__init__.py** As before, the file that defines the plugin class @@ -306,7 +306,7 @@ Or from within calibre by right-clicking the :guilabel:`Preferences` button or u When running from the command line, debug output will be printed to the console, when running from within calibre the output will go to a txt file. -You can insert print statements anywhere in your plugin code, they will be output in debug mode. Remember, this is python, you really shouldn't need anything more than print statements to debug ;) I developed all of calibre using just this debugging technique. +You can insert print statements anywhere in your plugin code, they will be output in debug mode. Remember, this is Python, you really shouldn't need anything more than print statements to debug ;) I developed all of calibre using just this debugging technique. You can quickly test changes to your plugin by using the following command line:: diff --git a/manual/gui.rst b/manual/gui.rst index 5fdd2305df..cf9426527d 100644 --- a/manual/gui.rst +++ b/manual/gui.rst @@ -342,7 +342,7 @@ Two other kinds of searches are available: equality search and search using `reg Equality searches are indicated by prefixing the search string with an equals sign (=). For example, the query ``tag:"=science"`` will match "science", but not "science fiction" or "hard science". Regular expression searches are -indicated by prefixing the search string with a tilde (~). Any `python-compatible regular expression `_ can +indicated by prefixing the search string with a tilde (~). Any `Python-compatible regular expression `_ can be used. Note that backslashes used to escape special characters in regular expressions must be doubled because single backslashes will be removed during query parsing. For example, to match a literal parenthesis you must enter ``\\(``. Regular expression searches are 'contains' searches unless the expression contains anchors. Should you need to search for a string with a leading equals or tilde, prefix the string with a backslash. @@ -621,7 +621,7 @@ The Jobs panel shows the number of currently running jobs. Jobs are tasks that r
-Keyboard Shortcuts +Keyboard shortcuts --------------------- calibre has several keyboard shortcuts to save you time and mouse movement. These shortcuts are active in the book list view (when you're not editing the details of a particular book), and most of them affect the title you have selected. The calibre e-book viewer has its own shortcuts which can be customised by clicking the :guilabel:`Preferences` button in the viewer. diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 357f42537c..6bd4de87fe 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -17,7 +17,7 @@ def option_parser(): {0} Various command line interfaces useful for debugging calibre. With no options, -this command starts an embedded python interpreter. You can also run the main +this command starts an embedded Python interpreter. You can also run the main calibre GUI, the calibre viewer and the calibre editor in debug mode. It also contains interfaces to various bits of calibre that do not have @@ -30,8 +30,8 @@ You can also use %prog to run standalone scripts. To do that use it like this: Everything after the -- is passed to the script. ''').format(_('%prog [options]'), '%prog myscript.py -- --option1 --option2 file1 file2 ...')) - parser.add_option('-c', '--command', help=_('Run python code.')) - parser.add_option('-e', '--exec-file', help=_('Run the python code in file.')) + parser.add_option('-c', '--command', help=_('Run Python code.')) + parser.add_option('-e', '--exec-file', help=_('Run the Python code in file.')) parser.add_option('-f', '--subset-font', action='store_true', default=False, help=_('Subset the specified font. Use -- after this option to pass option to the font subsetting program.')) parser.add_option('-d', '--debug-device-driver', default=False, action='store_true', diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index aef3da92db..bf8853bc25 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -710,7 +710,7 @@ OptionRecommendation(name='search_replace', 'Path to a file containing search and replace regular expressions. ' 'The file must contain alternating lines of regular expression ' 'followed by replacement pattern (which can be an empty line). ' - 'The regular expression must be in the python regex syntax and ' + 'The regular expression must be in the Python regex syntax and ' 'the file must be UTF-8 encoded.')), ] # }}} diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 8d3c119982..9342fdbe51 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -512,7 +512,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): self.regexp_heading = _( 'In regular expression mode, the search text is an ' - 'arbitrary python-compatible regular expression. The ' + 'arbitrary Python-compatible regular expression. The ' 'replacement text can contain backreferences to parenthesized ' 'expressions in the pattern. The search is not anchored, ' 'and can match and replace multiple times on the same string. ' @@ -521,8 +521,8 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): 'The destination box specifies the field where the result after ' 'matching and replacement is to be assigned. You can replace ' 'the text in the field, or prepend or append the matched text. ' - 'See ' - 'this reference for more information on python\'s regular ' + 'See ' + 'this reference for more information on Python\'s regular ' 'expressions, and in particular the \'sub\' function.' ) diff --git a/src/calibre/gui2/preferences/create_custom_column.py b/src/calibre/gui2/preferences/create_custom_column.py index 9604fc4491..4539c7e4d5 100644 --- a/src/calibre/gui2/preferences/create_custom_column.py +++ b/src/calibre/gui2/preferences/create_custom_column.py @@ -412,7 +412,7 @@ class CreateCustomColumn(QDialog): else: l, dl = _('&Format for numbers'), ( '

' + _('Default: Not formatted. For format language details see' - ' the python documentation')) + ' the Python documentation')) if col_type == 'int': self.format_box.setToolTip('

' + _('Examples: The format {0:0>4d} ' diff --git a/src/calibre/gui2/preferences/template_functions.ui b/src/calibre/gui2/preferences/template_functions.ui index f0a174912d..a368da11fb 100644 --- a/src/calibre/gui2/preferences/template_functions.ui +++ b/src/calibre/gui2/preferences/template_functions.ui @@ -123,7 +123,7 @@ - &Program code: (be sure to follow python indenting rules) + &Program code: (be sure to follow Python indenting rules) program diff --git a/src/calibre/gui2/tweak_book/search.py b/src/calibre/gui2/tweak_book/search.py index 342c7c9550..f3207dec32 100644 --- a/src/calibre/gui2/tweak_book/search.py +++ b/src/calibre/gui2/tweak_book/search.py @@ -211,7 +211,7 @@ class ModeBox(QComboBox):

Regex
The search expression is interpreted as a regular expression. See the User Manual for more help on using regular expressions.
Regex-function
-
The search expression is interpreted as a regular expression. The replace expression is an arbitrarily powerful python function.
+
The search expression is interpreted as a regular expression. The replace expression is an arbitrarily powerful Python function.
''')) @dynamic_property diff --git a/src/calibre/utils/formatter_functions.py b/src/calibre/utils/formatter_functions.py index 10f311d58a..211e2e89ac 100644 --- a/src/calibre/utils/formatter_functions.py +++ b/src/calibre/utils/formatter_functions.py @@ -108,6 +108,7 @@ class FormatterFunctions(object): for a in c.aliases: self._functions[a] = c + _ff = FormatterFunctions() @@ -597,7 +598,7 @@ class BuiltinRe(BuiltinFormatterFunction): __doc__ = doc = _('re(val, pattern, replacement) -- return val after applying ' 'the regular expression. All instances of `pattern` are replaced ' 'with `replacement`. As in all of calibre, these are ' - 'python-compatible regular expressions') + 'Python-compatible regular expressions') def evaluate(self, formatter, kwargs, mi, locals, val, pattern, replacement): return re.sub(pattern, replacement, val, flags=re.I) @@ -848,10 +849,10 @@ class BuiltinFormatNumber(BuiltinFormatterFunction): arg_count = 2 category = 'Formatting values' __doc__ = doc = _('format_number(v, template) -- format the number v using ' - 'a python formatting template such as "{0:5.2f}" or ' + 'a Python formatting template such as "{0:5.2f}" or ' '"{0:,d}" or "${0:5,.2f}". The field_name part of the ' 'template must be a 0 (zero) (the "{0:" in the above examples). ' - 'See the template language and python documentation for more ' + 'See the template language and Python documentation for more ' 'examples. Returns the empty string if formatting fails.' ) @@ -1564,6 +1565,7 @@ class BuiltinAuthorSorts(BuiltinFormatterFunction): names = [sort_data.get(n) for n in mi.authors if n.strip()] return val_sep.join(n for n in names) + _formatter_builtins = [ BuiltinAdd(), BuiltinAnd(), BuiltinApproximateFormats(), BuiltinAssign(), BuiltinAuthorLinks(), BuiltinAuthorSorts(), BuiltinBooksize(), @@ -1598,6 +1600,7 @@ class FormatterUserFunction(FormatterFunction): self.arg_count = arg_count self.program_text = program_text + tabs = re.compile(r'^\t*')