Some pylint nits.

This commit is contained in:
Georg Brandl 2008-05-04 16:17:31 +00:00
parent d93b236545
commit 407a0c47c1
9 changed files with 27 additions and 25 deletions

View File

@ -8,7 +8,6 @@ all: clean-pyc check
check: check:
@$(PYTHON) utils/check_sources.py -i sphinx/style/jquery.js sphinx @$(PYTHON) utils/check_sources.py -i sphinx/style/jquery.js sphinx
@$(PYTHON) utils/check_sources.py converter
clean: clean-pyc clean-patchfiles clean: clean-pyc clean-patchfiles

View File

@ -109,7 +109,8 @@ def main(argv=sys.argv):
key, val = val.split('=') key, val = val.split('=')
try: try:
val = int(val) val = int(val)
except: pass except ValueError:
pass
confoverrides[key] = val confoverrides[key] = val
elif opt == '-N': elif opt == '-N':
nocolor() nocolor()
@ -158,7 +159,8 @@ def main(argv=sys.argv):
print >>sys.stderr, ('Please also report this if it was a user ' print >>sys.stderr, ('Please also report this if it was a user '
'error, so that a better error message ' 'error, so that a better error message '
'can be provided next time.') 'can be provided next time.')
print >>sys.stderr, 'Send reports to sphinx-dev@googlegroups.com. Thanks!' print >>sys.stderr, ('Send reports to sphinx-dev@googlegroups.com. '
'Thanks!')
return 1 return 1

View File

@ -9,7 +9,6 @@
:license: BSD. :license: BSD.
""" """
import sys
import codecs import codecs
from os import path from os import path

View File

@ -226,11 +226,6 @@ class TemplateBridge(object):
that renders templates given a template name and a context. that renders templates given a template name and a context.
""" """
def __init__(self):
"""
Initialize the class.
"""
def init(self, builder): def init(self, builder):
""" """
Called by the builder to initialize the template system. *builder* Called by the builder to initialize the template system. *builder*

View File

@ -25,7 +25,7 @@ from docutils.frontend import OptionParser
from docutils.readers.doctree import Reader as DoctreeReader from docutils.readers.doctree import Reader as DoctreeReader
from sphinx import addnodes from sphinx import addnodes
from sphinx.util import mtimes_of_files, ensuredir, relative_uri, SEP, os_path from sphinx.util import ensuredir, relative_uri, SEP, os_path
from sphinx.htmlhelp import build_hhx from sphinx.htmlhelp import build_hhx
from sphinx.htmlwriter import HTMLWriter, HTMLTranslator, SmartyPantsHTMLTranslator from sphinx.htmlwriter import HTMLWriter, HTMLTranslator, SmartyPantsHTMLTranslator
from sphinx.latexwriter import LaTeXWriter from sphinx.latexwriter import LaTeXWriter
@ -775,7 +775,7 @@ class LaTeXBuilder(Builder):
subtree = process_tree(includefile, subtree = process_tree(includefile,
self.env.get_doctree(includefile)) self.env.get_doctree(includefile))
self.docnames.add(includefile) self.docnames.add(includefile)
except: except Exception:
self.warn('%s: toctree contains ref to nonexisting file %r' % self.warn('%s: toctree contains ref to nonexisting file %r' %
(docname, includefile)) (docname, includefile))
else: else:

View File

@ -77,7 +77,7 @@ def desc_index_text(desctype, currmodule, name):
elif desctype == 'method': elif desctype == 'method':
try: try:
clsname, methname = name.rsplit('.', 1) clsname, methname = name.rsplit('.', 1)
except: except ValueError:
if currmodule: if currmodule:
return '%s() (in module %s)' % (name, currmodule) return '%s() (in module %s)' % (name, currmodule)
else: else:
@ -89,7 +89,7 @@ def desc_index_text(desctype, currmodule, name):
elif desctype == 'attribute': elif desctype == 'attribute':
try: try:
clsname, attrname = name.rsplit('.', 1) clsname, attrname = name.rsplit('.', 1)
except: except ValueError:
if currmodule: if currmodule:
return '%s (in module %s)' % (name, currmodule) return '%s (in module %s)' % (name, currmodule)
else: else:
@ -133,7 +133,8 @@ def parse_py_signature(signode, sig, desctype, env):
* it is added to the full name (return value) if not present * it is added to the full name (return value) if not present
""" """
m = py_sig_re.match(sig) m = py_sig_re.match(sig)
if m is None: raise ValueError if m is None:
raise ValueError
classname, name, arglist = m.groups() classname, name, arglist = m.groups()
add_module = True add_module = True
@ -177,14 +178,17 @@ def parse_py_signature(signode, sig, desctype, env):
stack[-1] += opt stack[-1] += opt
stack.append(opt) stack.append(opt)
elif token == ']': elif token == ']':
try: stack.pop() try:
except IndexError: raise ValueError stack.pop()
except IndexError:
raise ValueError
elif not token or token == ',' or token.isspace(): elif not token or token == ',' or token.isspace():
pass pass
else: else:
token = token.strip() token = token.strip()
stack[-1] += addnodes.desc_parameter(token, token) stack[-1] += addnodes.desc_parameter(token, token)
if len(stack) != 1: raise ValueError if len(stack) != 1:
raise ValueError
return fullname, classname return fullname, classname
@ -267,7 +271,8 @@ opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)\s*\((.*)\)')
def parse_opcode_signature(signode, sig): def parse_opcode_signature(signode, sig):
"""Transform an opcode signature into RST nodes.""" """Transform an opcode signature into RST nodes."""
m = opcode_sig_re.match(sig) m = opcode_sig_re.match(sig)
if m is None: raise ValueError if m is None:
raise ValueError
opname, arglist = m.groups() opname, arglist = m.groups()
signode += addnodes.desc_name(opname, opname) signode += addnodes.desc_name(opname, opname)
paramlist = addnodes.desc_parameterlist() paramlist = addnodes.desc_parameterlist()

View File

@ -22,7 +22,7 @@ from string import uppercase
try: try:
import hashlib import hashlib
md5 = hashlib.md5 md5 = hashlib.md5
except: except ImportError:
# 2.4 compatibility # 2.4 compatibility
import md5 import md5
md5 = md5.new md5 = md5.new
@ -701,7 +701,8 @@ class BuildEnvironment:
stream=RedirStream(self._warnfunc)) stream=RedirStream(self._warnfunc))
return doctree return doctree
def get_and_resolve_doctree(self, docname, builder, doctree=None, prune_toctrees=True): def get_and_resolve_doctree(self, docname, builder, doctree=None,
prune_toctrees=True):
"""Read the doctree from the pickle, resolve cross-references and """Read the doctree from the pickle, resolve cross-references and
toctrees and return it.""" toctrees and return it."""
if doctree is None: if doctree is None:
@ -932,7 +933,7 @@ class BuildEnvironment:
if type == 'single': if type == 'single':
try: try:
entry, subentry = string.split(';', 1) entry, subentry = string.split(';', 1)
except: except ValueError:
entry, subentry = string, '' entry, subentry = string, ''
add_entry(entry.strip(), subentry.strip()) add_entry(entry.strip(), subentry.strip())
elif type == 'pair': elif type == 'pair':

View File

@ -155,7 +155,7 @@ def generate_rst(what, name, members, inherited, undoc, add_content, document,
args = '()' args = '()'
else: else:
args = '' args = ''
except: except Exception:
args = '' args = ''
if len(objpath) == 2: if len(objpath) == 2:
qualname = '%s.%s' % (cls, obj) qualname = '%s.%s' % (cls, obj)

View File

@ -326,7 +326,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
try: try:
type, container = d.type.rsplit(' ', 1) type, container = d.type.rsplit(' ', 1)
container = container.rstrip('.') container = container.rstrip('.')
except: except ValueError:
container = '' container = ''
type = d.type type = d.type
t2 = "{%s}{%s}{%s}" % (container, type, d.name) t2 = "{%s}{%s}{%s}" % (container, type, d.name)
@ -454,7 +454,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_entry(self, node): def visit_entry(self, node):
if node.has_key('morerows') or node.has_key('morecols'): if node.has_key('morerows') or node.has_key('morecols'):
raise NotImplementedError('Column or row spanning cells are not implemented.') raise NotImplementedError('Column or row spanning cells are '
'not implemented.')
if self.table.col > 0: if self.table.col > 0:
self.body.append(' & ') self.body.append(' & ')
self.table.col += 1 self.table.col += 1