Commits

Anonymous committed 01a31b9

Use True/False for booleans. frontend.validate_ternary() returns True/False or value.

  • Participants
  • Parent commits f73826b

Comments (0)

Files changed (6)

File docutils/docutils/frontend.py

                      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):
     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',

File docutils/test/DocutilsTestSupport.py

     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):

File docutils/test/test_functional.py

         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()

File docutils/test/test_pickle.py

     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())

File docutils/test/test_publisher.py

 class PublishDoctreeTestCase(DocutilsTestSupport.StandardTestCase, docutils.SettingsSpec):
 
     settings_default_overrides = {
-        '_disable_config': 1,
+        '_disable_config': True,
         'warning_stream': io.NullOutput()}
 
     def test_publish_doctree(self):

File docutils/test/test_settings.py

 
     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')],