mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Replace .has_key() calls with the in-operator
This commit is contained in:
parent
12ecec3f57
commit
e97122236d
@ -314,7 +314,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
# ... and all others are the appendices
|
||||
self.body.append(u'\n\\appendix\n')
|
||||
self.first_document = -1
|
||||
if node.has_key('docname'):
|
||||
if 'docname' in node:
|
||||
self.body.append(self.hypertarget(':doc'))
|
||||
# "- 1" because the level is increased before the title is visited
|
||||
self.sectionlevel = self.top_sectionlevel - 1
|
||||
@ -694,7 +694,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.table.rowcount += 1
|
||||
|
||||
def visit_entry(self, node):
|
||||
if node.has_key('morerows') or node.has_key('morecols'):
|
||||
if 'morerows' in node or 'morecols' in node:
|
||||
raise UnsupportedError('%s:%s: column or row spanning cells are '
|
||||
'not yet implemented.' %
|
||||
(self.curfilestack[-1], node.line or ''))
|
||||
@ -751,7 +751,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
|
||||
def visit_term(self, node):
|
||||
ctx = '}] \\leavevmode'
|
||||
if node.has_key('ids') and node['ids']:
|
||||
if node.get('ids'):
|
||||
ctx += self.hypertarget(node['ids'][0])
|
||||
self.body.append('\\item[{')
|
||||
self.context.append(ctx)
|
||||
@ -833,20 +833,20 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
post = []
|
||||
include_graphics_options = []
|
||||
is_inline = self.is_inline(node)
|
||||
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:
|
||||
w = self.latex_image_length(attrs['width'])
|
||||
if w:
|
||||
include_graphics_options.append('width=%s' % w)
|
||||
if attrs.has_key('height'):
|
||||
if 'height' in attrs:
|
||||
h = self.latex_image_length(attrs['height'])
|
||||
if h:
|
||||
include_graphics_options.append('height=%s' % h)
|
||||
if attrs.has_key('align'):
|
||||
if 'align' in attrs:
|
||||
align_prepost = {
|
||||
# By default latex aligns the top of an image.
|
||||
(1, 'top'): ('', ''),
|
||||
@ -887,13 +887,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
pass
|
||||
|
||||
def visit_figure(self, node):
|
||||
if node.has_key('width') and node.get('align', '') in ('left', 'right'):
|
||||
if 'width' in node and node.get('align', '') in ('left', 'right'):
|
||||
self.body.append('\\begin{wrapfigure}{%s}{%s}\n\\centering' %
|
||||
(node['align'] == 'right' and 'r' or 'l',
|
||||
node['width']))
|
||||
self.context.append('\\end{wrapfigure}\n')
|
||||
else:
|
||||
if (not node.attributes.has_key('align') or
|
||||
if (not 'align' in node.attributes or
|
||||
node.attributes['align'] == 'center'):
|
||||
# centering does not add vertical space like center.
|
||||
align = '\n\\centering'
|
||||
@ -1154,7 +1154,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.no_contractions -= 1
|
||||
if self.in_title:
|
||||
self.body.append(r'\texttt{%s}' % content)
|
||||
elif node.has_key('role') and node['role'] == 'samp':
|
||||
elif node.get('role') == 'samp':
|
||||
self.body.append(r'\samp{%s}' % content)
|
||||
else:
|
||||
self.body.append(r'\code{%s}' % content)
|
||||
@ -1183,10 +1183,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
code = self.verbatim.rstrip('\n')
|
||||
lang = self.hlsettingstack[-1][0]
|
||||
linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
|
||||
if node.has_key('language'):
|
||||
if 'language' in node:
|
||||
# code-block directives
|
||||
lang = node['language']
|
||||
if node.has_key('linenos'):
|
||||
if 'linenos' in node:
|
||||
linenos = node['linenos']
|
||||
hlcode = self.highlighter.highlight_block(code, lang, linenos)
|
||||
# workaround for Unicode issue
|
||||
|
Loading…
Reference in New Issue
Block a user