diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-03-14 16:45:09 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-03-14 16:45:09 +0000 |
| commit | e113241b50a0041cb19112ac4aebf8fbcd6f8ba2 (patch) | |
| tree | ef6cd9d2a61bf07d47d247ec5ccc30846e4c1cbf /docutils | |
| parent | d6d71e6698452cf9660b4209a396001a9b69276b (diff) | |
| download | docutils-e113241b50a0041cb19112ac4aebf8fbcd6f8ba2.tar.gz | |
re-added --no-random option of PEP writer for testing
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@3039 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/docs/user/config.txt | 7 | ||||
| -rw-r--r-- | docutils/docutils/writers/pep_html.py | 13 | ||||
| -rw-r--r-- | docutils/test/data/config_1.txt | 1 | ||||
| -rw-r--r-- | docutils/test/data/config_old.txt | 1 | ||||
| -rwxr-xr-x | docutils/test/test_settings.py | 2 |
5 files changed, 21 insertions, 3 deletions
diff --git a/docutils/docs/user/config.txt b/docutils/docs/user/config.txt index 07fa26460..458801347 100644 --- a/docutils/docs/user/config.txt +++ b/docutils/docs/user/config.txt @@ -590,6 +590,13 @@ The PEP/HTML Writer derives from the standard HTML Writer, and shares all settings defined in the `[html4css1 writer]`_ section. The "[html4css1 writer]" section is processed before "[pep_html writer]". +_`no_random` + Do not use a random banner image. Mainly used to get predictable + results when testing. + + Default: random enabled (None). Options: ``--no-random`` + (hidden). + _`pep_home` Home URL prefix for PEPs. diff --git a/docutils/docutils/writers/pep_html.py b/docutils/docutils/writers/pep_html.py index 9305e6062..ebeef12e3 100644 --- a/docutils/docutils/writers/pep_html.py +++ b/docutils/docutils/writers/pep_html.py @@ -11,7 +11,6 @@ PEP HTML Writer. __docformat__ = 'reStructuredText' -import random import sys import docutils from docutils import frontend, nodes, utils @@ -32,7 +31,11 @@ class Writer(html4css1.Writer): {'default': '..', 'metavar': '<URL>'}), ('Home URL prefix for PEPs. Default is "." (current directory).', ['--pep-home'], - {'default': '.', 'metavar': '<URL>'}),)) + {'default': '.', 'metavar': '<URL>'}), + # For testing. + (frontend.SUPPRESS_HELP, + ['--no-random'], + {'action': 'store_true', 'validator': frontend.validate_boolean}),)) settings_default_overrides = {'footnote_references': 'brackets'} @@ -66,7 +69,11 @@ class Writer(html4css1.Writer): header = self.document[index] pepnum = header[0][1].astext() subs['pep'] = pepnum - subs['banner'] = random.randrange(64) + if settings.no_random: + subs['banner'] = 0 + else: + import random + subs['banner'] = random.randrange(64) try: subs['pepnum'] = '%04i' % int(pepnum) except ValueError: diff --git a/docutils/test/data/config_1.txt b/docutils/test/data/config_1.txt index 0c513dc57..f94074a8a 100644 --- a/docutils/test/data/config_1.txt +++ b/docutils/test/data/config_1.txt @@ -22,3 +22,4 @@ stylesheet-path: stylesheets/default.css template: pep-html-template stylesheet-path: stylesheets/pep.css python-home: http://www.python.org +no-random: yes diff --git a/docutils/test/data/config_old.txt b/docutils/test/data/config_old.txt index 53ab8cb70..fa07d6dab 100644 --- a/docutils/test/data/config_old.txt +++ b/docutils/test/data/config_old.txt @@ -11,3 +11,4 @@ stylesheet-path: stylesheets/default.css pep-template: pep-html-template pep-stylesheet-path: stylesheets/pep.css python-home: http://www.python.org +no-random: 1 diff --git a/docutils/test/test_settings.py b/docutils/test/test_settings.py index bb0b87020..2a17c6eef 100755 --- a/docutils/test/test_settings.py +++ b/docutils/test/test_settings.py @@ -43,6 +43,7 @@ class ConfigFileTests(unittest.TestCase): settings = { 'old': {'datestamp': '%Y-%m-%d %H:%M UTC', 'generator': 1, + 'no_random': 1, 'python_home': 'http://www.python.org', 'source_link': 1, 'stylesheet': None, @@ -50,6 +51,7 @@ class ConfigFileTests(unittest.TestCase): 'template': fixpath('data/pep-html-template')}, 'one': {'datestamp': '%Y-%m-%d %H:%M UTC', 'generator': 1, + 'no_random': 1, 'python_home': 'http://www.python.org', 'record_dependencies': utils.DependencyList(), 'source_link': 1, |
