diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-03-05 23:28:32 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-03-05 23:28:32 +0000 |
| commit | 9d0a53389e9df5f921ec2d4134f64f85eb894664 (patch) | |
| tree | 6df81ee12a56d8f60aeed08b70887425f10c6ea5 | |
| parent | 78579d742e01ddf9896faa562e5984a2341f36d4 (diff) | |
| download | docutils-9d0a53389e9df5f921ec2d4134f64f85eb894664.tar.gz | |
Avoid too long lines.
flake8 rule E501: line too long (N > 79 characters)
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9030 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
91 files changed, 459 insertions, 438 deletions
diff --git a/docutils/docutils/core.py b/docutils/docutils/core.py index 26debd030..1a7d20c84 100644 --- a/docutils/docutils/core.py +++ b/docutils/docutils/core.py @@ -9,7 +9,8 @@ behavior. For custom behavior (setting component options), create custom component objects first, and pass *them* to ``publish_*``/`Publisher`. See `The Docutils Publisher`_. -.. _The Docutils Publisher: https://docutils.sourceforge.io/docs/api/publisher.html +.. _The Docutils Publisher: + https://docutils.sourceforge.io/docs/api/publisher.html """ __docformat__ = 'reStructuredText' @@ -313,10 +314,11 @@ command line used.""" % (__version__, default_usage = '%prog [options] [<source> [<destination>]]' -default_description = ('Reads from <source> (default is stdin) and writes to ' - '<destination> (default is stdout). See ' - '<https://docutils.sourceforge.io/docs/user/config.html> for ' - 'the full reference.') +default_description = ( + 'Reads from <source> (default is stdin) and writes to <destination> ' + '(default is stdout). ' + 'See https://docutils.sourceforge.io/docs/user/config.html ' + ' for the full reference.') def publish_cmdline(reader=None, reader_name='standalone', diff --git a/docutils/docutils/frontend.py b/docutils/docutils/frontend.py index b0a6be93d..a80c1c581 100644 --- a/docutils/docutils/frontend.py +++ b/docutils/docutils/frontend.py @@ -511,7 +511,8 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec): 'default': 5, 'metavar': '<level>', 'validator': validate_threshold}), ('Enable debug-level system messages and diagnostics.', - ['--debug'], {'action': 'store_true', 'validator': validate_boolean}), + ['--debug'], {'action': 'store_true', + 'validator': validate_boolean}), ('Disable debug output. (default)', ['--no-debug'], {'action': 'store_false', 'dest': 'debug'}), ('Send the output of system messages to <file>.', @@ -587,7 +588,7 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec): '_source': None, '_destination': None, '_config_files': None} - """Defaults for settings that don't have command-line option equivalents.""" + """Defaults for settings without command-line option equivalents.""" relative_path_settings = ('warning_stream',) @@ -633,8 +634,9 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec): self.defaults.update(config_settings.__dict__) def populate_from_components(self, components): - """ - For each component, first populate from the `SettingsSpec.settings_spec` + """Collect settings specification from components. + + For each component, populate from the `SettingsSpec.settings_spec` structure, then from the `SettingsSpec.settings_defaults` dictionary. After all components have been processed, check for and populate from each component's `SettingsSpec.settings_default_overrides` dictionary. @@ -771,12 +773,12 @@ class ConfigParser(configparser.RawConfigParser): `handle_old_config`, to convert settings from the old [options] section. """ - old_warning = """ -The "[option]" section is deprecated. Support for old-format configuration -files will be removed in Docutils 0.21 or later. Please revise your -configuration files. See <https://docutils.sourceforge.io/docs/user/config.html>, -section "Old-Format Configuration Files". -""" + old_warning = ( + 'The "[option]" section is deprecated.\n' + 'Support for old-format configuration files will be removed in ' + 'Docutils 0.21 or later. Please revise your configuration files. ' + 'See <https://docutils.sourceforge.io/docs/user/config.html>, ' + 'section "Old-Format Configuration Files".') not_utf8_error = """\ Unable to read configuration file "%s": content not encoded as UTF-8. diff --git a/docutils/docutils/languages/__init__.py b/docutils/docutils/languages/__init__.py index 41c019d8c..2c7ca2d37 100644 --- a/docutils/docutils/languages/__init__.py +++ b/docutils/docutils/languages/__init__.py @@ -74,7 +74,8 @@ class LanguageImporter: if self.fallback: module = self.import_from_packages(self.fallback) if reporter and (language_code != 'en'): - reporter.info('Using %s for language "%s".'%(module, language_code)) + reporter.info('Using %s for language "%s".' + % (module, language_code)) self.cache[language_code] = module return module diff --git a/docutils/docutils/languages/af.py b/docutils/docutils/languages/af.py index a45e29692..25a69fe9e 100644 --- a/docutils/docutils/languages/af.py +++ b/docutils/docutils/languages/af.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Afrikaans-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/ar.py b/docutils/docutils/languages/ar.py index 2d42e0673..d6aebd0b1 100644 --- a/docutils/docutils/languages/ar.py +++ b/docutils/docutils/languages/ar.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Arabic-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/ca.py b/docutils/docutils/languages/ca.py index 954e9a9db..b3e597b65 100644 --- a/docutils/docutils/languages/ca.py +++ b/docutils/docutils/languages/ca.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Catalan-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/cs.py b/docutils/docutils/languages/cs.py index f85382278..2c21b7461 100644 --- a/docutils/docutils/languages/cs.py +++ b/docutils/docutils/languages/cs.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Czech-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/da.py b/docutils/docutils/languages/da.py index 428c4eaf5..5b3c7b80c 100644 --- a/docutils/docutils/languages/da.py +++ b/docutils/docutils/languages/da.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Danish-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/de.py b/docutils/docutils/languages/de.py index 97b85bff9..7522131d7 100644 --- a/docutils/docutils/languages/de.py +++ b/docutils/docutils/languages/de.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ German language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/en.py b/docutils/docutils/languages/en.py index 31dee12b5..d35bfbb61 100644 --- a/docutils/docutils/languages/en.py +++ b/docutils/docutils/languages/en.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ English-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/eo.py b/docutils/docutils/languages/eo.py index 1508ad412..e78dfc444 100644 --- a/docutils/docutils/languages/eo.py +++ b/docutils/docutils/languages/eo.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Esperanto-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/es.py b/docutils/docutils/languages/es.py index 66e9c83f1..61775a416 100644 --- a/docutils/docutils/languages/es.py +++ b/docutils/docutils/languages/es.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Spanish-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/fa.py b/docutils/docutils/languages/fa.py index aeabdf383..f25814d22 100644 --- a/docutils/docutils/languages/fa.py +++ b/docutils/docutils/languages/fa.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Persian-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/fi.py b/docutils/docutils/languages/fi.py index e78fb9d0f..c3026659d 100644 --- a/docutils/docutils/languages/fi.py +++ b/docutils/docutils/languages/fi.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Finnish-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/fr.py b/docutils/docutils/languages/fr.py index 9058a49f7..fa182151d 100644 --- a/docutils/docutils/languages/fr.py +++ b/docutils/docutils/languages/fr.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ French-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/gl.py b/docutils/docutils/languages/gl.py index ddb9845d2..29e46f837 100644 --- a/docutils/docutils/languages/gl.py +++ b/docutils/docutils/languages/gl.py @@ -5,9 +5,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Galician-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/he.py b/docutils/docutils/languages/he.py index e3ed7bc3f..1c2b3b1f4 100644 --- a/docutils/docutils/languages/he.py +++ b/docutils/docutils/languages/he.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Hebrew-language mappings for language-dependent features of Docutils. @@ -24,7 +24,8 @@ labels = { 'revision': '\u05de\u05d4\u05d3\u05d5\u05e8\u05d4', 'status': '\u05e1\u05d8\u05d8\u05d5\u05e1', 'date': '\u05ea\u05d0\u05e8\u05d9\u05da', - 'copyright': '\u05d6\u05db\u05d5\u05d9\u05d5\u05ea \u05e9\u05de\u05d5\u05e8\u05d5\u05ea', + 'copyright': ('\u05d6\u05db\u05d5\u05d9\u05d5\u05ea ' + '\u05e9\u05de\u05d5\u05e8\u05d5\u05ea'), 'dedication': '\u05d4\u05e7\u05d3\u05e9\u05d4', 'abstract': '\u05ea\u05e7\u05e6\u05d9\u05e8', 'attention': '\u05ea\u05e9\u05d5\u05de\u05ea \u05dc\u05d1', @@ -50,7 +51,7 @@ bibliographic_fields = { '\u05de\u05d4\u05d3\u05d5\u05e8\u05d4': 'revision', '\u05e1\u05d8\u05d8\u05d5\u05e1': 'status', '\u05ea\u05d0\u05e8\u05d9\u05da': 'date', - '\u05d6\u05db\u05d5\u05d9\u05d5\u05ea \u05e9\u05de\u05d5\u05e8\u05d5\u05ea': 'copyright', + '\u05d6\u05db\u05d5\u05d9\u05d5\u05ea \u05e9\u05de\u05d5\u05e8\u05d5\u05ea': 'copyright', # noqa:E501 '\u05d4\u05e7\u05d3\u05e9\u05d4': 'dedication', '\u05ea\u05e7\u05e6\u05d9\u05e8': 'abstract'} """Hebrew to canonical name mapping for bibliographic fields.""" diff --git a/docutils/docutils/languages/it.py b/docutils/docutils/languages/it.py index d17e9a678..c887f9f6e 100644 --- a/docutils/docutils/languages/it.py +++ b/docutils/docutils/languages/it.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Italian-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/ja.py b/docutils/docutils/languages/ja.py index 03bff1b04..a78e34b16 100644 --- a/docutils/docutils/languages/ja.py +++ b/docutils/docutils/languages/ja.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Japanese-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/ko.py b/docutils/docutils/languages/ko.py index a7846754f..4764b865f 100644 --- a/docutils/docutils/languages/ko.py +++ b/docutils/docutils/languages/ko.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Korean-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/lt.py b/docutils/docutils/languages/lt.py index fa4afb829..679783794 100644 --- a/docutils/docutils/languages/lt.py +++ b/docutils/docutils/languages/lt.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Lithuanian language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/lv.py b/docutils/docutils/languages/lv.py index 8b544784f..71da60c5b 100644 --- a/docutils/docutils/languages/lv.py +++ b/docutils/docutils/languages/lv.py @@ -2,9 +2,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Latvian-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/nl.py b/docutils/docutils/languages/nl.py index 204512992..3c03dd420 100644 --- a/docutils/docutils/languages/nl.py +++ b/docutils/docutils/languages/nl.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Dutch-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/pl.py b/docutils/docutils/languages/pl.py index a268041f0..507783b0f 100644 --- a/docutils/docutils/languages/pl.py +++ b/docutils/docutils/languages/pl.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Polish-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/pt_br.py b/docutils/docutils/languages/pt_br.py index 1a77aaf09..e450b5d14 100644 --- a/docutils/docutils/languages/pt_br.py +++ b/docutils/docutils/languages/pt_br.py @@ -3,12 +3,12 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ -Brazilian Portuguese-language mappings for language-dependent features of Docutils. +Brazilian Portuguese-language mappings for language-dependent features. """ __docformat__ = 'reStructuredText' @@ -53,7 +53,7 @@ bibliographic_fields = { 'copyright': 'copyright', 'dedicat\u00F3ria': 'dedication', 'resumo': 'abstract'} -"""Brazilian Portuguese (lowcased) to canonical name mapping for bibliographic fields.""" +"""Brazilian Portuguese (lowcased) name mapping for bibliographic fields.""" author_separators = [';', ','] """List of separator strings for the 'Authors' bibliographic field. Tried in diff --git a/docutils/docutils/languages/ru.py b/docutils/docutils/languages/ru.py index 87bada45d..f4176455a 100644 --- a/docutils/docutils/languages/ru.py +++ b/docutils/docutils/languages/ru.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Russian-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/sk.py b/docutils/docutils/languages/sk.py index 21b260f1f..5518d9e3e 100644 --- a/docutils/docutils/languages/sk.py +++ b/docutils/docutils/languages/sk.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Slovak-language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/sv.py b/docutils/docutils/languages/sv.py index e15c07e5c..bd8f95475 100644 --- a/docutils/docutils/languages/sv.py +++ b/docutils/docutils/languages/sv.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Swedish language mappings for language-dependent features of Docutils. diff --git a/docutils/docutils/languages/zh_cn.py b/docutils/docutils/languages/zh_cn.py index 82c54397a..18549f418 100644 --- a/docutils/docutils/languages/zh_cn.py +++ b/docutils/docutils/languages/zh_cn.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Simplified Chinese language mappings for language-dependent features diff --git a/docutils/docutils/languages/zh_tw.py b/docutils/docutils/languages/zh_tw.py index 6428dc7f2..a5f688602 100644 --- a/docutils/docutils/languages/zh_tw.py +++ b/docutils/docutils/languages/zh_tw.py @@ -3,12 +3,12 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ -Traditional Chinese language mappings for language-dependent features of Docutils. +Traditional Chinese language mappings for language-dependent features. """ __docformat__ = 'reStructuredText' diff --git a/docutils/docutils/nodes.py b/docutils/docutils/nodes.py index d9f0ebaa8..649f051b4 100644 --- a/docutils/docutils/nodes.py +++ b/docutils/docutils/nodes.py @@ -53,8 +53,7 @@ class Node: @property def document(self): - """ - Return the `document` node at the root of the tree containing this Node. + """Return the `document` root node of the tree containing this Node. """ try: return self._document or self.parent.document diff --git a/docutils/docutils/parsers/rst/__init__.py b/docutils/docutils/parsers/rst/__init__.py index 783175223..6962b4e63 100644 --- a/docutils/docutils/parsers/rst/__init__.py +++ b/docutils/docutils/parsers/rst/__init__.py @@ -101,7 +101,8 @@ class Parser(docutils.parsers.Parser): ('Recognize and link to standalone RFC references (like "RFC 822").', ['--rfc-references'], {'action': 'store_true', 'validator': frontend.validate_boolean}), - ('Base URL for RFC references (default "https://tools.ietf.org/html/").', + ('Base URL for RFC references ' + '(default "https://tools.ietf.org/html/").', ['--rfc-base-url'], {'metavar': '<URL>', 'default': 'https://tools.ietf.org/html/', 'validator': frontend.validate_url_trailing_slash}), @@ -264,15 +265,16 @@ class Directive: - ``lineno`` is the absolute line number of the first line of the directive. - - ``content_offset`` is the line offset of the first line of the content from - the beginning of the current input. Used when initiating a nested parse. + - ``content_offset`` is the line offset of the first line + of the content from the beginning of the current input. + Used when initiating a nested parse. - ``block_text`` is a string containing the entire directive. - ``state`` is the state which called the directive function. - - ``state_machine`` is the state machine which controls the state which called - the directive function. + - ``state_machine`` is the state machine which controls the state + which called the directive function. - ``reporter`` is the state machine's `reporter` instance. diff --git a/docutils/docutils/parsers/rst/directives/body.py b/docutils/docutils/parsers/rst/directives/body.py index f30320bfa..9c2e52183 100644 --- a/docutils/docutils/parsers/rst/directives/body.py +++ b/docutils/docutils/parsers/rst/directives/body.py @@ -38,7 +38,8 @@ class BasePseudoSection(Directive): self.assert_has_content() if self.arguments: # title (in sidebars optional) title_text = self.arguments[0] - textnodes, messages = self.state.inline_text(title_text, self.lineno) + textnodes, messages = self.state.inline_text( + title_text, self.lineno) titles = [nodes.title(title_text, '', *textnodes)] # Sidebar uses this code. if 'subtitle' in self.options: diff --git a/docutils/docutils/parsers/rst/directives/misc.py b/docutils/docutils/parsers/rst/directives/misc.py index cf3bb5123..867005624 100644 --- a/docutils/docutils/parsers/rst/directives/misc.py +++ b/docutils/docutils/parsers/rst/directives/misc.py @@ -323,8 +323,8 @@ class Replace(Directive): else: return [ self.reporter.error( - 'Error in "%s" directive: may contain a single paragraph ' - 'only.' % self.name, line=self.lineno)] + f'Error in "{self.name}" directive: may contain ' + 'a single paragraph only.', line=self.lineno)] if node: return messages + node.children return messages @@ -631,24 +631,3 @@ class TestDirective(Directive): 'content: None' % (self.name, self.arguments, self.options), line=self.lineno) return [info] - -# Old-style, functional definition: -# -# def directive_test_function(name, arguments, options, content, lineno, -# content_offset, block_text, state, state_machine): -# """This directive is useful only for testing purposes.""" -# if content: -# text = '\n'.join(content) -# info = reporter.info( -# 'Directive processed. Type="%s", arguments=%r, options=%r, ' -# 'content:' % (name, arguments, options), -# nodes.literal_block(text, text), line=lineno) -# else: -# info = reporter.info( -# 'Directive processed. Type="%s", arguments=%r, options=%r, ' -# 'content: None' % (name, arguments, options), line=lineno) -# return [info] -# -# directive_test_function.arguments = (0, 1, 1) -# directive_test_function.options = {'option': directives.unchanged_required} -# directive_test_function.content = 1 diff --git a/docutils/docutils/parsers/rst/directives/tables.py b/docutils/docutils/parsers/rst/directives/tables.py index 7fb36b82d..216d92f34 100644 --- a/docutils/docutils/parsers/rst/directives/tables.py +++ b/docutils/docutils/parsers/rst/directives/tables.py @@ -72,23 +72,26 @@ class Table(Directive): line=self.lineno) raise SystemMessagePropagation(error) if len(rows) == header_rows > 0: - error = self.reporter.error('Insufficient data supplied (%s row(s)); ' - 'no data remaining for table body, required by "%s" directive.' - % (len(rows), self.name), + error = self.reporter.error( + f'Insufficient data supplied ({len(rows)} row(s)); ' + 'no data remaining for table body, ' + f'required by "{self.name}" directive.', nodes.literal_block(self.block_text, self.block_text), line=self.lineno) raise SystemMessagePropagation(error) for row in rows: if len(row) < stub_columns: - error = self.reporter.error('%s stub column(s) specified but ' - 'only %s columns(s) of data supplied ("%s" directive).' - % (stub_columns, len(row), self.name), + error = self.reporter.error( + f'{stub_columns} stub column(s) specified ' + f'but only {len(row)} columns(s) of data supplied ' + f'("{self.name}" directive).', nodes.literal_block(self.block_text, self.block_text), line=self.lineno) raise SystemMessagePropagation(error) if len(row) == stub_columns > 0: - error = self.reporter.error('Insufficient data supplied ' - '(%s columns(s)); no data remaining for table body, required ' + error = self.reporter.error( + 'Insufficient data supplied (%s columns(s)); ' + 'no data remaining for table body, required ' 'by "%s" directive.' % (len(row), self.name), nodes.literal_block(self.block_text, self.block_text), line=self.lineno) @@ -287,7 +290,7 @@ class CSVTable(Table): """ encoding = self.options.get( 'encoding', self.state.document.settings.input_encoding) - error_handler = self.state.document.settings.input_encoding_error_handler + error_handler = self.state.document.settings.input_encoding_error_handler # noqa:E501 if self.content: # CSV data is from directive content. if 'file' in self.options or 'url' in self.options: @@ -475,7 +478,8 @@ class ListTable(Table): col_widths = self.get_column_widths(num_cols) return num_cols, col_widths - def build_table_from_list(self, table_data, col_widths, header_rows, stub_columns): + def build_table_from_list(self, table_data, + col_widths, header_rows, stub_columns): table = nodes.table() if self.widths == 'auto': table['classes'] += ['colwidths-auto'] diff --git a/docutils/docutils/parsers/rst/languages/af.py b/docutils/docutils/parsers/rst/languages/af.py index dd7381f9f..973f899aa 100644 --- a/docutils/docutils/parsers/rst/languages/af.py +++ b/docutils/docutils/parsers/rst/languages/af.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Afrikaans-language mappings for language-dependent features of @@ -103,5 +103,5 @@ roles = { 'url': 'uri-reference', 'rou': 'raw', } -"""Mapping of Afrikaans role names to canonical role names for interpreted text. +"""Mapping of Afrikaans role names to canonical names for interpreted text. """ diff --git a/docutils/docutils/parsers/rst/languages/ar.py b/docutils/docutils/parsers/rst/languages/ar.py index 3f9009521..71be92a5e 100644 --- a/docutils/docutils/parsers/rst/languages/ar.py +++ b/docutils/docutils/parsers/rst/languages/ar.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Arabic-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/ca.py b/docutils/docutils/parsers/rst/languages/ca.py index 78b317adc..53907b582 100644 --- a/docutils/docutils/parsers/rst/languages/ca.py +++ b/docutils/docutils/parsers/rst/languages/ca.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Catalan-language mappings for language-dependent features of @@ -73,7 +73,7 @@ directives = { # 'citations': 'citations', 'notes-amb-destinacions': 'target-notes', 'notes-destinacions': 'target-notes', - 'directiva-de-prova-de-restructuredtext': 'restructuredtext-test-directive'} + 'directiva-de-prova-de-restructuredtext': 'restructuredtext-test-directive'} # noqa:E501 """Catalan name to registered (in directives/__init__.py) directive name mapping.""" diff --git a/docutils/docutils/parsers/rst/languages/cs.py b/docutils/docutils/parsers/rst/languages/cs.py index 131ca5bb0..6fd1708c0 100644 --- a/docutils/docutils/parsers/rst/languages/cs.py +++ b/docutils/docutils/parsers/rst/languages/cs.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Czech-language mappings for language-dependent features of @@ -18,7 +18,8 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed 'pozor': 'attention', - 'caution (translation required)': 'caution', # jak rozlisit caution a warning? + # jak rozlisit caution a warning? + 'caution (translation required)': 'caution', 'code (translation required)': 'code', 'nebezpe\u010D\u00ED': 'danger', 'chyba': 'error', diff --git a/docutils/docutils/parsers/rst/languages/da.py b/docutils/docutils/parsers/rst/languages/da.py index 61d8f95dc..c0f8e630e 100644 --- a/docutils/docutils/parsers/rst/languages/da.py +++ b/docutils/docutils/parsers/rst/languages/da.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Danish-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/de.py b/docutils/docutils/parsers/rst/languages/de.py index 18f42d6ad..28b1649cb 100644 --- a/docutils/docutils/parsers/rst/languages/de.py +++ b/docutils/docutils/parsers/rst/languages/de.py @@ -4,9 +4,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ German-language mappings for language-dependent features of @@ -38,7 +38,8 @@ directives = { 'epigraph': 'epigraph', 'highlights': 'highlights', 'pull-quote': 'pull-quote', # commonly used in German too - 'seitenansprache': 'pull-quote', # cf. http://www.typografie.info/2/wiki.php?title=Seitenansprache + 'seitenansprache': 'pull-quote', + # cf. http://www.typografie.info/2/wiki.php?title=Seitenansprache 'zusammengesetzt': 'compound', 'verbund': 'compound', 'container': 'container', diff --git a/docutils/docutils/parsers/rst/languages/en.py b/docutils/docutils/parsers/rst/languages/en.py index 15add0463..cae482e13 100644 --- a/docutils/docutils/parsers/rst/languages/en.py +++ b/docutils/docutils/parsers/rst/languages/en.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ English-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/eo.py b/docutils/docutils/parsers/rst/languages/eo.py index b22e4c5b3..a39923e3b 100644 --- a/docutils/docutils/parsers/rst/languages/eo.py +++ b/docutils/docutils/parsers/rst/languages/eo.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Esperanto-language mappings for language-dependent features of @@ -114,5 +114,5 @@ roles = { 'url': 'uri-reference', 'senanaliza': 'raw', } -"""Mapping of Esperanto role names to canonical role names for interpreted text. +"""Mapping of Esperanto role names to canonical names for interpreted text. """ diff --git a/docutils/docutils/parsers/rst/languages/es.py b/docutils/docutils/parsers/rst/languages/es.py index 9613bef16..fb58a5d5e 100644 --- a/docutils/docutils/parsers/rst/languages/es.py +++ b/docutils/docutils/parsers/rst/languages/es.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Spanish-language mappings for language-dependent features of @@ -102,7 +102,7 @@ roles = { 'enfasis': 'emphasis', '\u00e9nfasis': 'emphasis', 'destacado': 'strong', - 'literal': 'literal', # "literal" is also a word in Spanish :-) + 'literal': 'literal', # "literal" is also a word in Spanish :-) 'math (translation required)': 'math', 'referencia-con-nombre': 'named-reference', 'referencia-anonima': 'anonymous-reference', diff --git a/docutils/docutils/parsers/rst/languages/fa.py b/docutils/docutils/parsers/rst/languages/fa.py index 883fcce61..420a315ef 100644 --- a/docutils/docutils/parsers/rst/languages/fa.py +++ b/docutils/docutils/parsers/rst/languages/fa.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Persian-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/fi.py b/docutils/docutils/parsers/rst/languages/fi.py index f2f972998..2ee67d207 100644 --- a/docutils/docutils/parsers/rst/languages/fi.py +++ b/docutils/docutils/parsers/rst/languages/fi.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Finnish-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/fr.py b/docutils/docutils/parsers/rst/languages/fr.py index 6e1cef9e5..70c6b498e 100644 --- a/docutils/docutils/parsers/rst/languages/fr.py +++ b/docutils/docutils/parsers/rst/languages/fr.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ French-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/gl.py b/docutils/docutils/parsers/rst/languages/gl.py index 08b602950..2d2216550 100644 --- a/docutils/docutils/parsers/rst/languages/gl.py +++ b/docutils/docutils/parsers/rst/languages/gl.py @@ -5,9 +5,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Galician-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/he.py b/docutils/docutils/parsers/rst/languages/he.py index d7565d890..1167a3357 100644 --- a/docutils/docutils/parsers/rst/languages/he.py +++ b/docutils/docutils/parsers/rst/languages/he.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ English-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/ja.py b/docutils/docutils/parsers/rst/languages/ja.py index 96cd5a915..22476c56b 100644 --- a/docutils/docutils/parsers/rst/languages/ja.py +++ b/docutils/docutils/parsers/rst/languages/ja.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Japanese-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/ko.py b/docutils/docutils/parsers/rst/languages/ko.py index c9f335007..da0293790 100644 --- a/docutils/docutils/parsers/rst/languages/ko.py +++ b/docutils/docutils/parsers/rst/languages/ko.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Korean-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/lt.py b/docutils/docutils/parsers/rst/languages/lt.py index 7e09ce053..32e292c8f 100644 --- a/docutils/docutils/parsers/rst/languages/lt.py +++ b/docutils/docutils/parsers/rst/languages/lt.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Lithuanian-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/lv.py b/docutils/docutils/parsers/rst/languages/lv.py index 58a1ba668..52f15d6af 100644 --- a/docutils/docutils/parsers/rst/languages/lv.py +++ b/docutils/docutils/parsers/rst/languages/lv.py @@ -2,9 +2,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Latvian-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/nl.py b/docutils/docutils/parsers/rst/languages/nl.py index 651afbcae..830f59163 100644 --- a/docutils/docutils/parsers/rst/languages/nl.py +++ b/docutils/docutils/parsers/rst/languages/nl.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Dutch-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/pl.py b/docutils/docutils/parsers/rst/languages/pl.py index 96f4f7cc6..079e03420 100644 --- a/docutils/docutils/parsers/rst/languages/pl.py +++ b/docutils/docutils/parsers/rst/languages/pl.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Polish-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/pt_br.py b/docutils/docutils/parsers/rst/languages/pt_br.py index 280d26e7d..e25f3eda7 100644 --- a/docutils/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/docutils/parsers/rst/languages/pt_br.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Brazilian Portuguese-language mappings for language-dependent features of @@ -93,7 +93,7 @@ roles = { '\u00EAnfase': 'emphasis', 'forte': 'strong', 'literal': 'literal', - 'math (translation required)': 'math', # translation required? + 'math (translation required)': 'math', # translation required? 'refer\u00EAncia-por-nome': 'named-reference', 'refer\u00EAncia-an\u00F4nima': 'anonymous-reference', 'refer\u00EAncia-a-nota-de-rodap\u00E9': 'footnote-reference', diff --git a/docutils/docutils/parsers/rst/languages/ru.py b/docutils/docutils/parsers/rst/languages/ru.py index 996ad2844..0a5aba681 100644 --- a/docutils/docutils/parsers/rst/languages/ru.py +++ b/docutils/docutils/parsers/rst/languages/ru.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Russian-language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/sk.py b/docutils/docutils/parsers/rst/languages/sk.py index 653bab8cb..2eb9ea9f3 100644 --- a/docutils/docutils/parsers/rst/languages/sk.py +++ b/docutils/docutils/parsers/rst/languages/sk.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Slovak-language mappings for language-dependent features of @@ -87,7 +87,7 @@ roles = { 'anonymous-reference (translation required)': 'anonymous-reference', 'footnote-reference (translation required)': 'footnote-reference', 'citation-reference (translation required)': 'citation-reference', - 'substitution-reference (translation required)': 'substitution-reference', + 'substitution-reference (translation required)': 'substitution-reference', # noqa:E501 'target (translation required)': 'target', 'uri-reference (translation required)': 'uri-reference', 'raw (translation required)': 'raw', diff --git a/docutils/docutils/parsers/rst/languages/sv.py b/docutils/docutils/parsers/rst/languages/sv.py index acf5afbc8..10d9bd2c6 100644 --- a/docutils/docutils/parsers/rst/languages/sv.py +++ b/docutils/docutils/parsers/rst/languages/sv.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Swedish language mappings for language-dependent features of reStructuredText. @@ -29,7 +29,8 @@ directives = { 'ämne': 'topic', 'tema': 'topic', 'rad-block': 'line-block', - 'parsed-literal (translation required)': 'parsed-literal', # 'tolkad-bokstavlig'? + # 'tolkad-bokstavlig'? + 'parsed-literal (translation required)': 'parsed-literal', 'rubrik': 'rubric', 'epigraf': 'epigraph', 'höjdpunkter': 'highlights', diff --git a/docutils/docutils/parsers/rst/languages/zh_cn.py b/docutils/docutils/parsers/rst/languages/zh_cn.py index a3b70162c..f0ab48693 100644 --- a/docutils/docutils/parsers/rst/languages/zh_cn.py +++ b/docutils/docutils/parsers/rst/languages/zh_cn.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Simplified Chinese language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/languages/zh_tw.py b/docutils/docutils/parsers/rst/languages/zh_tw.py index 90259ed9f..defa97bc1 100644 --- a/docutils/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/docutils/parsers/rst/languages/zh_tw.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ Traditional Chinese language mappings for language-dependent features of diff --git a/docutils/docutils/parsers/rst/roles.py b/docutils/docutils/parsers/rst/roles.py index 7410e9422..eb931e6cf 100644 --- a/docutils/docutils/parsers/rst/roles.py +++ b/docutils/docutils/parsers/rst/roles.py @@ -307,7 +307,7 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner, ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum if section is not None: ref += "#" + section - node = nodes.reference(rawtext, 'RFC ' + str(rfcnum), refuri=ref, **options) + node = nodes.reference(rawtext, 'RFC '+str(rfcnum), refuri=ref, **options) return [node], [] @@ -415,7 +415,7 @@ def set_classes(options): # TODO: Change use in directives.py and uncomment. # warnings.warn('The auxiliary function roles.set_classes() is obsoleted' # ' by roles.normalized_role_options() and will be removed' - # ' in Docutils 0.21 or later', PendingDeprecationWarning, stacklevel=2) + # ' in Docutils 0.21 or later', DeprecationWarning, stacklevel=2) if options and 'class' in options: assert 'classes' not in options options['classes'] = options['class'] diff --git a/docutils/docutils/parsers/rst/states.py b/docutils/docutils/parsers/rst/states.py index 0805b2db7..63a1e029e 100644 --- a/docutils/docutils/parsers/rst/states.py +++ b/docutils/docutils/parsers/rst/states.py @@ -225,7 +225,7 @@ class RSTState(StateWS): self.parent = self.state_machine.node # enable the reporter to determine source and source-line if not hasattr(self.reporter, 'get_source_and_line'): - self.reporter.get_source_and_line = self.state_machine.get_source_and_line + self.reporter.get_source_and_line = self.state_machine.get_source_and_line # noqa:E501 def goto_line(self, abs_line_offset): """ @@ -1357,7 +1357,7 @@ class Body(RSTState): break # yes; keep `format` else: # shouldn't happen raise ParserError('enumerator format not matched') - text = groupdict[format][self.enum.formatinfo[format].start # noqa: E203 + text = groupdict[format][self.enum.formatinfo[format].start # noqa: E203,E501 : self.enum.formatinfo[format].end] if text == '#': sequence = '#' @@ -2032,11 +2032,13 @@ class Body(RSTState): break blockindex += 1 try: - escaped = escaped + ' ' + escape2null(block[blockindex].strip()) + escaped = escaped + ' ' + escape2null( + block[blockindex].strip()) except IndexError: raise MarkupError('malformed substitution definition.') del block[:blockindex] # strip out the substitution marker - block[0] = (block[0].strip() + ' ')[subdefmatch.end()-len(escaped)-1:-1] + start = subdefmatch.end()-len(escaped)-1 + block[0] = (block[0].strip() + ' ')[start:-1] if not block[0]: del block[0] offset += 1 @@ -2135,7 +2137,7 @@ class Body(RSTState): ) = self.state_machine.get_first_known_indented(match.end(), strip_top=0) block_text = '\n'.join(self.state_machine.input_lines[ - initial_line_offset : self.state_machine.line_offset + 1]) # noqa: E203 + initial_line_offset : self.state_machine.line_offset + 1]) # noqa: E203,E501 try: arguments, options, content, content_offset = ( self.parse_directive_block(indented, line_offset, diff --git a/docutils/docutils/transforms/__init__.py b/docutils/docutils/transforms/__init__.py index 5bded1035..5c0d4aae7 100644 --- a/docutils/docutils/transforms/__init__.py +++ b/docutils/docutils/transforms/__init__.py @@ -153,7 +153,8 @@ class Transformer(TransformSpec): unknown_reference_resolvers = [] for i in components: unknown_reference_resolvers.extend(i.unknown_reference_resolvers) - decorated_list = sorted((f.priority, f) for f in unknown_reference_resolvers) + decorated_list = sorted((f.priority, f) + for f in unknown_reference_resolvers) self.unknown_reference_resolvers.extend(f[1] for f in decorated_list) def apply_transforms(self): diff --git a/docutils/docutils/transforms/frontmatter.py b/docutils/docutils/transforms/frontmatter.py index f91c9330a..27bb6095e 100644 --- a/docutils/docutils/transforms/frontmatter.py +++ b/docutils/docutils/transforms/frontmatter.py @@ -65,7 +65,8 @@ class TitlePromoter(Transform): # already exist in node with those in section. # NOTE: Remove `and_source` to NOT copy the 'source' # attribute from section - node.update_all_atts_concatenating(section, replace=True, and_source=True) + node.update_all_atts_concatenating(section, replace=True, + and_source=True) # setup_child is called automatically for all nodes. node[:] = (section[:1] # section title @@ -106,7 +107,8 @@ class TitlePromoter(Transform): # that already exist in node with those in section. # NOTE: Remove `and_source` to NOT copy the 'source' # attribute from section. - subtitle.update_all_atts_concatenating(subsection, replace=True, and_source=True) + subtitle.update_all_atts_concatenating(subsection, replace=True, + and_source=True) # Transfer the contents of the subsection's title to the # subtitle: @@ -232,7 +234,8 @@ class DocTitle(TitlePromoter): if not self.document.hasattr('title'): if self.document.settings.title is not None: self.document['title'] = self.document.settings.title - elif len(self.document) and isinstance(self.document[0], nodes.title): + elif len(self.document) and isinstance(self.document[0], + nodes.title): self.document['title'] = self.document[0].astext() def apply(self): diff --git a/docutils/docutils/transforms/references.py b/docutils/docutils/transforms/references.py index 6e1939fa4..958ae8422 100644 --- a/docutils/docutils/transforms/references.py +++ b/docutils/docutils/transforms/references.py @@ -827,7 +827,8 @@ class TargetNotes(Transform): reflist = [refnode] if not utils.get_trim_footnote_ref_space(self.document.settings): if self.classes: - reflist.insert(0, nodes.inline(text=' ', Classes=self.classes)) + reflist.insert( + 0, nodes.inline(text=' ', Classes=self.classes)) else: reflist.insert(0, nodes.Text(' ')) ref.parent.insert(index, reflist) diff --git a/docutils/docutils/utils/__init__.py b/docutils/docutils/utils/__init__.py index bf42c0868..f389a2bed 100644 --- a/docutils/docutils/utils/__init__.py +++ b/docutils/docutils/utils/__init__.py @@ -167,7 +167,7 @@ class Reporter: attributes.setdefault('source', source) if line is not None: attributes.setdefault('line', line) - # assert source is not None, "node has line- but no source-argument" + # assert source is not None, "line- but no source-argument" if 'source' not in attributes: # 'line' is absolute line number try: diff --git a/docutils/docutils/utils/error_reporting.py b/docutils/docutils/utils/error_reporting.py index 2be49c364..5a32f0308 100644 --- a/docutils/docutils/utils/error_reporting.py +++ b/docutils/docutils/utils/error_reporting.py @@ -65,7 +65,6 @@ else: locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1] # locale.getpreferredencoding([do_setlocale=True|False]) # has side-effects | might return a wrong guess. - # (cf. Update 1 in http://stackoverflow.com/questions/4082645/using-python-2-xs-locale-module-to-format-numbers-and-currency) except ValueError as error: # OS X may set UTF-8 without language code # see http://bugs.python.org/issue18378 # and https://sourceforge.net/p/docutils/bugs/298/ diff --git a/docutils/docutils/utils/smartquotes.py b/docutils/docutils/utils/smartquotes.py index 0d8abd2cf..58a26576b 100644 --- a/docutils/docutils/utils/smartquotes.py +++ b/docutils/docutils/utils/smartquotes.py @@ -360,26 +360,27 @@ example, ``"1"`` is equivalent to ``"qBde"``. :d: Educates em-dashes. -:D: Educates em-dashes and en-dashes, using old-school typewriter shorthand: - (dash dash) for en-dashes, (dash dash dash) for em-dashes. +:D: Educates em-dashes and en-dashes, using old-school typewriter + shorthand: (dash dash) for en-dashes, (dash dash dash) for em-dashes. :i: Educates em-dashes and en-dashes, using inverted old-school typewriter shorthand: (dash dash) for em-dashes, (dash dash dash) for en-dashes. :e: Educates ellipses. -:w: Translates any instance of ``"`` into a normal double-quote character. - This should be of no interest to most people, but of particular interest - to anyone who writes their posts using Dreamweaver, as Dreamweaver - inexplicably uses this entity to represent a literal double-quote - character. SmartyPants only educates normal quotes, not entities (because - ordinarily, entities are used for the explicit purpose of representing the - specific character they represent). The "w" option must be used in - conjunction with one (or both) of the other quote options ("q" or "b"). - Thus, if you wish to apply all SmartyPants transformations (quotes, en- - and em-dashes, and ellipses) and also translate ``"`` entities into - regular quotes so SmartyPants can educate them, you should pass the - following to the smarty_pants attribute: +:w: Translates any instance of ``"`` into a normal double-quote + character. This should be of no interest to most people, but + of particular interest to anyone who writes their posts using + Dreamweaver, as Dreamweaver inexplicably uses this entity to represent + a literal double-quote character. SmartyPants only educates normal + quotes, not entities (because ordinarily, entities are used for + the explicit purpose of representing the specific character they + represent). The "w" option must be used in conjunction with one (or + both) of the other quote options ("q" or "b"). Thus, if you wish to + apply all SmartyPants transformations (quotes, en- and em-dashes, and + ellipses) and also translate ``"`` entities into regular quotes + so SmartyPants can educate them, you should pass the following to the + smarty_pants attribute: """ @@ -392,104 +393,105 @@ class smartchars: apostrophe = '’' # "’" RIGHT SINGLE QUOTATION MARK # quote characters (language-specific, set in __init__()) - # [1] https://en.wikipedia.org/wiki/Non-English_usage_of_quotation_marks - # [2] http://de.wikipedia.org/wiki/Anf%C3%BChrungszeichen#Andere_Sprachen - # [3] https://fr.wikipedia.org/wiki/Guillemet - # [4] http://typographisme.net/post/Les-espaces-typographiques-et-le-web - # [5] http://www.btb.termiumplus.gc.ca/tpv2guides/guides/redac/index-fra.html - # [6] https://en.wikipedia.org/wiki/Hebrew_punctuation#Quotation_marks + # https://en.wikipedia.org/wiki/Non-English_usage_of_quotation_marks + # http://de.wikipedia.org/wiki/Anf%C3%BChrungszeichen#Andere_Sprachen + # https://fr.wikipedia.org/wiki/Guillemet + # http://typographisme.net/post/Les-espaces-typographiques-et-le-web + # http://www.btb.termiumplus.gc.ca/tpv2guides/guides/redac/index-fra.html + # https://en.wikipedia.org/wiki/Hebrew_punctuation#Quotation_marks # [7] http://www.tustep.uni-tuebingen.de/bi/bi00/bi001t1-anfuehrung.pdf # [8] http://www.korrekturavdelingen.no/anforselstegn.htm # [9] Typografisk håndbok. Oslo: Spartacus. 2000. s. 67. ISBN 8243001530. # [10] http://www.typografi.org/sitat/sitatart.html # # See also configuration option "smartquote-locales". - quotes = {'af': '“”‘’', - 'af-x-altquot': '„”‚’', - 'bg': '„“‚‘', # https://bg.wikipedia.org/wiki/Кавички - 'ca': '«»“”', - 'ca-x-altquot': '“”‘’', - 'cs': '„“‚‘', - 'cs-x-altquot': '»«›‹', - 'da': '»«›‹', - 'da-x-altquot': '„“‚‘', - # 'da-x-altquot2': '””’’', - 'de': '„“‚‘', - 'de-x-altquot': '»«›‹', - 'de-ch': '«»‹›', - 'el': '«»“”', - 'en': '“”‘’', - 'en-uk-x-altquot': '‘’“”', # Attention: " → ‘ and ' → “ ! - 'eo': '“”‘’', - 'es': '«»“”', - 'es-x-altquot': '“”‘’', - 'et': '„“‚‘', # no secondary quote listed in - 'et-x-altquot': '«»‹›', # the sources above (wikipedia.org) - 'eu': '«»‹›', - 'fi': '””’’', - 'fi-x-altquot': '»»››', - 'fr': ('« ', ' »', '“', '”'), # full no-break space - 'fr-x-altquot': ('« ', ' »', '“', '”'), # narrow no-break space - 'fr-ch': '«»‹›', # http://typoguide.ch/ - 'fr-ch-x-altquot': ('« ', ' »', '‹ ', ' ›'), # narrow no-break space - 'gl': '«»“”', - 'he': '”“»«', # Hebrew is RTL, test position: - 'he-x-altquot': '„”‚’', # low quotation marks are opening. - # 'he-x-altquot': '“„‘‚', # RTL: low quotation marks opening - 'hr': '„”‘’', # http://hrvatska-tipografija.com/polunavodnici/ - 'hr-x-altquot': '»«›‹', - 'hsb': '„“‚‘', - 'hsb-x-altquot': '»«›‹', - 'hu': '„”«»', - 'is': '„“‚‘', - 'it': '«»“”', - 'it-ch': '«»‹›', - 'it-x-altquot': '“”‘’', - # 'it-x-altquot2': '“„‘‚', # [7] in headlines - 'ja': '「」『』', - 'ko': '“”‘’', - 'lt': '„“‚‘', - 'lv': '„“‚‘', - 'mk': '„“‚‘', # Macedonian, https://mk.wikipedia.org/wiki/Правопис_и_правоговор_на_македонскиот_јазик - 'nl': '“”‘’', - 'nl-x-altquot': '„”‚’', - # 'nl-x-altquot2': '””’’', - 'nb': '«»’’', # Norsk bokmål (canonical form 'no') - 'nn': '«»’’', # Nynorsk [10] - 'nn-x-altquot': '«»‘’', # [8], [10] - # 'nn-x-altquot2': '«»«»', # [9], [10 - # 'nn-x-altquot3': '„“‚‘', # [10] - 'no': '«»’’', # Norsk bokmål [10] - 'no-x-altquot': '«»‘’', # [8], [10] - # 'no-x-altquot2': '«»«»', # [9], [10 - # 'no-x-altquot3': '„“‚‘', # [10] - 'pl': '„”«»', - 'pl-x-altquot': '«»‚’', - # 'pl-x-altquot2': '„”‚’', # https://pl.wikipedia.org/wiki/Cudzys%C5%82%C3%B3w - 'pt': '«»“”', - 'pt-br': '“”‘’', - 'ro': '„”«»', - 'ru': '«»„“', - 'sh': '„”‚’', # Serbo-Croatian - 'sh-x-altquot': '»«›‹', - 'sk': '„“‚‘', # Slovak - 'sk-x-altquot': '»«›‹', - 'sl': '„“‚‘', # Slovenian - 'sl-x-altquot': '»«›‹', - 'sq': '«»‹›', # Albanian - 'sq-x-altquot': '“„‘‚', - 'sr': '„”’’', - 'sr-x-altquot': '»«›‹', - 'sv': '””’’', - 'sv-x-altquot': '»»››', - 'tr': '“”‘’', - 'tr-x-altquot': '«»‹›', - # 'tr-x-altquot2': '“„‘‚', # [7] antiquated? - 'uk': '«»„“', - 'uk-x-altquot': '„“‚‘', - 'zh-cn': '“”‘’', - 'zh-tw': '「」『』', - } + quotes = { + 'af': '“”‘’', + 'af-x-altquot': '„”‚’', + 'bg': '„“‚‘', # https://bg.wikipedia.org/wiki/Кавички + 'ca': '«»“”', + 'ca-x-altquot': '“”‘’', + 'cs': '„“‚‘', + 'cs-x-altquot': '»«›‹', + 'da': '»«›‹', + 'da-x-altquot': '„“‚‘', + # 'da-x-altquot2': '””’’', + 'de': '„“‚‘', + 'de-x-altquot': '»«›‹', + 'de-ch': '«»‹›', + 'el': '«»“”', + 'en': '“”‘’', + 'en-uk-x-altquot': '‘’“”', # Attention: " → ‘ and ' → “ ! + 'eo': '“”‘’', + 'es': '«»“”', + 'es-x-altquot': '“”‘’', + 'et': '„“‚‘', # no secondary quote listed in + 'et-x-altquot': '«»‹›', # the sources above (wikipedia.org) + 'eu': '«»‹›', + 'fi': '””’’', + 'fi-x-altquot': '»»››', + 'fr': ('« ', ' »', '“', '”'), # full no-break space + 'fr-x-altquot': ('« ', ' »', '“', '”'), # narrow no-break space + 'fr-ch': '«»‹›', # http://typoguide.ch/ + 'fr-ch-x-altquot': ('« ', ' »', '‹ ', ' ›'), # narrow no-break space # noqa:E501 + 'gl': '«»“”', + 'he': '”“»«', # Hebrew is RTL, test position: + 'he-x-altquot': '„”‚’', # low quotation marks are opening. + # 'he-x-altquot': '“„‘‚', # RTL: low quotation marks opening + 'hr': '„”‘’', # http://hrvatska-tipografija.com/polunavodnici/ # noqa:E501 + 'hr-x-altquot': '»«›‹', + 'hsb': '„“‚‘', + 'hsb-x-altquot': '»«›‹', + 'hu': '„”«»', + 'is': '„“‚‘', + 'it': '«»“”', + 'it-ch': '«»‹›', + 'it-x-altquot': '“”‘’', + # 'it-x-altquot2': '“„‘‚', # [7] in headlines + 'ja': '「」『』', + 'ko': '“”‘’', + 'lt': '„“‚‘', + 'lv': '„“‚‘', + 'mk': '„“‚‘', # Macedonian, https://mk.wikipedia.org/wiki/Правопис_и_правоговор_на_македонскиот_јазик # noqa:E501 + 'nl': '“”‘’', + 'nl-x-altquot': '„”‚’', + # 'nl-x-altquot2': '””’’', + 'nb': '«»’’', # Norsk bokmål (canonical form 'no') + 'nn': '«»’’', # Nynorsk [10] + 'nn-x-altquot': '«»‘’', # [8], [10] + # 'nn-x-altquot2': '«»«»', # [9], [10] + # 'nn-x-altquot3': '„“‚‘', # [10] + 'no': '«»’’', # Norsk bokmål [10] + 'no-x-altquot': '«»‘’', # [8], [10] + # 'no-x-altquot2': '«»«»', # [9], [10 + # 'no-x-altquot3': '„“‚‘', # [10] + 'pl': '„”«»', + 'pl-x-altquot': '«»‚’', + # 'pl-x-altquot2': '„”‚’', # https://pl.wikipedia.org/wiki/Cudzys%C5%82%C3%B3w # noqa:E501 + 'pt': '«»“”', + 'pt-br': '“”‘’', + 'ro': '„”«»', + 'ru': '«»„“', + 'sh': '„”‚’', # Serbo-Croatian + 'sh-x-altquot': '»«›‹', + 'sk': '„“‚‘', # Slovak + 'sk-x-altquot': '»«›‹', + 'sl': '„“‚‘', # Slovenian + 'sl-x-altquot': '»«›‹', + 'sq': '«»‹›', # Albanian + 'sq-x-altquot': '“„‘‚', + 'sr': '„”’’', + 'sr-x-altquot': '»«›‹', + 'sv': '””’’', + 'sv-x-altquot': '»»››', + 'tr': '“”‘’', + 'tr-x-altquot': '«»‹›', + # 'tr-x-altquot2': '“„‘‚', # [7] antiquated? + 'uk': '«»„“', + 'uk-x-altquot': '„“‚‘', + 'zh-cn': '“”‘’', + 'zh-tw': '「」『』', + } def __init__(self, language='en'): self.language = language @@ -696,8 +698,8 @@ def educateQuotes(text, language='en'): %(open)s | # zero width separating char, or %(dash)s # em/en-dash ) - " # the quote - (?=\\w|%(punct)s) # followed by a word character or punctuation + " # the quote, followed by + (?=\\w|%(punct)s) # a word character or punctuation """ % ch_classes, re.VERBOSE) text = opening_primary_quotes_regex.sub(r'\1'+smart.opquote, text) @@ -968,7 +970,8 @@ if __name__ == "__main__": self.assertEqual(smartyPants("'60s"), "’60s") def test_educated_quotes(self): - self.assertEqual(smartyPants('"Isn\'t this fun?"'), '“Isn’t this fun?”') + self.assertEqual(smartyPants('"Isn\'t this fun?"'), + '“Isn’t this fun?”') def test_html_tags(self): text = '<a src="foo">more</a>' diff --git a/docutils/docutils/utils/urischemes.py b/docutils/docutils/utils/urischemes.py index 339d7de20..0020148f8 100644 --- a/docutils/docutils/utils/urischemes.py +++ b/docutils/docutils/utils/urischemes.py @@ -50,7 +50,8 @@ schemes = { 'hnews': 'an HTTP-tunneling variant of the NNTP news protocol', 'http': 'Hypertext Transfer Protocol; RFC 2616', 'https': 'HTTP over SSL; RFC 2818', - 'hydra': 'SubEthaEdit URI. See http://www.codingmonkeys.de/subethaedit.', + 'hydra': ('SubEthaEdit URI. ' + 'See http://www.codingmonkeys.de/subethaedit.'), 'iioploc': 'Internet Inter-ORB Protocol Location?', 'ilu': 'Inter-Language Unification', 'im': 'Instant Messaging; RFC 3860', @@ -62,8 +63,8 @@ schemes = { 'iris.beep': 'iris.beep; RFC 3983', 'iseek': 'See www.ambrosiasw.com; a little util for OS X.', 'jar': 'Java archive', - 'javascript': ('JavaScript code; evaluates the expression after the ' - 'colon'), + 'javascript': ('JavaScript code; ' + 'evaluates the expression after the colon'), 'jdbc': 'JDBC connection URI.', 'ldap': 'Lightweight Directory Access Protocol', 'lifn': '', diff --git a/docutils/docutils/writers/_html_base.py b/docutils/docutils/writers/_html_base.py index 90ec310f6..31dfceea7 100644 --- a/docutils/docutils/writers/_html_base.py +++ b/docutils/docutils/writers/_html_base.py @@ -701,7 +701,8 @@ class HTMLTranslator(nodes.NodeVisitor): self.body.append('</div>\n') def visit_container(self, node): - self.body.append(self.starttag(node, 'div', CLASS='docutils container')) + self.body.append(self.starttag(node, 'div', + CLASS='docutils container')) def depart_container(self, node): self.body.append('</div>\n') diff --git a/docutils/docutils/writers/docutils_xml.py b/docutils/docutils/writers/docutils_xml.py index 37955de52..7aaded478 100644 --- a/docutils/docutils/writers/docutils_xml.py +++ b/docutils/docutils/writers/docutils_xml.py @@ -113,7 +113,7 @@ class XMLTranslator(nodes.GenericNodeVisitor): # -------------------------------- simple_nodes = (nodes.TextElement, - nodes.image, nodes.colspec, nodes.transition) # empty elements + nodes.image, nodes.colspec, nodes.transition) def default_visit(self, node): """Default node visit method.""" diff --git a/docutils/docutils/writers/html4css1/__init__.py b/docutils/docutils/writers/html4css1/__init__.py index 620c3c0bc..1ea84bb33 100644 --- a/docutils/docutils/writers/html4css1/__init__.py +++ b/docutils/docutils/writers/html4css1/__init__.py @@ -57,8 +57,8 @@ class Writer(writers._html_base.Writer): 'default': default_stylesheets}), stylesheet_dirs=( 'Comma-separated list of directories where stylesheets are found. ' - 'Used by --stylesheet-path when expanding relative path arguments. ' - '(default: "%s")' % ','.join(default_stylesheet_dirs), + 'Used by --stylesheet-path when expanding relative path ' + 'arguments. (default: "%s")' % ','.join(default_stylesheet_dirs), ['--stylesheet-dirs'], {'metavar': '<dir[,dir,...]>', 'validator': frontend.validate_comma_separated_list, @@ -618,7 +618,7 @@ class HTMLTranslator(writers._html_base.HTMLTranslator): CLASS='label')) def depart_label(self, node): - self.body.append(']%s</td><td>%s' % (self.context.pop(), self.context.pop())) + self.body.append(f']{self.context.pop()}</td><td>{self.context.pop()}') # ersatz for first/last pseudo-classes def visit_list_item(self, node): diff --git a/docutils/docutils/writers/html5_polyglot/__init__.py b/docutils/docutils/writers/html5_polyglot/__init__.py index ffbb06f1d..8602cdf6b 100644 --- a/docutils/docutils/writers/html5_polyglot/__init__.py +++ b/docutils/docutils/writers/html5_polyglot/__init__.py @@ -65,8 +65,8 @@ class Writer(writers._html_base.Writer): 'default': default_stylesheets}), stylesheet_dirs=( 'Comma-separated list of directories where stylesheets are found. ' - 'Used by --stylesheet-path when expanding relative path arguments. ' - '(default: "%s")' % ','.join(default_stylesheet_dirs), + 'Used by --stylesheet-path when expanding relative path ' + 'arguments. (default: "%s")' % ','.join(default_stylesheet_dirs), ['--stylesheet-dirs'], {'metavar': '<dir[,dir,...]>', 'validator': frontend.validate_comma_separated_list, diff --git a/docutils/docutils/writers/latex2e/__init__.py b/docutils/docutils/writers/latex2e/__init__.py index 71ac6bebe..30482f12f 100644 --- a/docutils/docutils/writers/latex2e/__init__.py +++ b/docutils/docutils/writers/latex2e/__init__.py @@ -522,7 +522,9 @@ PreambleCmds.table = r"""\usepackage{longtable,ltcaption,array} \setlength{\extrarowheight}{2pt} \newlength{\DUtablewidth} % internal use in tables""" -PreambleCmds.table_columnwidth = r"""\newcommand{\DUcolumnwidth}[1]{\dimexpr#1\DUtablewidth-2\tabcolsep\relax}""" +PreambleCmds.table_columnwidth = ( + r'\newcommand{\DUcolumnwidth}[1]' + r'{\dimexpr#1\DUtablewidth-2\tabcolsep\relax}') PreambleCmds.textcomp = r"""\usepackage{textcomp} % text symbol macros""" # TODO? Options [force,almostfull] prevent spurious error messages, @@ -936,7 +938,8 @@ class Table: # elif self.borders == 'standard': # closing.append(r'\hline') closing.append(r'\end{%s}' % self.get_latex_type()) - if self.get('align') and self.get_latex_type() not in ("longtable", "longtable*"): + if (self.get('align') + and self.get_latex_type() not in ("longtable", "longtable*")): closing.append('}') return '\n'.join(closing) @@ -994,8 +997,8 @@ class Table: """Return columnwidth for current cell (not multicell).""" try: if self.legacy_column_widths: - return '%.2f\\DUtablewidth' % self._colwidths[self._cell_in_row] - return '\\DUcolumnwidth{%.2f}' % self._colwidths[self._cell_in_row] + return '%.2f\\DUtablewidth'%self._colwidths[self._cell_in_row] + return '\\DUcolumnwidth{%.2f}'%self._colwidths[self._cell_in_row] except IndexError: return '*' @@ -1348,8 +1351,9 @@ class LaTeXTranslator(nodes.NodeVisitor): if self.hyperlink_color in ('0', 'false', 'False', ''): self.hyperref_options = '' else: - self.hyperref_options = 'colorlinks=true,linkcolor=%s,urlcolor=%s' % ( - self.hyperlink_color, self.hyperlink_color) + self.hyperref_options = ('colorlinks=true,' + f'linkcolor={self.hyperlink_color},' + f'urlcolor={self.hyperlink_color}') if settings.hyperref_options: self.hyperref_options += ',' + settings.hyperref_options @@ -1432,7 +1436,7 @@ class LaTeXTranslator(nodes.NodeVisitor): tr = {'iso-8859-1': 'latin1', # west european 'iso-8859-2': 'latin2', # east european 'iso-8859-3': 'latin3', # esperanto, maltese - 'iso-8859-4': 'latin4', # north european, scandinavian, baltic + 'iso-8859-4': 'latin4', # north european 'iso-8859-5': 'iso88595', # cyrillic (ISO) 'iso-8859-9': 'latin5', # turkish 'iso-8859-15': 'latin9', # latin9, update to latin1. @@ -1460,7 +1464,7 @@ class LaTeXTranslator(nodes.NodeVisitor): encoding = docutils_encoding.lower() if encoding in tr: return tr[encoding] - # drop hyphen or low-line from "latin-1", "latin_1", "utf-8" and similar + # drop hyphen or low-line from "latin_1", "utf-8" and similar encoding = encoding.replace('_', '').replace('-', '') # strip the error handler return encoding.split(':')[0] @@ -1507,7 +1511,7 @@ class LaTeXTranslator(nodes.NodeVisitor): # quick-and-dirty replacement with spaces # (for better results use `--literal-block-env=lstlisting`) table[ord('\t')] = '~' * self.settings.tab_width - # Unicode replacements for 8-bit tex engines (not required with XeTeX/LuaTeX): + # Unicode replacements for 8-bit tex engines (not required with XeTeX) if not self.is_xetex: if not self.latex_encoding.startswith('utf8'): table.update(CharMaps.unsupported_unicode) @@ -1712,7 +1716,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.fallbacks['admonition'] = PreambleCmds.admonition_legacy if 'error' in node['classes']: self.fallbacks['error'] = PreambleCmds.error_legacy - self.out.append('\n\\DUadmonition[%s]{' % ','.join(node['classes'])) + self.out.append('\n\\DUadmonition[%s]{'%','.join(node['classes'])) return if not self.fallback_stylesheet: self.fallbacks['admonition'] = PreambleCmds.admonition @@ -2914,7 +2918,7 @@ class LaTeXTranslator(nodes.NodeVisitor): if isinstance(node.parent, nodes.document): self.push_output_collector(self.subtitle) if not self.fallback_stylesheet: - self.fallbacks['documentsubtitle'] = PreambleCmds.documentsubtitle + self.fallbacks['documentsubtitle'] = PreambleCmds.documentsubtitle # noqa:E501 protect = (self.settings.documentclass == 'memoir') self.subtitle_labels += self.ids_to_labels(node, set_anchor=False, protect=protect) diff --git a/docutils/docutils/writers/manpage.py b/docutils/docutils/writers/manpage.py index 2ea80f228..93d0e5981 100644 --- a/docutils/docutils/writers/manpage.py +++ b/docutils/docutils/writers/manpage.py @@ -218,7 +218,7 @@ class Translator(nodes.NodeVisitor): # Hopefully ``C`` courier too. self.defs = { 'indent': ('.INDENT %.1f\n', '.UNINDENT\n'), - 'definition_list_item': ('.TP', ''), # paragraph with hanging tag + 'definition_list_item': ('.TP', ''), # par. with hanging tag 'field_name': ('.TP\n.B ', '\n'), 'literal': ('\\fB', '\\fP'), 'literal_block': ('.sp\n.nf\n.ft C\n', '\n.ft P\n.fi\n'), @@ -271,7 +271,8 @@ class Translator(nodes.NodeVisitor): and self.body[i - 2][:4] == '.TP\n'): self.body[i] = '.\n' elif (self.body[i - 1] == '\n' - and not self.possibly_a_roff_command.match(self.body[i - 2]) + and not self.possibly_a_roff_command.match( + self.body[i - 2]) and (self.body[i - 3][:7] == '.TP\n.B ' or self.body[i - 3][:4] == '\n.B ') ): @@ -625,8 +626,8 @@ class Translator(nodes.NodeVisitor): def visit_entry(self, node): # a cell in a table row if 'morerows' in node: - self.document.reporter.warning('"table row spanning" not supported', - base_node=node) + self.document.reporter.warning( + '"table row spanning" not supported', base_node=node) if 'morecols' in node: self.document.reporter.warning( '"table cell spanning" not supported', base_node=node) @@ -900,8 +901,8 @@ class Translator(nodes.NodeVisitor): # options without parameter bold only, .B, -v # options with parameter bold italic, .BI, -f file # - # we do not know if .B or .BI - self.context.append('.B ') # blind guess. Add blank for sphinx see docutils/bugs/380 + # we do not know if .B or .BI, blind guess: + self.context.append('.B ') # Add blank for sphinx (docutils/bugs/380) self.context.append(len(self.body)) # to be able to insert later self.context.append(0) # option counter @@ -1033,8 +1034,8 @@ class Translator(nodes.NodeVisitor): raise nodes.SkipNode def visit_substitution_reference(self, node): - self.document.reporter.warning('"substitution_reference" not supported', - base_node=node) + self.document.reporter.warning( + '"substitution_reference" not supported', base_node=node) def visit_subtitle(self, node): if isinstance(node.parent, nodes.sidebar): @@ -1123,7 +1124,7 @@ class Translator(nodes.NodeVisitor): self._docinfo['title_upper'] = node.astext().upper() raise nodes.SkipNode elif self.section_level == 1: - self.body.append('.SH %s\n' % self.deunicode(node.astext().upper())) + self.body.append('.SH %s\n'%self.deunicode(node.astext().upper())) raise nodes.SkipNode else: self.body.append('.SS ') diff --git a/docutils/docutils/writers/s5_html/__init__.py b/docutils/docutils/writers/s5_html/__init__.py index 1cfe79935..77670eb82 100644 --- a/docutils/docutils/writers/s5_html/__init__.py +++ b/docutils/docutils/writers/s5_html/__init__.py @@ -223,7 +223,7 @@ class S5HTMLTranslator(html4css1.HTMLTranslator): line = line.strip() if line and not line.startswith('#'): path = find_theme(line) - if path in theme_paths: # check for duplicates (cycles) + if path in theme_paths: # check for duplicates/cycles path = None # if found, use default base else: theme_paths.append(path) diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py index ef7c5b16a..163cda1bf 100644 --- a/docutils/test/DocutilsTestSupport.py +++ b/docutils/test/DocutilsTestSupport.py @@ -749,10 +749,10 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase): standard_content_type_template + standard_generator_template % docutils.__version__) standard_meta_value = standard_html_meta_value % 'utf-8' - standard_html_prolog = """\ -<?xml version="1.0" encoding="%s" ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -""" + standard_html_prolog = ( + '<?xml version="1.0" encoding="%s" ?>\n' + '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' + '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n') def format_output(self, parts): """Minimize & standardize the output.""" diff --git a/docutils/test/alltests.py b/docutils/test/alltests.py index f4c09088a..ccb022da4 100755 --- a/docutils/test/alltests.py +++ b/docutils/test/alltests.py @@ -16,13 +16,13 @@ import time # and setup outside of unittest. start = time.time() -import sys # noqa: E402 -import atexit # noqa: E402 -import os # noqa: E402 -import platform # noqa: E402 +import sys # noqa: E402 +import atexit # noqa: E402 +import os # noqa: E402 +import platform # noqa: E402 -import DocutilsTestSupport # noqa: E402 must be imported before docutils -import docutils # noqa: E402 +import DocutilsTestSupport # noqa: E402 must be imported before docutils +import docutils # noqa: E402 class Tee: diff --git a/docutils/test/local_dummy_lang.py b/docutils/test/local_dummy_lang.py index 01b5604ab..b64e37a15 100644 --- a/docutils/test/local_dummy_lang.py +++ b/docutils/test/local_dummy_lang.py @@ -3,9 +3,9 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# read <https://docutils.sourceforge.io/docs/howto/i18n.html>. +# Two files must be translated for each language: one in docutils/languages, +# the other in docutils/parsers/rst/languages. """ English-language mappings for language-dependent features of Docutils. @@ -112,7 +112,8 @@ directives = { # 'dummy-footnotes': 'footnotes', # 'dummy-citations': 'citations', 'dummy-target-notes': 'target-notes', - 'dummy-restructuredtext-test-directive': 'restructuredtext-test-directive'} + 'dummy-restructuredtext-test-directive': 'restructuredtext-test-directive', # noqa: E501 + } """English name to registered (in directives/__init__.py) directive name mapping.""" diff --git a/docutils/test/package_unittest.py b/docutils/test/package_unittest.py index 05ed53a94..66f42bb67 100644 --- a/docutils/test/package_unittest.py +++ b/docutils/test/package_unittest.py @@ -102,7 +102,8 @@ def loadTestModules(path, name='', packages=None): try: module = import_module(mod) except ImportError: - print("ERROR: Can't import %s, skipping its tests:" % mod, file=sys.stderr) + print(f"ERROR: Can't import {mod}, skipping its tests:", + file=sys.stderr) sys.excepthook(*sys.exc_info()) else: # if there's a suite defined, incorporate its contents diff --git a/docutils/test/test_dependencies.py b/docutils/test/test_dependencies.py index 635da683f..9e24c50bf 100755 --- a/docutils/test/test_dependencies.py +++ b/docutils/test/test_dependencies.py @@ -69,7 +69,8 @@ class RecordDependenciesTests(unittest.TestCase): expected = [paths[key] for key in keys] # stylesheets are tested separately in test_stylesheet_dependencies(): so = {'stylesheet_path': None, 'stylesheet': None} - record = sorted(self.get_record(writer_name='html', settings_overrides=so)) + record = sorted(self.get_record(writer_name='html', + settings_overrides=so)) # the order of the files is arbitrary expected.sort() self.assertEqual(record, expected) @@ -83,8 +84,9 @@ class RecordDependenciesTests(unittest.TestCase): if PIL: keys += ['figure-image'] expected = [paths[key] for key in keys] - record = sorted(self.get_record(writer_name='latex', - settings_overrides=latex_settings_overwrites)) + record = sorted(self.get_record( + writer_name='latex', + settings_overrides=latex_settings_overwrites)) # the order of the files is arbitrary expected.sort() self.assertEqual(record, expected) diff --git a/docutils/test/test_error_reporting.py b/docutils/test/test_error_reporting.py index 462abf00b..e0bd2d286 100644 --- a/docutils/test/test_error_reporting.py +++ b/docutils/test/test_error_reporting.py @@ -75,7 +75,10 @@ class SafeStringTests(unittest.TestCase): self.assertEqual(self.us, str(self.wue)) def test_str(self): - """Test conversion to a string (bytes in Python 2, unicode in Python 3).""" + """Test conversion to a string + + (bytes in Python 2, unicode in Python 3). + """ self.assertEqual(str(self.bs), str(self.wbs)) self.assertEqual(str(self.be), str(self.wbe)) self.assertEqual(str(self.us), str(self.wus)) @@ -151,7 +154,7 @@ class ErrorOutputTests(unittest.TestCase): # decode of binary strings e = ErrorOutput(buf, encoding='ascii') e.write(b'b\xfc') - self.assertEqual(buf.getvalue(), u'b\ufffd') # use REPLACEMENT CHARACTER + self.assertEqual(buf.getvalue(), u'b\ufffd') # REPLACEMENT CHARACTER # write Unicode string and Exceptions with Unicode args e.write(u' u\xfc') self.assertEqual(buf.getvalue(), u'b\ufffd u\xfc') @@ -214,7 +217,10 @@ class SafeStringTests_locale(unittest.TestCase): self.assertEqual(str, type(str(self.wuose))) def test_str(self): - """Test conversion to a string (bytes in Python 2, unicode in Python 3).""" + """Test conversion to a string + + (bytes in Python 2, unicode in Python 3). + """ self.assertEqual(str(self.bioe), str(self.wbioe)) self.assertEqual(str(self.uioe), str(self.wuioe)) self.assertEqual(str(self.bose), str(self.wbose)) diff --git a/docutils/test/test_nodes.py b/docutils/test/test_nodes.py index 21fae7ab9..5df034fc1 100755 --- a/docutils/test/test_nodes.py +++ b/docutils/test/test_nodes.py @@ -187,7 +187,7 @@ class ElementTests(unittest.TestCase): self.assertEqual(element1['ids'], ['foo', 'bar', 'baz', 'qux']) # 'parent_only' should remain unaffected. self.assertEqual(element1['parent_only'], 'parent') - # 'all_nodes' is overwritten due to the second parameter default of True. + # 'all_nodes' is overwritten due to the second parameter default True. self.assertEqual(element1['all_nodes'], 'dad') # 'child_only' should have been added. self.assertEqual(element1['child_only'], 'child') @@ -507,7 +507,8 @@ class MiscTests(unittest.TestCase): if expect != output: failures.append("'%s' != '%s'" % (expect, output)) if failures: - self.fail("%d failures in %d\n%s" % (len(failures), len(self.ids), "\n".join(failures))) + self.fail(f'{len(failures)} failures in {len(self.ids)} ids\n' + + "\n".join(failures)) def test_findall(self): e = nodes.Element() diff --git a/docutils/test/test_settings.py b/docutils/test/test_settings.py index e6cf24e82..bd82d2810 100755 --- a/docutils/test/test_settings.py +++ b/docutils/test/test_settings.py @@ -309,9 +309,9 @@ class HelperFunctionsTests(unittest.TestCase): (['a', 'b:c'], ['a', 'b', 'c']), ) for t in tests: - self.assertEqual( - frontend.validate_colon_separated_string_list(None, t[0], None), - t[1]) + self.assertEqual(frontend.validate_colon_separated_string_list( + None, t[0], None), + t[1]) def test_validate_comma_separated_list(self): tests = ( @@ -339,11 +339,11 @@ class HelperFunctionsTests(unittest.TestCase): def test_validate_smartquotes_locales(self): tests = ( - ('en:ssvv', [('en', 'ssvv')]), - ('sd:«»°°', [('sd', '«»°°')]), - ([('sd', '«»°°'), 'ds:°°«»'], [('sd', '«»°°'), ('ds', '°°«»')]), - ('frs:« : »:((:))', [('frs', ['« ', ' »', '((', '))'])]), - ) + ('en:ssvv', [('en', 'ssvv')]), + ('sd:«»°°', [('sd', '«»°°')]), + ([('sd', '«»°°'), 'ds:°°«»'], [('sd', '«»°°'), ('ds', '°°«»')]), + ('frs:« : »:((:))', [('frs', ['« ', ' »', '((', '))'])]), + ) for t in tests: self.assertEqual( frontend.validate_smartquotes_locales(None, t[0], None), @@ -352,7 +352,7 @@ class HelperFunctionsTests(unittest.TestCase): def test_set_conditions_deprecation_warning(self): reporter = utils.Reporter('test', 1, 4) with self.assertWarnsRegex(DeprecationWarning, - 'Set attributes via configuration settings'): + 'Set attributes via configuration '): reporter.set_conditions('foo', 1, 4) # trigger warning diff --git a/docutils/test/test_utils.py b/docutils/test/test_utils.py index b31de86e3..cb3afee14 100755 --- a/docutils/test/test_utils.py +++ b/docutils/test/test_utils.py @@ -328,7 +328,8 @@ class HelperFunctionTests(unittest.TestCase): # '..\\HISTORY.txt' on windows # '../HISTORY.txt' on other platforms # 'HISTORY.txt' if not called from docutils directory. - self.assertTrue(found.startswith('..'), 'HISTORY.txt not found in "..".') + self.assertTrue(found.startswith('..'), + 'HISTORY.txt not found in "..".') # Return `path` if the file exists in the cwd or if there is no match self.assertEqual(utils.find_file_in_dirs('alltests.py', dirs), 'alltests.py') diff --git a/docutils/tools/buildhtml.py b/docutils/tools/buildhtml.py index a30daa180..c3f366842 100755 --- a/docutils/tools/buildhtml.py +++ b/docutils/tools/buildhtml.py @@ -207,11 +207,6 @@ class Builder: return settings def run(self, directory=None, recurse=1): - # if not self.initial_settings.silent: - # errout = io.ErrorOutput(encoding=self.initial_settings.error_encoding) - # errout.write('*** Using writer "%s"\n' - # % self.initial_settings.writer) - # sys.stderr.flush() recurse = recurse and self.initial_settings.recurse if directory: self.directories = [directory] diff --git a/docutils/tools/dev/create_unimap.py b/docutils/tools/dev/create_unimap.py index a1a563a9e..27f545a01 100755 --- a/docutils/tools/dev/create_unimap.py +++ b/docutils/tools/dev/create_unimap.py @@ -71,6 +71,6 @@ print('# <https://www.w3.org/2003/entities/xml/unicode.xml>, written by') print('# David Carlisle and Sebastian Rahtz.') print('#') print('# The extraction has been done by the "create_unimap.py" script') -print('# located at <https://docutils.sourceforge.io/tools/dev/create_unimap.py>.') +print('# located at <https://docutils.sourceforge.io/tools/dev/create_unimap.py>.') # noqa:501 print('') print('unicode_map = %s' % pprint.pformat(unicode_map, indent=0)) diff --git a/docutils/tools/dev/generate_punctuation_chars.py b/docutils/tools/dev/generate_punctuation_chars.py index 9d9869243..2810158e1 100644 --- a/docutils/tools/dev/generate_punctuation_chars.py +++ b/docutils/tools/dev/generate_punctuation_chars.py @@ -77,10 +77,12 @@ import unicodedata The category of some characters changed with the development of the Unicode standard. The current lists are generated with the help of the - "unicodedata" module of Python %(python_version)s (based on Unicode version %(unidata_version)s). + "unicodedata" module of Python %(python_version)s + (based on Unicode version %(unidata_version)s). .. _inline markup recognition rules: - https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules + https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html + #inline-markup-recognition-rules """ %(openers)s diff --git a/docutils/tools/rst2man.py b/docutils/tools/rst2man.py index 2aafbaf06..c19ca3bf3 100755 --- a/docutils/tools/rst2man.py +++ b/docutils/tools/rst2man.py @@ -21,6 +21,7 @@ except: from docutils.core import publish_cmdline, default_description from docutils.writers import manpage -description = ("Generates plain unix manual documents. " + default_description) +description = ("Generates plain unix manual documents. " + + default_description) publish_cmdline(writer=manpage.Writer(), description=description) diff --git a/docutils/tox.ini b/docutils/tox.ini index 0ca913edb..395888d56 100644 --- a/docutils/tox.ini +++ b/docutils/tox.ini @@ -38,7 +38,6 @@ ignore = # whitespace around the operators with the lowest priority(ies). # Use your own judgment; …" - E501, # line too long (N > 79 characters) E502, # the backslash is redundant between brackets E701, # multiple statements on one line (colon) E704, # multiple statements on one line (def) @@ -67,27 +66,29 @@ per-file-ignores = # deprecated module, will be removed docutils/utils/error_reporting.py:E261 # module with 3rd-party origin - docutils/utils/math/math2html.py:E111,E114,E123,E241,E261 + docutils/utils/math/math2html.py:E111,E114,E123,E241,E261,E501 # generated auxiliary files docutils/utils/math/unichar2tex.py:E122 - docutils/utils/math/tex2unichar.py:E123,E261 + docutils/utils/math/tex2unichar.py:E123,E261,E501 # allow aligning values in data-collections docutils/utils/smartquotes.py:E241 docutils/utils/roman.py:E241 - docutils/utils/math/latex2mathml.py:E241,E261 + docutils/utils/math/latex2mathml.py:E241,E261,E501 docutils/writers/xetex/__init__.py:E241 # also allow '##' to mark deactivated code: docutils/writers/latex2e/__init__.py:E241,E266 - # deprecated module, will be removed - test/test_error_reporting.py:E261 # included configuration files referencing externally defined variables test/functional/tests/*:F821 + # deprecated module, will be removed + test/test_error_reporting.py:E261 + # test output samples contain long lines # don't indent list delimiters in lists of test samples (multi-line strings) - test/test_readers/test_pep/*:E122,E128 - test/test_parsers/*:E122,E124,E128 - test/test_writers/*:E122,E124,E128 - test/test_transforms/*:E122,E124,E128 + test/test_readers/test_pep/*:E122,E128,E501 + test/test_parsers/*:E122,E124,E128,E501 + test/test_writers/*:E122,E124,E128,E501 + test/test_transforms/*:E122,E124,E128,E501 + test/test_publisher.py:E501 # raw string test samples with trailing whitespace - test/test_writers/test_manpage.py:E121,E128,W291 - test/test_writers/test_latex2e.py:E122,E128,W291,W293 + test/test_writers/test_manpage.py:E121,E128,E501,W291 + test/test_writers/test_latex2e.py:E122,E128,E501,W291,W293 |
