diff options
author | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-23 19:18:19 +0000 |
---|---|---|
committer | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-23 19:18:19 +0000 |
commit | 909813ea5e93a2ce8809737f60791560b33c1e85 (patch) | |
tree | 8d6fc47c20f6d73499d1b8f1d0d7e4fd2deefdfc /parsers | |
parent | 537774fff163c1bbb528f4ac3c92ce42feacb33d (diff) | |
download | docutils-abolish-userstring.tar.gz |
Replace all has_key with the in operator.abolish-userstring
git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/abolish-userstring@5607 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'parsers')
-rw-r--r-- | parsers/__init__.py | 2 | ||||
-rw-r--r-- | parsers/rst/directives/__init__.py | 2 | ||||
-rw-r--r-- | parsers/rst/directives/admonitions.py | 2 | ||||
-rw-r--r-- | parsers/rst/directives/body.py | 2 | ||||
-rw-r--r-- | parsers/rst/directives/images.py | 4 | ||||
-rw-r--r-- | parsers/rst/directives/misc.py | 24 | ||||
-rw-r--r-- | parsers/rst/directives/parts.py | 4 | ||||
-rw-r--r-- | parsers/rst/directives/tables.py | 24 | ||||
-rw-r--r-- | parsers/rst/languages/__init__.py | 2 | ||||
-rw-r--r-- | parsers/rst/roles.py | 12 | ||||
-rw-r--r-- | parsers/rst/states.py | 4 |
11 files changed, 41 insertions, 41 deletions
diff --git a/parsers/__init__.py b/parsers/__init__.py index 125ab7674..2683376f9 100644 --- a/parsers/__init__.py +++ b/parsers/__init__.py @@ -41,7 +41,7 @@ _parser_aliases = { def get_parser_class(parser_name): """Return the Parser class from the `parser_name` module.""" parser_name = parser_name.lower() - if _parser_aliases.has_key(parser_name): + if parser_name in _parser_aliases: parser_name = _parser_aliases[parser_name] module = __import__(parser_name, globals(), locals()) return module.Parser diff --git a/parsers/rst/directives/__init__.py b/parsers/rst/directives/__init__.py index 14ac03a99..30da65ecd 100644 --- a/parsers/rst/directives/__init__.py +++ b/parsers/rst/directives/__init__.py @@ -76,7 +76,7 @@ def directive(directive_name, language_module, document): normname = directive_name.lower() messages = [] msg_text = [] - if _directives.has_key(normname): + if normname in _directives: return _directives[normname], messages canonicalname = None try: diff --git a/parsers/rst/directives/admonitions.py b/parsers/rst/directives/admonitions.py index bed3381b8..870b6659e 100644 --- a/parsers/rst/directives/admonitions.py +++ b/parsers/rst/directives/admonitions.py @@ -35,7 +35,7 @@ class BaseAdmonition(Directive): self.lineno) admonition_node += nodes.title(title_text, '', *textnodes) admonition_node += messages - if self.options.has_key('class'): + if 'class' in self.options: classes = self.options['class'] else: classes = ['admonition-' + nodes.make_id(title_text)] diff --git a/parsers/rst/directives/body.py b/parsers/rst/directives/body.py index 03c9c3fa6..0cc695726 100644 --- a/parsers/rst/directives/body.py +++ b/parsers/rst/directives/body.py @@ -39,7 +39,7 @@ class BasePseudoSection(Directive): textnodes, messages = self.state.inline_text(title_text, self.lineno) titles = [nodes.title(title_text, '', *textnodes)] # Sidebar uses this code. - if self.options.has_key('subtitle'): + if 'subtitle' in self.options: textnodes, more_messages = self.state.inline_text( self.options['subtitle'], self.lineno) titles.append(nodes.subtitle(self.options['subtitle'], '', diff --git a/parsers/rst/directives/images.py b/parsers/rst/directives/images.py index 96bdb3353..59323bba0 100644 --- a/parsers/rst/directives/images.py +++ b/parsers/rst/directives/images.py @@ -46,7 +46,7 @@ class Image(Directive): 'class': directives.class_option} def run(self): - if self.options.has_key('align'): + if 'align' in self.options: if isinstance(self.state, states.SubstitutionDef): # Check for align_v_values. if self.options['align'] not in self.align_v_values: @@ -66,7 +66,7 @@ class Image(Directive): reference = directives.uri(self.arguments[0]) self.options['uri'] = reference reference_node = None - if self.options.has_key('target'): + if 'target' in self.options: block = states.escape2null( self.options['target']).splitlines() block = [line for line in block] diff --git a/parsers/rst/directives/misc.py b/parsers/rst/directives/misc.py index 5d5d34729..89c8364c7 100644 --- a/parsers/rst/directives/misc.py +++ b/parsers/rst/directives/misc.py @@ -86,7 +86,7 @@ class Include(Directive): raise self.severe('Problem with "end-before" option of "%s" ' 'directive:\nText not found.' % self.name) include_text = include_text[:before_index] - if self.options.has_key('literal'): + if 'literal' in self.options: literal_block = nodes.literal_block(include_text, include_text, source=path) literal_block.line = 1 @@ -120,20 +120,20 @@ class Raw(Directive): def run(self): if (not self.state.document.settings.raw_enabled or (not self.state.document.settings.file_insertion_enabled - and (self.options.has_key('file') - or self.options.has_key('url')))): + and ('file' in self.options + or 'url' in self.options))): raise self.warning('"%s" directive disabled.' % self.name) attributes = {'format': ' '.join(self.arguments[0].lower().split())} encoding = self.options.get( 'encoding', self.state.document.settings.input_encoding) if self.content: - if self.options.has_key('file') or self.options.has_key('url'): + if 'file' in self.options or 'url' in self.options: raise self.error( '"%s" directive may not both specify an external file ' 'and have content.' % self.name) text = '\n'.join(self.content) - elif self.options.has_key('file'): - if self.options.has_key('url'): + elif 'file' in self.options: + if 'url' in self.options: raise self.error( 'The "file" and "url" options may not be simultaneously ' 'specified for the "%s" directive.' % self.name) @@ -159,7 +159,7 @@ class Raw(Directive): 'Problem with "%s" directive:\n%s: %s' % (self.name, error.__class__.__name__, error)) attributes['source'] = path - elif self.options.has_key('url'): + elif 'url' in self.options: source = self.options['url'] # Do not import urllib2 at the top of the module because # it may fail due to broken SSL dependencies, and it takes @@ -244,12 +244,12 @@ class Unicode(Directive): 'Invalid context: the "%s" directive can only be used within ' 'a substitution definition.' % self.name) substitution_definition = self.state_machine.node - if self.options.has_key('trim'): + if 'trim' in self.options: substitution_definition.attributes['ltrim'] = 1 substitution_definition.attributes['rtrim'] = 1 - if self.options.has_key('ltrim'): + if 'ltrim' in self.options: substitution_definition.attributes['ltrim'] = 1 - if self.options.has_key('rtrim'): + if 'rtrim' in self.options: substitution_definition.attributes['rtrim'] = 1 codes = self.comment_pattern.split(self.arguments[0])[0].split() element = nodes.Element() @@ -349,7 +349,7 @@ class Role(Directive): nodes.literal_block(self.block_text, self.block_text), line=self.lineno) return messages + [error] - if not options.has_key('class'): + if 'class' not in options: try: options['class'] = directives.class_option(new_role_name) except ValueError, detail: @@ -373,7 +373,7 @@ class DefaultRole(Directive): def run(self): if not self.arguments: - if roles._roles.has_key(''): + if '' in roles._roles: # restore the "default" default role del roles._roles[''] return [] diff --git a/parsers/rst/directives/parts.py b/parsers/rst/directives/parts.py index da1586275..6ef8c905c 100644 --- a/parsers/rst/directives/parts.py +++ b/parsers/rst/directives/parts.py @@ -57,13 +57,13 @@ class Contents(Directive): title = nodes.title(title_text, '', *text_nodes) else: messages = [] - if self.options.has_key('local'): + if 'local' in self.options: title = None else: title = nodes.title('', language.labels['contents']) topic = nodes.topic(classes=['contents']) topic['classes'] += self.options.get('class', []) - if self.options.has_key('local'): + if 'local' in self.options: topic['classes'].append('local') if title: name = title.astext() diff --git a/parsers/rst/directives/tables.py b/parsers/rst/directives/tables.py index 639ce8d1f..5527c9f0b 100644 --- a/parsers/rst/directives/tables.py +++ b/parsers/rst/directives/tables.py @@ -49,7 +49,7 @@ class Table(Directive): source = self.state_machine.get_source(self.lineno - 1) table_head = [] max_header_cols = 0 - if self.options.has_key('header'): # separate table header in option + if 'header' in self.options: # separate table header in option rows, max_header_cols = self.parse_csv_data_into_rows( self.options['header'].split('\n'), self.HeaderDialect(), source) @@ -88,7 +88,7 @@ class Table(Directive): raise SystemMessagePropagation(error) def get_column_widths(self, max_cols): - if self.options.has_key('widths'): + if 'widths' in self.options: col_widths = self.options['widths'] if len(col_widths) != max_cols: error = self.state_machine.reporter.error( @@ -170,13 +170,13 @@ class CSVTable(Table): quoting = csv.QUOTE_MINIMAL def __init__(self, options): - if options.has_key('delim'): + if 'delim' in options: self.delimiter = str(options['delim']) - if options.has_key('keepspace'): + if 'keepspace' in options: self.skipinitialspace = False - if options.has_key('quote'): + if 'quote' in options: self.quotechar = str(options['quote']) - if options.has_key('escape'): + if 'escape' in options: self.doublequote = False self.escapechar = str(options['escape']) csv.Dialect.__init__(self) @@ -206,8 +206,8 @@ class CSVTable(Table): def run(self): try: if (not self.state.document.settings.file_insertion_enabled - and (self.options.has_key('file') - or self.options.has_key('url'))): + and ('file' in self.options + or 'url' in self.options)): warning = self.state_machine.reporter.warning( 'File and URL access deactivated; ignoring "%s" ' 'directive.' % self.name, nodes.literal_block( @@ -253,7 +253,7 @@ class CSVTable(Table): 'encoding', self.state.document.settings.input_encoding) if self.content: # CSV data is from directive content. - if self.options.has_key('file') or self.options.has_key('url'): + if 'file' in self.options or 'url' in self.options: error = self.state_machine.reporter.error( '"%s" directive may not both specify an external file and' ' have content.' % self.name, nodes.literal_block( @@ -261,9 +261,9 @@ class CSVTable(Table): raise SystemMessagePropagation(error) source = self.content.source(0) csv_data = self.content - elif self.options.has_key('file'): + elif 'file' in self.options: # CSV data is from an external file. - if self.options.has_key('url'): + if 'url' in self.options: error = self.state_machine.reporter.error( 'The "file" and "url" options may not be simultaneously' ' specified for the "%s" directive.' % self.name, @@ -289,7 +289,7 @@ class CSVTable(Table): % (self.name, error), nodes.literal_block( self.block_text, self.block_text), line=self.lineno) raise SystemMessagePropagation(severe) - elif self.options.has_key('url'): + elif 'url' in self.options: # CSV data is from a URL. # Do not import urllib2 at the top of the module because # it may fail due to broken SSL dependencies, and it takes diff --git a/parsers/rst/languages/__init__.py b/parsers/rst/languages/__init__.py index 18c884748..962802245 100644 --- a/parsers/rst/languages/__init__.py +++ b/parsers/rst/languages/__init__.py @@ -15,7 +15,7 @@ __docformat__ = 'reStructuredText' _languages = {} def get_language(language_code): - if _languages.has_key(language_code): + if language_code in _languages: return _languages[language_code] try: module = __import__(language_code, globals(), locals()) diff --git a/parsers/rst/roles.py b/parsers/rst/roles.py index 1da1395e9..062d53e50 100644 --- a/parsers/rst/roles.py +++ b/parsers/rst/roles.py @@ -101,7 +101,7 @@ def role(role_name, language_module, lineno, reporter): messages = [] msg_text = [] - if _roles.has_key(normname): + if normname in _roles: return _roles[normname], messages if role_name: @@ -135,7 +135,7 @@ def role(role_name, language_module, lineno, reporter): messages.append(message) # Look the role up in the registry, and return it. - if _role_registry.has_key(canonicalname): + if canonicalname in _role_registry: role_fn = _role_registry[canonicalname] register_local_role(normname, role_fn) return role_fn, messages @@ -171,7 +171,7 @@ def set_implicit_options(role_fn): """ if not hasattr(role_fn, 'options') or role_fn.options is None: role_fn.options = {'class': directives.class_option} - elif not role_fn.options.has_key('class'): + elif 'class' not in role_fn.options: role_fn.options['class'] = directives.class_option def register_generic_role(canonical_name, node_class): @@ -294,7 +294,7 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner, register_canonical_role('rfc-reference', rfc_reference_role) def raw_role(role, rawtext, text, lineno, inliner, options={}, content=[]): - if not options.has_key('format'): + if 'format' not in options: msg = inliner.reporter.error( 'No format (Writer name) is associated with this role: "%s".\n' 'The "raw" role cannot be used directly.\n' @@ -340,7 +340,7 @@ def set_classes(options): Auxiliary function to set options['classes'] and delete options['class']. """ - if options.has_key('class'): - assert not options.has_key('classes') + if 'class' in options: + assert 'classes' not in options options['classes'] = options['class'] del options['class'] diff --git a/parsers/rst/states.py b/parsers/rst/states.py index eabc179ef..b20c9f4d9 100644 --- a/parsers/rst/states.py +++ b/parsers/rst/states.py @@ -901,8 +901,8 @@ class Inliner: return self.reference(match, lineno, anonymous=1) def standalone_uri(self, match, lineno): - if not match.group('scheme') or urischemes.schemes.has_key( - match.group('scheme').lower()): + if (not match.group('scheme') + or match.group('scheme').lower() in urischemes.schemes): if match.group('email'): addscheme = 'mailto:' else: |