summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-01-12 13:03:53 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2017-01-12 13:03:53 +0900
commit38d6c34f35c60689f22d1f71ce650ca1e3005ec4 (patch)
tree0677416d0de03a53ee7d348289d8560e511c2bed /sphinx/util
parentef912eb9a3e923e80d5c6a08fda4597a65d591aa (diff)
parent478306e052d9711170b1fbe63635edef02853484 (diff)
downloadsphinx-git-38d6c34f35c60689f22d1f71ce650ca1e3005ec4.tar.gz
Merge branch 'stable'
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/__init__.py12
-rw-r--r--sphinx/util/console.py4
-rw-r--r--sphinx/util/docutils.py2
-rw-r--r--sphinx/util/jsdump.py4
-rw-r--r--sphinx/util/nodes.py8
-rw-r--r--sphinx/util/osutil.py4
-rw-r--r--sphinx/util/parallel.py4
-rw-r--r--sphinx/util/stemmer/porter.py16
8 files changed, 27 insertions, 27 deletions
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index ff5e35fa4..f2cb2f24b 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -110,7 +110,7 @@ def get_matching_docs(dirname, suffixes, exclude_matchers=()):
for filename in get_matching_files(dirname, exclude_matchers):
for suffixpattern in suffixpatterns:
if fnmatch.fnmatch(filename, suffixpattern): # type: ignore
- yield filename[:-len(suffixpattern)+1]
+ yield filename[:-len(suffixpattern) + 1]
break
@@ -183,7 +183,7 @@ def copy_static_entry(source, targetdir, builder, context={},
if path.isdir(path.join(source, entry)):
newtarget = path.join(targetdir, entry)
copy_static_entry(path.join(source, entry), newtarget,
- builder, context, level=level+1,
+ builder, context, level=level + 1,
exclude_matchers=exclude_matchers)
@@ -380,9 +380,9 @@ def parselinenos(spec, total):
if len(begend) > 2:
raise ValueError
if len(begend) == 1:
- items.append(int(begend[0])-1)
+ items.append(int(begend[0]) - 1)
else:
- start = (begend[0] == '') and 0 or int(begend[0])-1
+ start = (begend[0] == '') and 0 or int(begend[0]) - 1
end = (begend[1] == '') and total or int(begend[1])
items.extend(range(start, end))
except Exception:
@@ -420,13 +420,13 @@ def rpartition(s, t):
"""Similar to str.rpartition from 2.5, but doesn't return the separator."""
i = s.rfind(t)
if i != -1:
- return s[:i], s[i+len(t):]
+ return s[:i], s[i + len(t):]
return '', s
def split_into(n, type, value):
"""Split an index entry into a given number of parts at semicolons."""
- parts = [x.strip() for x in value.split(';', n-1)]
+ parts = [x.strip() for x in value.split(';', n - 1)]
if sum(1 for part in parts if part) < n:
raise ValueError('invalid %s index entry %r' % (type, value))
return parts
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index f4e03775f..b418edfb8 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -123,8 +123,8 @@ _colors = [
]
for i, (dark, light) in enumerate(_colors):
- codes[dark] = '\x1b[%im' % (i+30)
- codes[light] = '\x1b[%i;01m' % (i+30)
+ codes[dark] = '\x1b[%im' % (i + 30)
+ codes[light] = '\x1b[%i;01m' % (i + 30)
_orig_codes = codes.copy()
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py
index ad80ac7a7..ae106c190 100644
--- a/sphinx/util/docutils.py
+++ b/sphinx/util/docutils.py
@@ -31,7 +31,7 @@ if False:
from sphinx.environment import BuildEnvironment # NOQA
-__version_info__ = tuple(map(int, docutils.__version__.split('.')))
+__version_info__ = tuple(map(int, docutils.__version__.split('.')))
@contextmanager
diff --git a/sphinx/util/jsdump.py b/sphinx/util/jsdump.py
index 330b5c0ee..7c60a1b70 100644
--- a/sphinx/util/jsdump.py
+++ b/sphinx/util/jsdump.py
@@ -20,8 +20,8 @@ if False:
# For type annotation
from typing import Any, IO, Union # NOQA
-_str_re = re.compile(r'"(\\\\|\\"|[^"])*"')
-_int_re = re.compile(r'\d+')
+_str_re = re.compile(r'"(\\\\|\\"|[^"])*"')
+_int_re = re.compile(r'\d+')
_name_re = re.compile(r'[a-zA-Z_]\w*')
_nameonly_re = re.compile(r'[a-zA-Z_][a-zA-Z0-9_]*$')
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index 4c574c242..e50de9630 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -266,15 +266,15 @@ def process_index_entry(entry, targetid):
main = 'main'
entry = entry[1:].lstrip()
for type in pairindextypes:
- if entry.startswith(type+':'):
- value = entry[len(type)+1:].strip()
+ if entry.startswith(type + ':'):
+ value = entry[len(type) + 1:].strip()
value = pairindextypes[type] + '; ' + value
indexentries.append(('pair', value, targetid, main, None))
break
else:
for type in indextypes:
- if entry.startswith(type+':'):
- value = entry[len(type)+1:].strip()
+ if entry.startswith(type + ':'):
+ value = entry[len(type) + 1:].strip()
if type == 'double':
type = 'pair'
indexentries.append((type, value, targetid, main, None))
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py
index 5561f0ddb..ba2e1abf4 100644
--- a/sphinx/util/osutil.py
+++ b/sphinx/util/osutil.py
@@ -30,7 +30,7 @@ if False:
# Errnos that we need.
EEXIST = getattr(errno, 'EEXIST', 0)
ENOENT = getattr(errno, 'ENOENT', 0)
-EPIPE = getattr(errno, 'EPIPE', 0)
+EPIPE = getattr(errno, 'EPIPE', 0)
EINVAL = getattr(errno, 'EINVAL', 0)
# SEP separates path elements in the canonical file names
@@ -73,7 +73,7 @@ def relative_uri(base, to):
# Special case: relative_uri('f/index.html','f/') should
# return './', not ''
return '.' + SEP
- return ('..' + SEP) * (len(b2)-1) + SEP.join(t2)
+ return ('..' + SEP) * (len(b2) - 1) + SEP.join(t2)
def ensuredir(path):
diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py
index 1d97a511c..fc691bee1 100644
--- a/sphinx/util/parallel.py
+++ b/sphinx/util/parallel.py
@@ -140,11 +140,11 @@ def make_chunks(arguments, nproc, maxbatch=10):
chunksize = nargs // nproc
if chunksize >= maxbatch:
# try to improve batch size vs. number of batches
- chunksize = int(sqrt(nargs/nproc * maxbatch))
+ chunksize = int(sqrt(nargs / nproc * maxbatch))
if chunksize == 0:
chunksize = 1
nchunks, rest = divmod(nargs, chunksize)
if rest:
nchunks += 1
# partition documents in "chunks" that will be written by one Process
- return [arguments[i*chunksize:(i+1)*chunksize] for i in range(nchunks)]
+ return [arguments[i * chunksize:(i + 1) * chunksize] for i in range(nchunks)]
diff --git a/sphinx/util/stemmer/porter.py b/sphinx/util/stemmer/porter.py
index 7cff74b6c..5f8d14ed6 100644
--- a/sphinx/util/stemmer/porter.py
+++ b/sphinx/util/stemmer/porter.py
@@ -107,7 +107,7 @@ class PorterStemmer(object):
"""doublec(j) is TRUE <=> j,(j-1) contain a double consonant."""
if j < (self.k0 + 1):
return 0
- if (self.b[j] != self.b[j-1]):
+ if (self.b[j] != self.b[j - 1]):
return 0
return self.cons(j)
@@ -120,8 +120,8 @@ class PorterStemmer(object):
cav(e), lov(e), hop(e), crim(e), but
snow, box, tray.
"""
- if i < (self.k0 + 2) or not self.cons(i) or self.cons(i-1) \
- or not self.cons(i-2):
+ if i < (self.k0 + 2) or not self.cons(i) or self.cons(i - 1) \
+ or not self.cons(i - 2):
return 0
ch = self.b[i]
if ch == 'w' or ch == 'x' or ch == 'y':
@@ -135,7 +135,7 @@ class PorterStemmer(object):
return 0
if length > (self.k - self.k0 + 1):
return 0
- if self.b[self.k-length+1:self.k+1] != s:
+ if self.b[self.k - length + 1:self.k + 1] != s:
return 0
self.j = self.k - length
return 1
@@ -144,7 +144,7 @@ class PorterStemmer(object):
"""setto(s) sets (j+1),...k to the characters in the string s,
readjusting k."""
length = len(s)
- self.b = self.b[:self.j+1] + s + self.b[self.j+length+1:]
+ self.b = self.b[:self.j + 1] + s + self.b[self.j + length + 1:]
self.k = self.j + length
def r(self, s):
@@ -203,7 +203,7 @@ class PorterStemmer(object):
"""step1c() turns terminal y to i when there is another vowel in
the stem."""
if (self.ends("y") and self.vowelinstem()):
- self.b = self.b[:self.k] + 'i' + self.b[self.k+1:]
+ self.b = self.b[:self.k] + 'i' + self.b[self.k + 1:]
def step2(self):
"""step2() maps double suffices to single ones.
@@ -376,7 +376,7 @@ class PorterStemmer(object):
self.j = self.k
if self.b[self.k] == 'e':
a = self.m()
- if a > 1 or (a == 1 and not self.cvc(self.k-1)):
+ if a > 1 or (a == 1 and not self.cvc(self.k - 1)):
self.k = self.k - 1
if self.b[self.k] == 'l' and self.doublec(self.k) and self.m() > 1:
self.k = self.k - 1
@@ -408,4 +408,4 @@ class PorterStemmer(object):
self.step3()
self.step4()
self.step5()
- return self.b[self.k0:self.k+1]
+ return self.b[self.k0:self.k + 1]