diff options
author | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-23 19:44:50 +0000 |
---|---|---|
committer | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-23 19:44:50 +0000 |
commit | 9878aff2fb3421f1a31681d361cc24d1ef3e1a5b (patch) | |
tree | 8b1cb8accd2b1843d83838796a738e1b4a93faa3 | |
parent | 83816c45579ffbfab7206e21818ecdd12ddcd8f6 (diff) | |
download | docutils-abolish-userstring-haskey@5608.tar.gz |
undo accidental commit to trunkabolish-userstring-haskey@5608
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5608 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r-- | extras/optparse.py | 16 | ||||
-rw-r--r-- | test/DocutilsTestSupport.py | 2 | ||||
-rw-r--r-- | test/docutils_difflib.py | 15 | ||||
-rwxr-xr-x | test/test_dependencies.py | 2 | ||||
-rwxr-xr-x | test/test_functional.py | 6 | ||||
-rwxr-xr-x | test/test_language.py | 8 | ||||
-rwxr-xr-x | test/test_nodes.py | 2 | ||||
-rwxr-xr-x | test/test_settings.py | 4 | ||||
-rwxr-xr-x | tools/dev/unicode2rstsubs.py | 4 |
9 files changed, 31 insertions, 28 deletions
diff --git a/extras/optparse.py b/extras/optparse.py index ae769301d..c21663c55 100644 --- a/extras/optparse.py +++ b/extras/optparse.py @@ -472,7 +472,7 @@ class Option: def _set_attrs (self, attrs): for attr in self.ATTRS: - if attr in attrs: + if attrs.has_key(attr): setattr(self, attr, attrs[attr]) del attrs[attr] else: @@ -676,7 +676,7 @@ class Values: are silently ignored. """ for attr in dir(self): - if attr in dict: + if dict.has_key(attr): dval = dict[attr] if dval is not None: setattr(self, attr, dval) @@ -786,10 +786,10 @@ class OptionContainer: def _check_conflict (self, option): conflict_opts = [] for opt in option._short_opts: - if opt in self._short_opt: + if self._short_opt.has_key(opt): conflict_opts.append((opt, self._short_opt[opt])) for opt in option._long_opts: - if opt in self._long_opt: + if self._long_opt.has_key(opt): conflict_opts.append((opt, self._long_opt[opt])) if conflict_opts: @@ -837,7 +837,7 @@ class OptionContainer: if option.dest is not None: # option has a dest, we need a default if option.default is not NO_DEFAULT: self.defaults[option.dest] = option.default - elif option.dest not in self.defaults: + elif not self.defaults.has_key(option.dest): self.defaults[option.dest] = None return option @@ -853,8 +853,8 @@ class OptionContainer: self._long_opt.get(opt_str)) def has_option (self, opt_str): - return (opt_str in self._short_opt or - opt_str in self._long_opt) + return (self._short_opt.has_key(opt_str) or + self._long_opt.has_key(opt_str)) def remove_option (self, opt_str): option = self._short_opt.get(opt_str) @@ -1393,7 +1393,7 @@ def _match_abbrev (s, wordmap): 'words', raise BadOptionError. """ # Is there an exact match? - if s in wordmap: + if wordmap.has_key(s): return s else: # Isolate all words with s as a prefix. diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py index ce67ab262..24858c624 100644 --- a/test/DocutilsTestSupport.py +++ b/test/DocutilsTestSupport.py @@ -668,7 +668,7 @@ class WriterPublishTestCase(CustomTestCase, docutils.SettingsSpec): writer_name = '' # set in subclasses or constructor def __init__(self, *args, **kwargs): - if 'writer_name' in kwargs: + if kwargs.has_key('writer_name'): self.writer_name = kwargs['writer_name'] del kwargs['writer_name'] CustomTestCase.__init__(self, *args, **kwargs) diff --git a/test/docutils_difflib.py b/test/docutils_difflib.py index 1865c2117..a41d4d5ba 100644 --- a/test/docutils_difflib.py +++ b/test/docutils_difflib.py @@ -163,6 +163,8 @@ class SequenceMatcher: # b2j # for x in b, b2j[x] is a list of the indices (into b) # at which x appears; junk elements do not appear + # b2jhas + # b2j.has_key # fullbcount # for x in b, fullbcount[x] == the number of times x # appears in b; only materialized if really needed (used @@ -186,7 +188,7 @@ class SequenceMatcher: # DON'T USE! Only __chain_b uses this. Use isbjunk. # isbjunk # for x in b, isbjunk(x) == isjunk(x) but much faster; - # it's really the in operator of a hidden dict. + # it's really the has_key method of a hidden dict. # DOES NOT WORK for x in a! self.isjunk = isjunk @@ -283,9 +285,10 @@ class SequenceMatcher: # from the start. b = self.b self.b2j = b2j = {} + self.b2jhas = b2jhas = b2j.has_key for i in xrange(len(b)): elt = b[i] - if elt in b2j: + if b2jhas(elt): b2j[elt].append(i) else: b2j[elt] = [i] @@ -301,12 +304,12 @@ class SequenceMatcher: junkdict[elt] = 1 # value irrelevant; it's a set del b2j[elt] - # Now for x in b, isjunk(x) == x in junkdict, but the + # Now for x in b, isjunk(x) == junkdict.has_key(x), but the # latter is much faster. Note too that while there may be a # lot of junk in the sequence, the number of *unique* junk # elements is probably small. So the memory burden of keeping # this dict alive is likely trivial compared to the size of b2j. - self.isbjunk = lambda elt: elt in junkdict + self.isbjunk = junkdict.has_key def find_longest_match(self, alo, ahi, blo, bhi): """Find longest matching block in a[alo:ahi] and b[blo:bhi]. @@ -547,9 +550,9 @@ class SequenceMatcher: # avail[x] is the number of times x appears in 'b' less the # number of times we've seen it in 'a' so far ... kinda avail = {} - matches = 0 + availhas, matches = avail.has_key, 0 for elt in self.a: - if elt in avail: + if availhas(elt): numb = avail[elt] else: numb = fullbcount.get(elt, 0) diff --git a/test/test_dependencies.py b/test/test_dependencies.py index c9463b440..d82f52c55 100755 --- a/test/test_dependencies.py +++ b/test/test_dependencies.py @@ -28,7 +28,7 @@ class RecordDependenciesTests(unittest.TestCase): settings.setdefault('settings_overrides', {}) settings['settings_overrides'] = settings['settings_overrides'].copy() settings['settings_overrides']['_disable_config'] = 1 - if 'record_dependencies' not in settings['settings_overrides']: + if not settings['settings_overrides'].has_key('record_dependencies'): settings['settings_overrides']['record_dependencies'] = \ docutils.utils.DependencyList(recordfile) docutils.core.publish_file(destination=DocutilsTestSupport.DevNull(), diff --git a/test/test_functional.py b/test/test_functional.py index 9d129f412..26f4533c6 100755 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -95,9 +95,9 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase): execfile(join_path(datadir, 'tests', '_default.py'), namespace) execfile(self.configfile, namespace) # Check for required settings: - assert 'test_source' in namespace,\ + assert namespace.has_key('test_source'),\ "No 'test_source' supplied in " + self.configfile - assert 'test_destination' in namespace,\ + assert namespace.has_key('test_destination'),\ "No 'test_destination' supplied in " + self.configfile # Set source_path and destination_path if not given: namespace.setdefault('source_path', @@ -151,7 +151,7 @@ class FunctionalTestCase(DocutilsTestSupport.CustomTestCase): print >>sys.stderr, diff raise # Execute optional function containing extra tests: - if '_test_more' in namespace: + if namespace.has_key('_test_more'): namespace['_test_more'](join_path(datadir, 'expected'), join_path(datadir, 'output'), self, namespace) diff --git a/test/test_language.py b/test/test_language.py index 6fd0ee546..3f929bd05 100755 --- a/test/test_language.py +++ b/test/test_language.py @@ -76,10 +76,10 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase): missing = [] # in ref but not in l. too_much = [] # in l but not in ref. for label in ref_dict.keys(): - if label not in l_dict: + if not l_dict.has_key(label): missing.append(label) for label in l_dict.keys(): - if label not in ref_dict: + if not ref_dict.has_key(label): too_much.append(label) return (missing, too_much) @@ -140,7 +140,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase): canonical.sort() canonical.remove('restructuredtext-test-directive') for name in canonical: - if name not in inverted: + if not inverted.has_key(name): failures.append('"%s": translation missing' % name) if failures: text = ('Module docutils.parsers.rst.languages.%s:\n %s' @@ -175,7 +175,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase): canonical.sort() canonical.remove('restructuredtext-unimplemented-role') for name in canonical: - if name not in inverted: + if not inverted.has_key(name): failures.append('"%s": translation missing' % name) if failures: text = ('Module docutils.parsers.rst.languages.%s:\n %s' diff --git a/test/test_nodes.py b/test/test_nodes.py index 2da605aea..c981a4e96 100755 --- a/test/test_nodes.py +++ b/test/test_nodes.py @@ -91,7 +91,7 @@ class ElementTests(unittest.TestCase): def test_normal_attributes(self): element = nodes.Element() - self.assert_('foo' not in element) + self.assert_(not element.has_key('foo')) self.assertRaises(KeyError, element.__getitem__, 'foo') element['foo'] = 'sometext' self.assertEquals(element['foo'], 'sometext') diff --git a/test/test_settings.py b/test/test_settings.py index fb050b2ad..2cf4e080c 100755 --- a/test/test_settings.py +++ b/test/test_settings.py @@ -92,8 +92,8 @@ class ConfigFileTests(unittest.TestCase): def compare_output(self, result, expected): """`result` and `expected` should both be dicts.""" - self.assert_('record_dependencies' in result) - if 'record_dependencies' not in expected: + self.assert_(result.has_key('record_dependencies')) + if not expected.has_key('record_dependencies'): # Delete it if we don't want to test it. del result['record_dependencies'] result = pprint.pformat(result) + '\n' diff --git a/tools/dev/unicode2rstsubs.py b/tools/dev/unicode2rstsubs.py index 22ac07ecc..9161e10c1 100755 --- a/tools/dev/unicode2rstsubs.py +++ b/tools/dev/unicode2rstsubs.py @@ -129,11 +129,11 @@ class CharacterEntitySetExtractor: set = self.entity_set_name(attributes['set']) if not set: return - if set not in self.sets: + if not self.sets.has_key(set): print 'bad set: %r' % set return entity = attributes['id'] - assert (entity not in self.sets[set] + assert (not self.sets[set].has_key(entity) or self.sets[set][entity] == self.charid), \ ('sets[%r][%r] == %r (!= %r)' % (set, entity, self.sets[set][entity], self.charid)) |