diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2012-11-26 13:50:06 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2012-11-26 13:50:06 +0000 |
| commit | 95cb6423c99388b64634c99e9692cf952ec7741b (patch) | |
| tree | 3e5e5821d83cae96a98a92aae0e7e748590d089e /docutils | |
| parent | 622389bf0fe030b55814bd5b6cff153e2e78b263 (diff) | |
| download | docutils-95cb6423c99388b64634c99e9692cf952ec7741b.tar.gz | |
Use True/False for booleans. frontend.validate_ternary() returns True/False or value.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7539 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/docutils/frontend.py | 12 | ||||
| -rw-r--r-- | docutils/test/DocutilsTestSupport.py | 4 | ||||
| -rwxr-xr-x | docutils/test/test_functional.py | 2 | ||||
| -rwxr-xr-x | docutils/test/test_pickle.py | 2 | ||||
| -rwxr-xr-x | docutils/test/test_publisher.py | 2 | ||||
| -rwxr-xr-x | docutils/test/test_settings.py | 18 |
6 files changed, 19 insertions, 21 deletions
diff --git a/docutils/docutils/frontend.py b/docutils/docutils/frontend.py index 3e3fcf73d..2f6a9a09a 100644 --- a/docutils/docutils/frontend.py +++ b/docutils/docutils/frontend.py @@ -128,17 +128,15 @@ def validate_ternary(setting, value, option_parser, config_parser=None, config_section=None): """Check/normalize three-value settings: True: '1', 'on', 'yes', 'true' - False: '0', 'off', 'no','false', - None: any other value (including '') + False: '0', 'off', 'no','false', '' + any other value: returned as-is. """ if isinstance(value, bool) or value is None: return value - if value == '': - return None try: return option_parser.booleans[value.strip().lower()] except KeyError: - return None + return value def validate_nonnegative_int(setting, value, option_parser, config_parser=None, config_section=None): @@ -349,8 +347,8 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec): thresholds = {'info': 1, 'warning': 2, 'error': 3, 'severe': 4, 'none': 5} """Lookup table for --report and --halt threshold values.""" - booleans={'1': 1, 'on': 1, 'yes': 1, 'true': 1, - '0': 0, 'off': 0, 'no': 0, 'false': 0, '': 0} + booleans={'1': True, 'on': True, 'yes': True, 'true': True, + '0': False, 'off': False, 'no': False, 'false': False, '': False} """Lookup table for boolean configuration file settings.""" default_error_encoding = getattr(sys.stderr, 'encoding', diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py index e410070d4..ea7e21ce8 100644 --- a/docutils/test/DocutilsTestSupport.py +++ b/docutils/test/DocutilsTestSupport.py @@ -706,8 +706,8 @@ class WriterPublishTestCase(CustomTestCase, docutils.SettingsSpec): Test case for publish. """ - settings_default_overrides = {'_disable_config': 1, - 'strict_visitor': 1} + settings_default_overrides = {'_disable_config': True, + 'strict_visitor': True} writer_name = '' # set in subclasses or constructor def __init__(self, *args, **kwargs): diff --git a/docutils/test/test_functional.py b/docutils/test/test_functional.py index 87bc57d44..4d8a26edf 100755 --- a/docutils/test/test_functional.py +++ b/docutils/test/test_functional.py @@ -123,7 +123,7 @@ expected output and check it in: namespace = {} # Initialize 'settings_overrides' for test settings scripts, # and disable configuration files: - namespace['settings_overrides'] = {'_disable_config': 1} + namespace['settings_overrides'] = {'_disable_config': True} # Read the variables set in the default config file and in # the current config file into namespace: defaultpy = open(join_path(datadir, 'tests', '_default.py')).read() diff --git a/docutils/test/test_pickle.py b/docutils/test/test_pickle.py index 79e1f15ac..b1a987f16 100755 --- a/docutils/test/test_pickle.py +++ b/docutils/test/test_pickle.py @@ -18,7 +18,7 @@ class PickleTests(unittest.TestCase): def test_pickle(self): doctree = core.publish_doctree( source='Title\n=====\n\nparagraph\n', - settings_overrides={'_disable_config': 1}) + settings_overrides={'_disable_config': True}) dill = pickle.dumps(doctree) reconstituted = pickle.loads(dill) self.assertEqual(doctree.pformat(), reconstituted.pformat()) diff --git a/docutils/test/test_publisher.py b/docutils/test/test_publisher.py index f38e3a900..0bbd17f1a 100755 --- a/docutils/test/test_publisher.py +++ b/docutils/test/test_publisher.py @@ -79,7 +79,7 @@ class PublisherTests(DocutilsTestSupport.StandardTestCase): class PublishDoctreeTestCase(DocutilsTestSupport.StandardTestCase, docutils.SettingsSpec): settings_default_overrides = { - '_disable_config': 1, + '_disable_config': True, 'warning_stream': io.NullOutput()} def test_publish_doctree(self): diff --git a/docutils/test/test_settings.py b/docutils/test/test_settings.py index 5bff6a0f8..8aaafc6f6 100755 --- a/docutils/test/test_settings.py +++ b/docutils/test/test_settings.py @@ -39,28 +39,28 @@ class ConfigFileTests(unittest.TestCase): settings = { 'old': {u'datestamp': u'%Y-%m-%d %H:%M UTC', - u'generator': 1, - u'no_random': 1, + u'generator': True, + u'no_random': True, u'python_home': u'http://www.python.org', - u'source_link': 1, + u'source_link': True, 'stylesheet': None, u'stylesheet_path': [fixpath(u'data/stylesheets/pep.css')], 'template': fixpath(u'data/pep-html-template')}, 'one': {u'datestamp': u'%Y-%m-%d %H:%M UTC', - u'generator': 1, - u'no_random': 1, + u'generator': True, + u'no_random': True, u'python_home': u'http://www.python.org', - u'raw_enabled': 0, + u'raw_enabled': False, 'record_dependencies': utils.DependencyList(), - u'source_link': 1, + u'source_link': True, 'stylesheet': None, u'stylesheet_path': [fixpath(u'data/stylesheets/pep.css')], u'tab_width': 8, u'template': fixpath(u'data/pep-html-template'), - u'trim_footnote_reference_space': 1, + u'trim_footnote_reference_space': True, }, 'two': {u'footnote_references': u'superscript', - u'generator': 0, + u'generator': False, 'record_dependencies': utils.DependencyList(), u'stylesheet': None, u'stylesheet_path': [fixpath(u'data/test.css')], |
