pep8 fixes

This commit is contained in:
Georg Brandl 2015-03-08 16:28:23 +01:00
parent 8bc5823724
commit 18b6843696
9 changed files with 40 additions and 34 deletions

View File

@ -112,8 +112,8 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs):
text += '\n'
submods = [path.splitext(sub)[0] for sub in py_files
if not shall_skip(path.join(root, sub), opts)
and sub != INITPY]
if not shall_skip(path.join(root, sub), opts) and
sub != INITPY]
if submods:
text += format_heading(2, 'Submodules')
if opts.separatemodules:
@ -212,8 +212,8 @@ def recurse_tree(rootpath, excludes, opts):
exclude_prefixes = ('.',)
else:
exclude_prefixes = ('.', '_')
subs[:] = sorted(sub for sub in subs if not sub.startswith(exclude_prefixes)
and not is_excluded(path.join(root, sub), excludes))
subs[:] = sorted(sub for sub in subs if not sub.startswith(exclude_prefixes) and
not is_excluded(path.join(root, sub), excludes))
if is_pkg:
# we are in a package with something to document

View File

@ -263,8 +263,8 @@ class Sphinx(object):
self.builder.compile_update_catalogs()
self.builder.build_update()
status = (self.statuscode == 0
and 'succeeded' or 'finished with problems')
status = (self.statuscode == 0 and
'succeeded' or 'finished with problems')
if self._warncount:
self.info(bold('build %s, %s warning%s.' %
(status, self._warncount,
@ -487,7 +487,8 @@ class Sphinx(object):
def emit(self, event, *args):
try:
self.debug2('[app] emitting event: %r%s', event, repr(args)[:100])
except Exception: # not every object likes to be repr()'d (think
except Exception:
# not every object likes to be repr()'d (think
# random stuff coming via autodoc)
pass
results = []

View File

@ -10,7 +10,6 @@
"""
from __future__ import print_function
import os
import sys
import optparse
import traceback

View File

@ -139,8 +139,8 @@ class Config(object):
applehelp_dev_region = ('en-us', 'applehelp'),
applehelp_bundle_version = ('1', 'applehelp'),
applehelp_icon = (None, 'applehelp'),
applehelp_kb_product = (lambda self: '%s-%s' \
% (make_filename(self.project), self.release),
applehelp_kb_product = (lambda self: '%s-%s' %
(make_filename(self.project), self.release),
'applehelp'),
applehelp_kb_url = (None, 'applehelp'),
applehelp_remote_url = (None, 'applehelp'),
@ -298,13 +298,13 @@ class Config(object):
current = self[name]
if type(current) is type(default):
continue
common_bases = (set(type(current).__bases__ + (type(current),))
& set(type(default).__bases__))
common_bases = (set(type(current).__bases__ + (type(current),)) &
set(type(default).__bases__))
common_bases.discard(object)
if common_bases:
continue # at least we share a non-trivial base class
warn("the config value %r has type `%s', defaults to `%s.'"
% (name, type(current).__name__, type(default).__name__))
warn("the config value %r has type `%s', defaults to `%s.'" %
(name, type(current).__name__, type(default).__name__))
def check_unicode(self, warn):
# check all string values for non-ASCII characters in bytestrings,
@ -313,8 +313,7 @@ class Config(object):
if isinstance(value, binary_type) and nonascii_re.search(value):
warn('the config value %r is set to a string with non-ASCII '
'characters; this can lead to Unicode errors occurring. '
'Please use Unicode strings, e.g. %r.' % (name, u'Content')
)
'Please use Unicode strings, e.g. %r.' % (name, u'Content'))
def init_values(self, warn):
config = self._raw_config

View File

@ -349,7 +349,7 @@ class BuildEnvironment:
fnset.discard(docname)
if not fnset:
del self.files_to_rebuild[subfn]
for key, (fn, _) in list(self.citations.items()):
for key, (fn, _ignore) in list(self.citations.items()):
if fn == docname:
del self.citations[key]
for version, changes in self.versionchanges.items():
@ -1473,8 +1473,8 @@ class BuildEnvironment:
toplevel[1][:] = subtrees
# resolve all sub-toctrees
for subtocnode in toc.traverse(addnodes.toctree):
if not (subtocnode.get('hidden', False)
and not includehidden):
if not (subtocnode.get('hidden', False) and
not includehidden):
i = subtocnode.parent.index(subtocnode) + 1
for item in _entries_from_toctree(
subtocnode, [refdoc] + parents,
@ -1939,8 +1939,8 @@ class BuildEnvironment:
else:
# get all other symbols under one heading
return _('Symbols')
return [(key, list(group))
for (key, group) in groupby(newlist, keyfunc2)]
return [(key_, list(group))
for (key_, group) in groupby(newlist, keyfunc2)]
def collect_relations(self):
relations = {}

View File

@ -27,12 +27,14 @@ def _tobool(val):
return val.lower() in ('true', '1', 'yes', 'on')
return bool(val)
def _toint(val):
try:
return int(val)
except ValueError:
return 0
def accesskey(context, key):
"""Helper to output each access key only once."""
if '_accesskeys' not in context:
@ -42,11 +44,14 @@ def accesskey(context, key):
return 'accesskey="%s"' % key
return ''
class idgen(object):
def __init__(self):
self.id = 0
def current(self):
return self.id
def __next__(self):
self.id += 1
return self.id
@ -71,6 +76,7 @@ class SphinxFileSystemLoader(FileSystemLoader):
f.close()
mtime = path.getmtime(filename)
def uptodate():
try:
return path.getmtime(filename) == mtime
@ -80,7 +86,6 @@ class SphinxFileSystemLoader(FileSystemLoader):
raise TemplateNotFound(template)
class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
"""
Interfaces the rendering environment of jinja2 for use in Sphinx.

View File

@ -18,8 +18,6 @@ import time
from os import path
from io import open
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
# try to import readline, unix specific enhancement
try:
import readline
@ -41,6 +39,8 @@ from sphinx.util.console import purple, bold, red, turquoise, \
nocolor, color_terminal
from sphinx.util import texescape
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
# function to get input from terminal -- overridden by the test suite
term_input = input

View File

@ -166,6 +166,8 @@ TRANSLATABLE_NODES = {
'index': addnodes.index,
'image': nodes.image,
}
class ExtraTranslatableNodes(Transform):
"""
make nodes translatable