jenkins-bot has submitted this change and it was merged.
Change subject: Search for scripts in maintenance folder too
......................................................................
Search for scripts in maintenance folder too
- with 38ac04438664 scripts can be found in an archive folder but mainenance
scripts must be started with preleading "maintenance/"
- join paths in the right way; otherwise we could have mixed separators
on windows os.
- simplify test for existing script
Change-Id: I02ed7a5e533eaa33c32cbd77a2c2bdcba567413c
---
M pwb.py
1 file changed, 9 insertions(+), 11 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index 395019e..060fea0 100755
--- a/pwb.py
+++ b/pwb.py
@@ -208,17 +208,15 @@
if not filename.endswith('.py'):
filename += '.py'
if not os.path.exists(filename):
- testpath = os.path.join(os.path.split(__file__)[0],
- 'scripts',
- filename)
- file_package = 'scripts'
- if not os.path.exists(testpath):
- testpath = os.path.join(
- os.path.split(__file__)[0], 'scripts/archive', filename)
- file_package = 'scripts.archive'
-
- if os.path.exists(testpath):
- filename = testpath
+ script_paths = ['scripts',
+ 'scripts.maintenance',
+ 'scripts.archive']
+ for file_package in script_paths:
+ paths = file_package.split('.') + [filename]
+ testpath = os.path.join(_pwb_dir, *paths)
+ if os.path.exists(testpath):
+ filename = testpath
+ break
else:
raise OSError("%s not found!" % filename)
--
To view, visit https://gerrit.wikimedia.org/r/270279
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I02ed7a5e533eaa33c32cbd77a2c2bdcba567413c
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Update mw version number
......................................................................
Update mw version number
Change-Id: I4ffce441cdbd2db56a4b7dc37b655f71c23fe0b5
---
M pywikibot/family.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
Dalba: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 2ad6c73..0bb5c09 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1240,7 +1240,7 @@
Use L{pywikibot.tools.MediaWikiVersion} to compare version strings.
"""
# Here we return the latest mw release for downloading
- return '1.26.3'
+ return '1.27.0'
def force_version(self, code):
"""
--
To view, visit https://gerrit.wikimedia.org/r/303993
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4ffce441cdbd2db56a4b7dc37b655f71c23fe0b5
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Use main account for checking user existence
......................................................................
Use main account for checking user existence
When running a bot using a Special:BotPassword username but no provided
password, use the main account username to check that the user exists
before prompting for the password.
For BotPasswords see https://www.mediawiki.org/wiki/Manual:Bot_passwords
Bug: T142623
Change-Id: I2bf629b3f6b21f375cacdabc2518c7ac0cf3cd49
---
M pywikibot/login.py
1 file changed, 7 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
Dalba: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index df1152c..20f38f7 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -122,21 +122,24 @@
@raises NoUsername: Username doesnt exist in user list.
"""
+ # convert any Special:BotPassword usernames to main account equivalent
+ main_username = self.username.partition('@')[0]
+
try:
- data = self.site.allusers(start=self.username, total=1)
+ data = self.site.allusers(start=main_username, total=1)
user = next(iter(data))
except pywikibot.data.api.APIError as e:
if e.code == 'readapidenied':
pywikibot.warning('Could not check user %s exists on %s'
- % (self.username, self.site))
+ % (main_username, self.site))
return
else:
raise
- if user['name'] != self.username:
+ if user['name'] != main_username:
# Report the same error as server error code NotExists
raise NoUsername('Username \'%s\' does not exist on %s'
- % (self.username, self.site))
+ % (main_username, self.site))
def botAllowed(self):
"""
--
To view, visit https://gerrit.wikimedia.org/r/304060
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2bf629b3f6b21f375cacdabc2518c7ac0cf3cd49
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: tests/family_tests: test should pass when domain is 'localhost:4881'
......................................................................
tests/family_tests: test should pass when domain is 'localhost:4881'
Change-Id: Icda9ffc9f845deb0d0b0f284682a57d7b606e274
---
M tests/family_tests.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/family_tests.py b/tests/family_tests.py
index 440f249..1b536f1 100644
--- a/tests/family_tests.py
+++ b/tests/family_tests.py
@@ -43,7 +43,7 @@
self.assertTrue(iter(f.domains))
for domain in f.domains:
self.assertIsInstance(domain, basestring)
- if domain != 'localhost':
+ if domain.split(':', 1)[0] != 'localhost':
self.assertIn('.', domain)
self.assertEqual(f.name, name)
self.assertIsInstance(f.languages_by_size, list)
--
To view, visit https://gerrit.wikimedia.org/r/293958
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icda9ffc9f845deb0d0b0f284682a57d7b606e274
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Whym <whym(a)whym.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [flake8] Use flake8-comprehensions
......................................................................
[flake8] Use flake8-comprehensions
Change-Id: I77feb4036cb670d19e1bbbd6ea461fa858566901
---
M generate_family_file.py
M pywikibot/data/api.py
M pywikibot/date.py
M pywikibot/page.py
M pywikibot/tools/__init__.py
M pywikibot/tools/formatter.py
M pywikibot/version.py
M scripts/casechecker.py
M scripts/checkimages.py
M scripts/data_ingestion.py
M scripts/protect.py
M tests/archivebot_tests.py
M tox.ini
13 files changed, 55 insertions(+), 57 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_family_file.py b/generate_family_file.py
index ddfe809..5505b69 100755
--- a/generate_family_file.py
+++ b/generate_family_file.py
@@ -9,7 +9,7 @@
print_function, unicode_literals)
#
# (C) Merlijn van Deen, 2010-2013
-# (C) Pywikibot team, 2010-2015
+# (C) Pywikibot team, 2010-2016
#
# Distributed under the terms of the MIT license
#
@@ -81,7 +81,7 @@
print("Determining other languages...", end="")
try:
self.langs = w.langs
- print(u' '.join(sorted([wiki[u'prefix'] for wiki in self.langs])))
+ print(' '.join(sorted(wiki['prefix'] for wiki in self.langs)))
except Exception as e:
self.langs = []
print(e, "; continuing...")
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 66c9aec..c3d95e8 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Interface to Mediawiki's api.php."""
#
-# (C) Pywikibot team, 2007-2015
+# (C) Pywikibot team, 2007-2016
#
# Distributed under the terms of the MIT license.
#
@@ -1049,8 +1049,8 @@
if not self._with_limits:
self.fetch(self.submodules('query', True))
self._with_limits = frozenset(
- [mod for mod in self.query_modules
- if self.parameter('query+' + mod, 'limit')])
+ mod for mod in self.query_modules
+ if self.parameter('query+' + mod, 'limit'))
return self._with_limits
@@ -1907,8 +1907,8 @@
modules = set([self.action])
if modules:
self.site._paraminfo.fetch(modules)
- use_get = all(['mustbeposted' not in self.site._paraminfo[mod]
- for mod in modules])
+ use_get = all('mustbeposted' not in self.site._paraminfo[mod]
+ for mod in modules)
else:
# If modules is empty, just 'meta' was given, which doesn't
# require POSTs, and is required for ParamInfo
diff --git a/pywikibot/date.py b/pywikibot/date.py
index 0592896..c3cb04c 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -7,7 +7,7 @@
# (C) Andre Engels, 2004-2005
# (C) Yuri Astrakhan, 2005-2006 (<Firstname><Lastname>@gmail.com)
# (years/decades/centuries/millenniums str <=> int conversions)
-# (C) Pywikibot team, 2004-2015
+# (C) Pywikibot team, 2004-2016
#
# Distributed under the terms of the MIT license.
#
@@ -263,28 +263,28 @@
# Helper for KN: digits representation
_knDigits = u'೦೧೨೩೪೫೬೭೮೯'
-_knDigitsToLocal = dict([(ord(unicode(i)), _knDigits[i]) for i in range(10)])
-_knLocalToDigits = dict([(ord(_knDigits[i]), unicode(i)) for i in range(10)])
+_knDigitsToLocal = dict((ord(unicode(i)), _knDigits[i]) for i in range(10))
+_knLocalToDigits = dict((ord(_knDigits[i]), unicode(i)) for i in range(10))
# Helper for Urdu/Persian languages
_faDigits = u'۰۱۲۳۴۵۶۷۸۹'
-_faDigitsToLocal = dict([(ord(unicode(i)), _faDigits[i]) for i in range(10)])
-_faLocalToDigits = dict([(ord(_faDigits[i]), unicode(i)) for i in range(10)])
+_faDigitsToLocal = dict((ord(unicode(i)), _faDigits[i]) for i in range(10))
+_faLocalToDigits = dict((ord(_faDigits[i]), unicode(i)) for i in range(10))
# Helper for HI:, MR:
_hiDigits = u'०१२३४५६७८९'
-_hiDigitsToLocal = dict([(ord(unicode(i)), _hiDigits[i]) for i in range(10)])
-_hiLocalToDigits = dict([(ord(_hiDigits[i]), unicode(i)) for i in range(10)])
+_hiDigitsToLocal = dict((ord(unicode(i)), _hiDigits[i]) for i in range(10))
+_hiLocalToDigits = dict((ord(_hiDigits[i]), unicode(i)) for i in range(10))
# Helper for BN:
_bnDigits = u'০১২৩৪৫৬৭৮৯'
-_bnDigitsToLocal = dict([(ord(unicode(i)), _bnDigits[i]) for i in range(10)])
-_bnLocalToDigits = dict([(ord(_bnDigits[i]), unicode(i)) for i in range(10)])
+_bnDigitsToLocal = dict((ord(unicode(i)), _bnDigits[i]) for i in range(10))
+_bnLocalToDigits = dict((ord(_bnDigits[i]), unicode(i)) for i in range(10))
# Helper for GU:
_guDigits = u'૦૧૨૩૪૫૬૭૮૯'
-_guDigitsToLocal = dict([(ord(unicode(i)), _guDigits[i]) for i in range(10)])
-_guLocalToDigits = dict([(ord(_guDigits[i]), unicode(i)) for i in range(10)])
+_guDigitsToLocal = dict((ord(unicode(i)), _guDigits[i]) for i in range(10))
+_guLocalToDigits = dict((ord(_guDigits[i]), unicode(i)) for i in range(10))
def intToLocalDigitsStr(value, digitsToLocalDict):
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 5c5f2e0..4a7f1b9 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1958,7 +1958,7 @@
warn(u'"unprotect" argument of protect() is deprecated',
DeprecationWarning, 2)
protections = dict(
- [(p_type, "") for p_type in self.applicable_protections()])
+ (p_type, "") for p_type in self.applicable_protections())
answer = 'y'
if called_using_deprecated_arg and prompt is None:
prompt = True
@@ -2160,7 +2160,7 @@
"""
# WARNING: may not return all templates used in particularly
# intricate cases such as template substitution
- titles = list(t.title() for t in self.templates())
+ titles = [t.title() for t in self.templates()]
templates = textlib.extract_templates_and_params(self.text)
# backwards-compatibility: convert the dict returned as the second
# element into a list in the format used by old scripts
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 40f7320..e1642dd 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -560,8 +560,8 @@
def run(self):
"""Run the generator and store the results on the queue."""
- iterable = any([hasattr(self.generator, key)
- for key in ['__iter__', '__getitem__']])
+ iterable = any(hasattr(self.generator, key)
+ for key in ('__iter__', '__getitem__'))
if iterable and not self.args and not self.kwargs:
self.__gen = self.generator
else:
diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py
index c53d80a..47f6762 100644
--- a/pywikibot/tools/formatter.py
+++ b/pywikibot/tools/formatter.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Module containing various formatting related utilities."""
#
-# (C) Pywikibot team, 2015
+# (C) Pywikibot team, 2015-2016
#
# Distributed under the terms of the MIT license.
#
@@ -70,7 +70,7 @@
colors = set(colors)
# Dot.product of colors to create all possible combinations of foreground
# and background colors.
- colors |= set(['%s;%s' % (c1, c2) for c1 in colors for c2 in colors])
+ colors |= set('%s;%s' % (c1, c2) for c1 in colors for c2 in colors)
def __init__(self):
"""Create new instance and store the stack depth."""
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 93b13af..bd4d841 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -483,12 +483,11 @@
std_lib_dir = get_python_lib(standard_lib=True)
- root_packages = set([key.split('.')[0]
- for key in modules])
+ root_packages = set(key.split('.')[0] for key in modules)
- builtin_packages = set([name.split('.')[0] for name in root_packages
- if name in sys.builtin_module_names or
- '_' + name in sys.builtin_module_names])
+ builtin_packages = set(name.split('.')[0] for name in root_packages
+ if name in sys.builtin_module_names or
+ '_' + name in sys.builtin_module_names)
# Improve performance by removing builtins from the list if possible.
if builtins is False:
diff --git a/scripts/casechecker.py b/scripts/casechecker.py
index 1daccca..925e0a9 100755
--- a/scripts/casechecker.py
+++ b/scripts/casechecker.py
@@ -172,22 +172,20 @@
self.titleList = [self.Page(t) for t in f]
self.failedTitles += '.failed'
- self.lclToLatDict = dict([(ord(self.localSuspects[i]),
- self.latinSuspects[i])
- for i in xrange(len(self.localSuspects))])
- self.latToLclDict = dict([(ord(self.latinSuspects[i]),
- self.localSuspects[i])
- for i in xrange(len(self.localSuspects))])
+ self.lclToLatDict = dict(
+ (ord(self.localSuspects[i]), self.latinSuspects[i])
+ for i in xrange(len(self.localSuspects)))
+ self.latToLclDict = dict(
+ (ord(self.latinSuspects[i]), self.localSuspects[i])
+ for i in xrange(len(self.localSuspects)))
if self.localKeyboard is not None:
self.lclToLatKeybDict = dict(
- [(ord(self.localKeyboard[i]),
- self.latinKeyboard[i])
- for i in xrange(len(self.localKeyboard))])
+ (ord(self.localKeyboard[i]), self.latinKeyboard[i])
+ for i in xrange(len(self.localKeyboard)))
self.latToLclKeybDict = dict(
- [(ord(self.latinKeyboard[i]),
- self.localKeyboard[i])
- for i in xrange(len(self.localKeyboard))])
+ (ord(self.latinKeyboard[i]), self.localKeyboard[i])
+ for i in xrange(len(self.localKeyboard)))
else:
self.lclToLatKeybDict = {}
self.latToLclKeybDict = {}
@@ -467,9 +465,9 @@
badWords = list(self.FindBadWords(title))
if len(badWords) > 0:
# Allow known words, allow any roman numerals with local suffixes
- badWords = set([i for i in badWords
- if i not in self.knownWords and
- self.romanNumSfxPtrn.match(i) is not None])
+ badWords = set(i for i in badWords
+ if i not in self.knownWords and
+ self.romanNumSfxPtrn.match(i) is not None)
if len(badWords) == 0 or self.Page(title).isImage():
return
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 02e9a0b..e8df222 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -548,8 +548,8 @@
self.com = i18n.translate(self.site, msg_comm10, fallback=True)
hiddentemplatesRaw = i18n.translate(self.site, HiddenTemplate)
self.hiddentemplates = set(
- [pywikibot.Page(self.site, tmp, ns=self.site.namespaces.TEMPLATE)
- for tmp in hiddentemplatesRaw])
+ pywikibot.Page(self.site, tmp, ns=self.site.namespaces.TEMPLATE)
+ for tmp in hiddentemplatesRaw)
self.pageHidden = i18n.translate(self.site, PageWithHiddenTemplates)
self.pageAllowed = i18n.translate(self.site, PageWithAllowedTemplates)
self.comment = i18n.twtranslate(self.site.lang,
diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index 40516cf..836d1af 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -8,7 +8,7 @@
python pwb.py data_ingestion -csvdir:local_dir/ -page:config_page
"""
#
-# (C) Pywikibot team, 2013
+# (C) Pywikibot team, 2013-2016
#
# Distributed under the terms of the MIT license.
#
@@ -105,9 +105,8 @@
"""
hashObject = hashlib.sha1()
hashObject.update(self.downloadPhoto().getvalue())
- return list(
- page.title(withNamespace=False) for page in
- self.site.allimages(sha1=base64.b16encode(hashObject.digest())))
+ return [page.title(withNamespace=False) for page in
+ self.site.allimages(sha1=base64.b16encode(hashObject.digest()))]
def getTitle(self, fmt):
"""
diff --git a/scripts/protect.py b/scripts/protect.py
index 222f19e..4441241 100755
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -235,8 +235,8 @@
protection_levels)
# set the default value for all
# None (not the string 'none') will be ignored by Site.protect()
- combined_protections = dict([
- (p_type, default_level) for p_type in protection_types])
+ combined_protections = dict(
+ (p_type, default_level) for p_type in protection_types)
for p_type, level in protections.items():
level = check_protection_level(p_type, level, protection_levels,
default_level)
diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py
index 4cf2e43..467c4c1 100644
--- a/tests/archivebot_tests.py
+++ b/tests/archivebot_tests.py
@@ -40,8 +40,8 @@
"""Test archivebot script on 40+ Wikipedia sites."""
family = 'wikipedia'
- sites = dict([(code, {'family': 'wikipedia', 'code': code})
- for code in THREADS])
+ sites = dict((code, {'family': 'wikipedia', 'code': code})
+ for code in THREADS)
cached = True
@@ -107,8 +107,8 @@
"""
family = 'wikipedia'
- sites = dict([(code, {'family': 'wikipedia', 'code': code})
- for code in THREADS_WITH_UPDATED_FORMAT])
+ sites = dict((code, {'family': 'wikipedia', 'code': code})
+ for code in THREADS_WITH_UPDATED_FORMAT)
cached = True
diff --git a/tox.ini b/tox.ini
index 10956ef..e87318d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -56,6 +56,7 @@
flake8-docstrings>=0.2.6
flake8-putty>=0.3.2
flake8-coding
+ flake8-comprehensions
flake8-future-import
flake8-string-format
flake8-import-order
@@ -122,12 +123,13 @@
# H301,I100,I101: import order rules; Pywikibot uses rules H306 and I201
# The following are to be fixed
+# C401, C402, C405: does not work with py 2.6
# D102: Missing docstring in public method
# D103: Missing docstring in public function
# E402: module level import not at top of file; see T87409
# H201: Except: format
# P102,P103: string does contain unindexed parameters; see I36355923
-ignore = E402,D105,D211,FI10,FI12,FI13,FI15,FI16,FI17,FI5,H101,H201,H236,H301,H404,H405,I100,I101
+ignore = C401,C402,C405,E402,D105,D211,FI10,FI12,FI13,FI15,FI16,FI17,FI5,H101,H201,H236,H301,H404,H405,I100,I101
exclude = .tox,.git,./*.egg,ez_setup.py,build,externals,user-config.py,./scripts/i18n/*
min-version = 2.6
max_line_length = 100
--
To view, visit https://gerrit.wikimedia.org/r/302103
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I77feb4036cb670d19e1bbbd6ea461fa858566901
Gerrit-PatchSet: 11
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>