jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Fix indentation errors E122 and E127
......................................................................
[IMPROV] Fix indentation errors E122 and E127
This also adds docstrings to all methods of the replace script also adding it
to the mandatory list of the tox file.
Change-Id: I7348bf135cdb9ea4ef24677f8de359ba717200a9
---
M docs/conf.py
M pywikibot/data/wikidataquery.py
M pywikibot/flow.py
M scripts/replace.py
M tox.ini
5 files changed, 35 insertions(+), 25 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 64c3114..d1263ad 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -175,16 +175,7 @@
# -- Options for LaTeX output --------------------------------------------------
-latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-# 'papersize': 'letterpaper',
-
-# The font size ('10pt', '11pt' or '12pt').
-# 'pointsize': '10pt',
-
-# Additional stuff for the LaTeX preamble.
-# 'preamble': '',
-}
+latex_elements = {}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
diff --git a/pywikibot/data/wikidataquery.py b/pywikibot/data/wikidataquery.py
index 8a40510..59cb48a 100644
--- a/pywikibot/data/wikidataquery.py
+++ b/pywikibot/data/wikidataquery.py
@@ -340,14 +340,14 @@
def validate(self):
"""Validate that the item, forward and reverse are all
ints."""
return (self.isOrContainsOnlyTypes(self.item, int) and
- self.isOrContainsOnlyTypes(self.forward, int) and
- self.isOrContainsOnlyTypes(self.reverse, int))
+ self.isOrContainsOnlyTypes(self.forward, int) and
+ self.isOrContainsOnlyTypes(self.reverse, int))
def __str__(self):
"""Return the query string for the API."""
return "%s[%s][%s][%s]" % (self.queryType, self.formatList(self.item),
- self.formatList(self.forward),
- self.formatList(self.reverse))
+ self.formatList(self.forward),
+ self.formatList(self.reverse))
class Around(Query):
@@ -474,7 +474,7 @@
"""
def __init__(self, host="https://wdq.wmflabs.org", cacheDir=None,
- cacheMaxAge=60):
+ cacheMaxAge=60):
"""Constructor."""
self.host = host
self.cacheMaxAge = cacheMaxAge
@@ -483,7 +483,7 @@
self.cacheDir = cacheDir
else:
self.cacheDir = os.path.join(tempfile.gettempdir(),
- "wikidataquery_cache")
+ "wikidataquery_cache")
def getUrl(self, queryStr):
"""Get the URL given the query string."""
@@ -535,7 +535,7 @@
data = pickle.load(f)
except pickle.UnpicklingError:
pywikibot.warning(u"Couldn't read cached data from
%s"
- % cacheFile)
+ % cacheFile)
data = None
return data
diff --git a/pywikibot/flow.py b/pywikibot/flow.py
index f9ba1fc..27c59ce 100644
--- a/pywikibot/flow.py
+++ b/pywikibot/flow.py
@@ -104,8 +104,8 @@
return new_params
def topics(self, format='wikitext', limit=100, sort_by='newest',
- offset=None, offset_uuid='', reverse=False,
- include_offset=False, toc_only=False):
+ offset=None, offset_uuid='', reverse=False,
+ include_offset=False, toc_only=False):
"""Load this board's topics.
@param format: The content format to request the data in.
diff --git a/scripts/replace.py b/scripts/replace.py
index 6c5e97c..aa3b6ed 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -166,6 +166,7 @@
def precompile_exceptions(exceptions, use_regex, flags):
+ """Compile the exceptions with the given flags."""
if not exceptions:
return
for exceptionCategory in [
@@ -183,6 +184,7 @@
"""The replacement instructions."""
def __init__(self, old, new, edit_summary=None, default_summary=True):
+ """Create a basic replacement instance."""
self.old = old
self.old_regex = None
self.new = new
@@ -191,6 +193,7 @@
@property
def edit_summary(self):
+ """Return the edit summary for this fix."""
return self._edit_summary
@property
@@ -219,6 +222,7 @@
return None
def _compile(self, use_regex, flags):
+ """Compile the search text without modifying the
flags."""
# This does not update use_regex and flags depending on this instance
if not use_regex:
self.old_regex = re.escape(self.old)
@@ -227,6 +231,7 @@
self.old_regex = re.compile(self.old_regex, flags)
def compile(self, use_regex, flags):
+ """Compile the search text."""
# Set the regular expression flags
flags |= re.UNICODE
@@ -247,6 +252,7 @@
def __init__(self, old, new, use_regex=None, exceptions=None,
case_insensitive=None, edit_summary=None,
default_summary=True):
+ """Create a single replacement entry unrelated to a
fix."""
super(Replacement, self).__init__(old, new, edit_summary,
default_summary)
self._use_regex = use_regex
@@ -264,13 +270,16 @@
@property
def case_insensitive(self):
+ """Return whether the search text is case
insensitive."""
return self._case_insensitive
@property
def use_regex(self):
+ """Return whether the search text is using
regex."""
return self._use_regex
def _compile(self, use_regex, flags):
+ """Compile the search regex and exceptions."""
super(Replacement, self)._compile(use_regex, flags)
precompile_exceptions(self.exceptions, use_regex, flags)
@@ -291,6 +300,7 @@
def __init__(self, use_regex, exceptions, case_insensitive, edit_summary,
name):
+ """Create a fix list which can contain multiple
replacements."""
super(ReplacementList, self).__init__()
self.use_regex = use_regex
self._exceptions = exceptions
@@ -300,6 +310,7 @@
self.name = name
def _compile_exceptions(self, use_regex, flags):
+ """Compile the exceptions if not already done."""
if not self.exceptions and self._exceptions is not None:
self.exceptions = dict(self._exceptions)
precompile_exceptions(self.exceptions, use_regex, flags)
@@ -311,24 +322,29 @@
def __init__(self, old, new, fix_set, edit_summary=None,
default_summary=True):
+ """Create a replacement entry inside a fix set."""
super(ReplacementListEntry, self).__init__(old, new, edit_summary,
default_summary)
self.fix_set = fix_set
@property
def case_insensitive(self):
+ """Return whether the fix set is case
insensitive."""
return self.fix_set.case_insensitive
@property
def use_regex(self):
+ """Return whether the fix set is using regex."""
return self.fix_set.use_regex
@property
def exceptions(self):
+ """Return the exceptions of the fix set."""
return self.fix_set.exceptions
@property
def edit_summary(self):
+ """Return this entry's edit summary or the fix's
summary."""
if self._edit_summary is None:
return self.fix_set.edit_summary
else:
@@ -348,6 +364,7 @@
return self.fix_set
def _compile(self, use_regex, flags):
+ """Compile the search regex and the fix's
exceptions."""
super(ReplacementListEntry, self)._compile(use_regex, flags)
self.fix_set._compile_exceptions(use_regex, flags)
@@ -504,7 +521,7 @@
if len(replacement) != 2:
raise ValueError('Replacement number {0} does not have '
'exactly two elements: {1}'.format(
- i, replacement))
+ i, replacement))
# Replacement assumes it gets strings but it's already compiled
replacements[i] = Replacement.from_compiled(replacement[0],
replacement[1])
@@ -602,6 +619,7 @@
return new_text
def doReplacements(self, original_text, page=None):
+ """Apply replacements to the given text and
page."""
if page is None:
pywikibot.warn(
'You must pass the target page as the "page" parameter to
'
@@ -978,12 +996,12 @@
if chars.contains_invisible(replacement[0]):
pywikibot.warning('The old string "{0}" contains formatting
'
'characters like U+200E'.format(
- chars.replace_invisible(replacement[0])))
+ chars.replace_invisible(replacement[0])))
if (not callable(replacement[1]) and
chars.contains_invisible(replacement[1])):
pywikibot.warning('The new string "{0}" contains formatting
'
'characters like U+200E'.format(
- chars.replace_invisible(replacement[1])))
+ chars.replace_invisible(replacement[1])))
replacement_set.append(ReplacementListEntry(
old=replacement[0],
new=replacement[1],
diff --git a/tox.ini b/tox.ini
index dcac433..6a052c3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -31,6 +31,7 @@
[testenv:flake8-docstrings-mandatory]
commands = flake8 \
+ docs/conf.py \
ez_setup.py \
generate_user_files.py \
pwb.py \
@@ -42,13 +43,12 @@
pywikibot/compat/ \
pywikibot/config2.py \
pywikibot/daemonize.py \
- pywikibot/data/__init__.py \
- pywikibot/data/api.py \
- pywikibot/data/wikistats.py \
+ pywikibot/data/ \
pywikibot/diff.py \
pywikibot/echo.py \
pywikibot/editor.py \
pywikibot/exceptions.py \
+ pywikibot/flow.py \
pywikibot/interwiki_graph.py \
pywikibot/families/ \
pywikibot/fixes.py \
@@ -109,6 +109,7 @@
scripts/patrol.py \
scripts/piper.py \
scripts/protect.py \
+ scripts/replace.py \
scripts/selflink.py \
scripts/shell.py \
scripts/spamremove.py \
--
To view, visit
https://gerrit.wikimedia.org/r/231887
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7348bf135cdb9ea4ef24677f8de359ba717200a9
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Mattflaschen <mflaschen(a)wikimedia.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>