diff options
Diffstat (limited to 'writers')
-rw-r--r-- | writers/__init__.py | 2 | ||||
-rw-r--r-- | writers/html4css1/__init__.py | 42 | ||||
-rw-r--r-- | writers/latex2e/__init__.py | 44 | ||||
-rw-r--r-- | writers/newlatex2e/__init__.py | 2 | ||||
-rw-r--r-- | writers/s5_html/__init__.py | 2 |
5 files changed, 46 insertions, 46 deletions
diff --git a/writers/__init__.py b/writers/__init__.py index 39e1ecd5b..8e3bd1aaa 100644 --- a/writers/__init__.py +++ b/writers/__init__.py @@ -127,7 +127,7 @@ _writer_aliases = { def get_writer_class(writer_name): """Return the Writer class from the `writer_name` module.""" writer_name = writer_name.lower() - if _writer_aliases.has_key(writer_name): + if writer_name in _writer_aliases: writer_name = _writer_aliases[writer_name] module = __import__(writer_name, globals(), locals()) return module.Writer diff --git a/writers/html4css1/__init__.py b/writers/html4css1/__init__.py index 634a74d1d..57d2c6ef0 100644 --- a/writers/html4css1/__init__.py +++ b/writers/html4css1/__init__.py @@ -353,13 +353,13 @@ class HTMLTranslator(nodes.NodeVisitor): for (name, value) in attributes.items(): atts[name.lower()] = value classes = node.get('classes', []) - if atts.has_key('class'): + if 'class' in atts: classes.append(atts['class']) if classes: atts['class'] = ' '.join(classes) - assert not atts.has_key('id') + assert 'id' not in atts ids.extend(node.get('ids', [])) - if atts.has_key('ids'): + if 'ids' in atts: ids.extend(atts['ids']) del atts['ids'] if ids: @@ -731,9 +731,9 @@ class HTMLTranslator(nodes.NodeVisitor): tagname = 'td' del atts['class'] node.parent.column += 1 - if node.has_key('morerows'): + if 'morerows' in node: atts['rowspan'] = node['morerows'] + 1 - if node.has_key('morecols'): + if 'morecols' in node: atts['colspan'] = node['morecols'] + 1 node.parent.column += node['morecols'] self.body.append(self.starttag(node, tagname, '', **atts)) @@ -752,9 +752,9 @@ class HTMLTranslator(nodes.NodeVisitor): usable. """ atts = {} - if node.has_key('start'): + if 'start' in node: atts['start'] = node['start'] - if node.has_key('enumtype'): + if 'enumtype' in node: atts['class'] = node['enumtype'] # @@@ To do: prefix, suffix. How? Change prefix/suffix to a # single "format" attribute? Use CSS2? @@ -941,26 +941,26 @@ class HTMLTranslator(nodes.NodeVisitor): def visit_image(self, node): atts = {} atts['src'] = node['uri'] - if node.has_key('width'): + if 'width' in node: atts['width'] = node['width'] - if node.has_key('height'): + if 'height' in node: atts['height'] = node['height'] - if node.has_key('scale'): - if Image and not (node.has_key('width') - and node.has_key('height')): + if 'scale' in node: + if Image and not ('width' in node + and 'height' in node): try: im = Image.open(str(atts['src'])) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. pass else: - if not atts.has_key('width'): + if 'width' not in atts: atts['width'] = str(im.size[0]) - if not atts.has_key('height'): + if 'height' not in atts: atts['height'] = str(im.size[1]) del im for att_name in 'width', 'height': - if atts.has_key(att_name): + if att_name in atts: match = re.match(r'([0-9.]+)(\S*)$', atts[att_name]) assert match atts[att_name] = '%s%s' % ( @@ -968,7 +968,7 @@ class HTMLTranslator(nodes.NodeVisitor): match.group(2)) style = [] for att_name in 'width', 'height': - if atts.has_key(att_name): + if att_name in atts: if re.match(r'^[0-9.]+$', atts[att_name]): # Interpret unitless values as pixels. atts[att_name] += 'px' @@ -984,7 +984,7 @@ class HTMLTranslator(nodes.NodeVisitor): suffix = '' else: suffix = '\n' - if node.has_key('align'): + if 'align' in node: if node['align'] == 'center': # "align" attribute is set in surrounding "div" element. self.body.append('<div align="center" class="align-center">') @@ -1210,7 +1210,7 @@ class HTMLTranslator(nodes.NodeVisitor): def visit_reference(self, node): atts = {'class': 'reference'} - if node.has_key('refuri'): + if 'refuri' in node: atts['href'] = node['refuri'] if ( self.settings.cloak_email_addresses and atts['href'].startswith('mailto:')): @@ -1218,7 +1218,7 @@ class HTMLTranslator(nodes.NodeVisitor): self.in_mailto = 1 atts['class'] += ' external' else: - assert node.has_key('refid'), \ + assert 'refid' in node, \ 'References must have "refuri" or "refid" attribute.' atts['href'] = '#' + node['refid'] atts['class'] += ' internal' @@ -1364,8 +1364,8 @@ class HTMLTranslator(nodes.NodeVisitor): self.body.append('</table>\n') def visit_target(self, node): - if not (node.has_key('refuri') or node.has_key('refid') - or node.has_key('refname')): + if not ('refuri' in node or 'refid' in node + or 'refname' in node): self.body.append(self.starttag(node, 'span', '', CLASS='target')) self.context.append('</span>') else: diff --git a/writers/latex2e/__init__.py b/writers/latex2e/__init__.py index a4245a173..70a158b64 100644 --- a/writers/latex2e/__init__.py +++ b/writers/latex2e/__init__.py @@ -1124,9 +1124,9 @@ class LaTeXTranslator(nodes.NodeVisitor): self.inside_citation_reference_label = 1 else: href = '' - if node.has_key('refid'): + if 'refid' in node: href = node['refid'] - elif node.has_key('refname'): + elif 'refname' in node: href = self.document.nameids[node['refname']] self.body.append('[\\hyperlink{%s}{' % href) @@ -1343,17 +1343,17 @@ class LaTeXTranslator(nodes.NodeVisitor): # IN WORK BUG TODO HACK continues here # multirow in LaTeX simply will enlarge the cell over several rows # (the following n if n is positive, the former if negative). - if node.has_key('morerows') and node.has_key('morecols'): + if 'morerows' in node and 'morecols' in node: raise NotImplementedError('Cells that ' 'span multiple rows *and* columns are not supported, sorry.') - if node.has_key('morerows'): + if 'morerows' in node: count = node['morerows'] + 1 self.active_table.set_rowspan(self.active_table.get_entry_number()-1,count) self.body.append('\\multirow{%d}{%s}{' % \ (count,self.active_table.get_column_width())) self.context.append('}') # BUG following rows must have empty cells. - elif node.has_key('morecols'): + elif 'morecols' in node: # the vertical bar before column is missing if it is the first column. # the one after always. if self.active_table.get_entry_number() == 1: @@ -1401,10 +1401,10 @@ class LaTeXTranslator(nodes.NodeVisitor): 'lowerroman':'roman', 'upperroman':'Roman' } enum_suffix = "" - if node.has_key('suffix'): + if 'suffix' in node: enum_suffix = node['suffix'] enum_prefix = "" - if node.has_key('prefix'): + if 'prefix' in node: enum_prefix = node['prefix'] if self.compound_enumerators: pref = "" @@ -1416,7 +1416,7 @@ class LaTeXTranslator(nodes.NodeVisitor): for ctype, cname in self._enumeration_counters: enum_prefix += '\\%s{%s}.' % (ctype, cname) enum_type = "arabic" - if node.has_key('enumtype'): + if 'enumtype' in node: enum_type = node['enumtype'] if enum_type in enum_style: enum_type = enum_style[enum_type] @@ -1436,7 +1436,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append('{\n') self.body.append('\\usecounter{%s}\n' % counter_name) # set start after usecounter, because it initializes to zero. - if node.has_key('start'): + if 'start' in node: self.body.append('\\addtocounter{%s}{%d}\n' \ % (counter_name,node['start']-1)) ## set rightmargin equal to leftmargin @@ -1500,7 +1500,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append(':]') def visit_figure(self, node): - if (not node.attributes.has_key('align') or + if ('align' not in node.attributes or node.attributes['align'] == 'center'): # centering does not add vertical space like center. align = '\n\\centering' @@ -1547,9 +1547,9 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append("\\footnotemark["+self.encode(node.astext())+"]") raise nodes.SkipNode href = '' - if node.has_key('refid'): + if 'refid' in node: href = node['refid'] - elif node.has_key('refname'): + elif 'refname' in node: href = self.document.nameids[node['refname']] format = self.settings.footnote_references if format == 'brackets': @@ -1633,18 +1633,18 @@ class LaTeXTranslator(nodes.NodeVisitor): post = [] include_graphics_options = [] inline = isinstance(node.parent, nodes.TextElement) - if attrs.has_key('scale'): + if 'scale' in attrs: # Could also be done with ``scale`` option to # ``\includegraphics``; doing it this way for consistency. pre.append('\\scalebox{%f}{' % (attrs['scale'] / 100.0,)) post.append('}') - if attrs.has_key('width'): + if 'width' in attrs: include_graphics_options.append('width=%s' % ( self.latex_image_length(attrs['width']), )) - if attrs.has_key('height'): + if 'height' in attrs: include_graphics_options.append('height=%s' % ( self.latex_image_length(attrs['height']), )) - if attrs.has_key('align'): + if 'align' in attrs: align_prepost = { # By default latex aligns the top of an image. (1, 'top'): ('', ''), @@ -1870,16 +1870,16 @@ class LaTeXTranslator(nodes.NodeVisitor): # BUG: hash_char "#" is trouble some in LaTeX. # mbox and other environment do not like the '#'. hash_char = '\\#' - if node.has_key('refuri'): + if 'refuri' in node: href = node['refuri'].replace('#',hash_char) - elif node.has_key('refid'): + elif 'refid' in node: href = hash_char + node['refid'] - elif node.has_key('refname'): + elif 'refname' in node: href = hash_char + self.document.nameids[node['refname']] else: raise AssertionError('Unknown reference.') self.body.append('\\href{%s}{' % href.replace("%", "\\%")) - if self._reference_label and not node.has_key('refuri'): + if self._reference_label and 'refuri' not in node: self.body.append('\\%s{%s}}' % (self._reference_label, href.replace(hash_char, ''))) raise nodes.SkipNode @@ -1993,8 +1993,8 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_target(self, node): # BUG: why not (refuri or refid or refname) means not footnote ? - if not (node.has_key('refuri') or node.has_key('refid') - or node.has_key('refname')): + if not ('refuri' in node or 'refid' in node + or 'refname' in node): for id in node['ids']: self.body.append('\\hypertarget{%s}{' % id) self.context.append('}' * len(node['ids'])) diff --git a/writers/newlatex2e/__init__.py b/writers/newlatex2e/__init__.py index 8c360876e..2830fd556 100644 --- a/writers/newlatex2e/__init__.py +++ b/writers/newlatex2e/__init__.py @@ -676,7 +676,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor): # Move IDs into TextElements. This won't work for images. # Need to review this. for node in document.traverse(nodes.Element): - if node.has_key('ids') and not isinstance(node, + if 'ids' in node and not isinstance(node, nodes.TextElement): next_text_element = node.next_node(nodes.TextElement) if next_text_element: diff --git a/writers/s5_html/__init__.py b/writers/s5_html/__init__.py index 486c03f4a..73a1ec66f 100644 --- a/writers/s5_html/__init__.py +++ b/writers/s5_html/__init__.py @@ -251,7 +251,7 @@ class S5HTMLTranslator(html4css1.HTMLTranslator): """ source = os.path.join(source_dir, name) dest = os.path.join(dest_dir, name) - if self.theme_files_copied.has_key(dest): + if dest in self.theme_files_copied: return 1 else: self.theme_files_copied[dest] = 1 |