mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove version spec from python docs links
This commit is contained in:
parent
c5003ede6c
commit
9ba6848530
@ -166,7 +166,7 @@ calibre is the directory that contains the src and resources sub-directories.
|
||||
|
||||
The next step is to set the environment variable ``CALIBRE_DEVELOP_FROM`` to the absolute path of the src directory.
|
||||
So, following the example above, it would be ``C:\Users\kovid\work\calibre\src``. `Here is a short
|
||||
guide <https://docs.python.org/2/using/windows.html#excursus-setting-environment-variables>`_ to setting environment
|
||||
guide <https://docs.python.org/using/windows.html#excursus-setting-environment-variables>`_ to setting environment
|
||||
variables on Windows.
|
||||
|
||||
Once you have set the environment variable, open a new command prompt and check that it was correctly set by using
|
||||
@ -333,7 +333,7 @@ the debugging session::
|
||||
calibre-debug -c "from calibre.rpdb import cli; cli()"
|
||||
|
||||
You can read about how to use the Python debugger in the `Python stdlib docs
|
||||
for the pdb module <https://docs.python.org/2/library/pdb.html#debugger-commands>`_.
|
||||
for the pdb module <https://docs.python.org/library/pdb.html#debugger-commands>`_.
|
||||
|
||||
.. note::
|
||||
By default, the remote debugger will try to connect on port 4444. You can
|
||||
|
@ -10,7 +10,7 @@ In the standard *regexp* mode for search and replace, you specify both a
|
||||
regular expression to search for as well as a template that is used to replace
|
||||
all found matches. In function mode, instead of using a fixed template, you
|
||||
specify an arbitrary function, in the
|
||||
`Python programming language <https://docs.python.org/2.7/>`_. This allows
|
||||
`Python programming language <https://docs.python.org>`_. This allows
|
||||
you to do lots of things that are not possible with simple templates.
|
||||
|
||||
Techniques for using function mode and the syntax will be described by means of
|
||||
@ -57,7 +57,7 @@ Python function named replace, that accepts all the arguments shown above.
|
||||
For the moment, we wont worry about all the different arguments to
|
||||
``replace()`` function. Just focus on the ``match`` argument. It represents a
|
||||
match when running a search and replace. Its full documentation in available
|
||||
`here <https://docs.python.org/2.7/library/re.html#match-objects>`_.
|
||||
`here <https://docs.python.org/library/re.html#match-objects>`_.
|
||||
``match.group()`` simply returns all the matched text and all we do is replace
|
||||
hyphens in that text with em-dashes, first replacing double hyphens and
|
||||
then single hyphens.
|
||||
@ -239,7 +239,7 @@ The ``match`` argument
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``match`` argument represents the currently found match. It is a
|
||||
`Python Match object <https://docs.python.org/2.7/library/re.html#match-objects>`_.
|
||||
`Python Match object <https://docs.python.org/library/re.html#match-objects>`_.
|
||||
Its most useful method is ``group()`` which can be used to get the matched
|
||||
text corresponding to individual capture groups in the search regular
|
||||
expression.
|
||||
|
@ -26,5 +26,4 @@ Glossary
|
||||
**URL** *(Uniform Resource Locator)* for example: ``http://example.com``
|
||||
|
||||
regexp
|
||||
**Regular expressions** provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. See `regexp syntax <https://docs.python.org/2.7/library/re.html>`_ for the syntax of regular expressions used in Python.
|
||||
|
||||
**Regular expressions** provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. See `regexp syntax <https://docs.python.org/library/re.html>`_ for the syntax of regular expressions used in Python.
|
||||
|
@ -345,7 +345,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 <https://docs.python.org/2/library/re.html>`_ can
|
||||
indicated by prefixing the search string with a tilde (~). Any `Python-compatible regular expression <https://docs.python.org/library/re.html>`_ 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.
|
||||
|
@ -103,7 +103,7 @@ This is Python, so indentation is important. After you've added the lines, it sh
|
||||
.. image:: images/bbc_altered.png
|
||||
:align: center
|
||||
|
||||
In the above, ``def print_version(self, url)`` defines a *method* that is called by calibre for every article. ``url`` is the URL of the original article. What ``print_version`` does is take that url and replace it with the new URL that points to the print version of the article. To learn about `Python <https://www.python.org>`_ see the `tutorial <https://docs.python.org/2/tutorial/>`_.
|
||||
In the above, ``def print_version(self, url)`` defines a *method* that is called by calibre for every article. ``url`` is the URL of the original article. What ``print_version`` does is take that url and replace it with the new URL that points to the print version of the article. To learn about `Python <https://www.python.org>`_ see the `tutorial <https://docs.python.org/tutorial/>`_.
|
||||
|
||||
Now, click the :guilabel:`Add/update recipe` button and your changes will be saved. Re-download the e-book. You should have a much improved e-book. One of the problems with the new version is that the fonts on the print version webpage are too small. This is automatically fixed when converting to an e-book, but even after the fixing process, the font size of the menus and navigation bar to become too large relative to the article text. To fix this, we will do some more customization, in the next section.
|
||||
|
||||
|
@ -118,7 +118,7 @@ Bulk editing metadata
|
||||
|
||||
The last part is regular expression search and replace in metadata fields. You can access this by selecting multiple books in the library and using bulk metadata edit. Be very careful when using this last feature, as it can do **Very Bad Things** to your library! Doublecheck that your expressions do what you want them to using the test fields, and only mark the books you really want to change! In the regular expression search mode, you can search in one field, replace the text with something and even write the result into another field. A practical example: Say your library contained the books of Frank Herbert's Dune series, named after the fashion ``Dune 1 - Dune``, ``Dune 2 - Dune Messiah`` and so on. Now you want to get ``Dune`` into the series field. You can do that by searching for ``(.*?) \d+ - .*`` in the title field and replacing it with ``\1`` in the series field. See what I did there? That's a reference to the first group you're replacing the series field with. Now that you have the series all set, you only need to do another search for ``.*? -`` in the title field and replace it with ``""`` (an empty string), again in the title field, and your metadata is all neat and tidy. Isn't that great? By the way, instead of replacing the entire field, you can also append or prepend to the field, so, if you *wanted* the book title to be prepended with series info, you could do that as well. As you by now have undoubtedly noticed, there's a checkbox labeled :guilabel:`Case sensitive`, so you won't have to use flags to select behaviour here.
|
||||
|
||||
Well, that just about concludes the very short introduction to regular expressions. Hopefully I'll have shown you enough to at least get you started and to enable you to continue learning by yourself- a good starting point would be the `Python documentation for regexps <https://docs.python.org/2/library/re.html>`_.
|
||||
Well, that just about concludes the very short introduction to regular expressions. Hopefully I'll have shown you enough to at least get you started and to enable you to continue learning by yourself- a good starting point would be the `Python documentation for regexps <https://docs.python.org/library/re.html>`_.
|
||||
|
||||
One last word of warning, though: Regexps are powerful, but also really easy to get wrong. calibre provides really great testing possibilities to see if your expressions behave as you expect them to. Use them. Try not to shoot yourself in the foot. (God, I love that expression...) But should you, despite the warning, injure your foot (or any other body parts), try to learn from it.
|
||||
|
||||
@ -144,7 +144,7 @@ Thanks for helping with tips, corrections and such:
|
||||
* Starson17
|
||||
* Orpheu
|
||||
|
||||
For more about regexps see `The Python User Manual <https://docs.python.org/3/library/re.html>`_.
|
||||
For more about regexps see `The Python User Manual <https://docs.python.org/library/re.html>`_.
|
||||
The actual regular expression library used by calibre is:
|
||||
`regex <https://bitbucket.org/mrabarnett/mrab-regex/src/hg/>`_ which supports
|
||||
several useful enhancements over the python standard library one.
|
||||
|
@ -84,7 +84,7 @@ If you want only the first two letters of the data, use::
|
||||
|
||||
{author_sort:.2} - Only the first two letter of the author sort name
|
||||
|
||||
The calibre template language comes from Python and for more details on the syntax of these advanced formatting operations, look at the `Python documentation <https://docs.python.org/2/library/string.html#format-string-syntax>`_.
|
||||
The calibre template language comes from Python and for more details on the syntax of these advanced formatting operations, look at the `Python documentation <https://docs.python.org/library/string.html#format-string-syntax>`_.
|
||||
|
||||
Advanced features
|
||||
------------------
|
||||
|
@ -107,5 +107,4 @@ XPath built-in functions
|
||||
``re:test(src, pattern, flags)`` returns `true` if the string `src` matches the
|
||||
regular expression `pattern`. A particularly useful flag is ``i``, it makes matching
|
||||
case insensitive. A good primer on the syntax for regular expressions can be found
|
||||
at `regexp syntax <https://docs.python.org/2.7/library/re.html>`_
|
||||
|
||||
at `regexp syntax <https://docs.python.org/library/re.html>`_
|
||||
|
@ -303,7 +303,7 @@ class XMLConfig(dict):
|
||||
Similar to :class:`DynamicConfig`, except that it uses an XML storage
|
||||
backend instead of a pickle file.
|
||||
|
||||
See `https://docs.python.org/dev/library/plistlib.html`_ for the supported
|
||||
See `https://docs.python.org/library/plistlib.html`_ for the supported
|
||||
data types.
|
||||
'''
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user