jenkins-bot has submitted this change and it was merged.
Change subject: archivebot: search for the marker template and fail earlier before making changes
......................................................................
archivebot: search for the marker template and fail earlier before making changes
Change-Id: I55ac08d0e726ed6f579c6b1325f9bbc3ed2c6423
---
M scripts/archivebot.py
1 file changed, 7 insertions(+), 5 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index c76ddde..2506408 100644
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -548,6 +548,13 @@
% (self.archived_threads, mintoarchive))
return
if whys:
+ # Search for the marker template
+ rx = re.compile(r'\{\{%s\s*?\n.*?\n\}\}'
+ % (template_title_regex(self.tpl).pattern), re.DOTALL)
+ if not rx.search(self.page.header):
+ pywikibot.error("Couldn't find the template in the header")
+ return
+
pywikibot.output(u'Archiving %d thread(s).' % self.archived_threads)
# Save the archives first (so that bugs don't cause a loss of data)
for a in sorted(self.archives.keys()):
@@ -558,11 +565,6 @@
self.archives[a].update(comment)
# Save the page itself
- rx = re.compile(r'\{\{%s\s*?\n.*?\n\}\}'
- % (template_title_regex(self.tpl).pattern), re.DOTALL)
- if not rx.search(self.page.header):
- pywikibot.error("Couldn't find the template in the header")
- return
self.page.header = rx.sub(self.attr2text(), self.page.header)
self.comment_params['count'] = self.archived_threads
comma = self.site.mediawiki_message('comma-separator')
--
To view, visit https://gerrit.wikimedia.org/r/197476
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I55ac08d0e726ed6f579c6b1325f9bbc3ed2c6423
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: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] tests: Try to determine source of fails
......................................................................
[IMPROV] tests: Try to determine source of fails
In recent builds there have been some failures on Travis related to the
fact that an apparent subset is not a subset. It tries to solve T92856.
Change-Id: I210f340b392bb7b2ba1ecf640ab9b9176beb2220
---
M tests/site_tests.py
1 file changed, 5 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 3d116e7..762f91f 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -366,8 +366,11 @@
for pl in links:
self.assertIsInstance(pl, pywikibot.Page)
# test links arguments
- self.assertTrue(links.issuperset(
- set(mysite.pagelinks(mainpage, namespaces=[0, 1]))))
+ # TODO: There have been build failures because the following assertion
+ # wasn't true. Bug: T92856
+ # Example: https://travis-ci.org/wikimedia/pywikibot-core/jobs/54552081#L505
+ self.assertCountEqual(
+ set(mysite.pagelinks(mainpage, namespaces=[0, 1])) - links, [])
for target in mysite.preloadpages(mysite.pagelinks(mainpage,
follow_redirects=True,
total=5)):
--
To view, visit https://gerrit.wikimedia.org/r/197089
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I210f340b392bb7b2ba1ecf640ab9b9176beb2220
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] login: Simplify reading password
......................................................................
[IMPROV] login: Simplify reading password
Instead of checking each variant of the tuple a default tuple can be
easily created by inverting the contents and appending the family name
and code if necessary. This makes the condition checking whether the
line applies easier as it doesn't need to care about whether code and
family name are set.
It now also explains which line has an invalid format and explicity
states that the file must be encoded in either UTF-8 or ASCII.
Change-Id: Iff025c267a64b5574c289a3a9ec1350e65728e4d
---
M pywikibot/login.py
1 file changed, 17 insertions(+), 19 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index dff941b..22a28b8 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -167,8 +167,7 @@
to set a default password for an username. The last matching entry will
be used, so default usernames should occur above specific usernames.
- If the username or password contain non-ASCII characters, they
- should be stored using the utf-8 encoding.
+ The file must be either encoded in ASCII or UTF-8.
Example:
@@ -185,7 +184,7 @@
os.chmod(config.password_file, config.private_files_permission)
password_f = codecs.open(config.password_file, encoding='utf-8')
- for line in password_f:
+ for line_nr, line in enumerate(password_f):
if not line.strip():
continue
try:
@@ -193,25 +192,24 @@
except SyntaxError:
entry = None
if type(entry) is not tuple:
- warn('Invalid tuple', _PasswordFileWarning)
+ warn('Invalid tuple in line {0}'.format(line_nr),
+ _PasswordFileWarning)
continue
if not 2 <= len(entry) <= 4:
- warn('The length of tuple should be 2 to 4 (%s given)'
- % len(entry), _PasswordFileWarning)
+ warn('The length of tuple in line {0} should be 2 to 4 ({1} '
+ 'given)'.format(line_nr, entry), _PasswordFileWarning)
continue
- username = normalize_username(entry[-2])
- if len(entry) == 4: # for userinfo included code and family
- if entry[0] == self.site.code and \
- entry[1] == self.site.family.name and \
- username == self.username:
- self.password = entry[3]
- elif len(entry) == 3: # for userinfo included family
- if entry[0] == self.site.family.name and \
- username == self.username:
- self.password = entry[2]
- elif len(entry) == 2: # for default userinfo
- if username == self.username:
- self.password = entry[1]
+
+ # When the tuple is inverted the default family and code can be
+ # easily appended which makes the next condition easier as it does
+ # not need to know if it's using the default value or not.
+ entry = list(entry[::-1]) + [self.site.family.name,
+ self.site.code][len(entry) - 2:]
+
+ if (normalize_username(entry[1]) == self.username and
+ entry[2] == self.site.family.name and
+ entry[3] == self.site.code):
+ self.password = entry[0]
password_f.close()
def login(self, retry=False):
--
To view, visit https://gerrit.wikimedia.org/r/197506
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iff025c267a64b5574c289a3a9ec1350e65728e4d
Gerrit-PatchSet: 1
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] config2: Automatically list imports
......................................................................
[IMPROV] config2: Automatically list imports
Instead of having to remember adding the imports manually in a tuple
this automatically iterates over the global variables and generates the
list (technically a frozenset) from there.
Change-Id: Iaeea9e6e5579153d0211b7625eec607ba65b8748
---
M pywikibot/config2.py
1 file changed, 7 insertions(+), 6 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 5169b0c..6e7954d 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -29,16 +29,17 @@
from warnings import warn
+# This frozen set should contain all imported modules/variables, so it must
+# occur directly after the imports. At that point globals() only contains the
+# names and some magic variables (like __name__)
+_imports = frozenset(name for name in globals() if not name.startswith('_'))
+
class _ConfigurationDeprecationWarning(UserWarning):
"""Feature that is no longer supported."""
pass
-
-
-# Please keep _imported_modules in sync with the imports above
-_imported_modules = ('collections', 'os', 'stat', 'sys')
# IMPORTANT:
# Do not change any of the variables in this file. Instead, make
@@ -816,7 +817,7 @@
# System-level and User-level changes.
# Store current variables and their types.
_glv = dict((_key, _val) for _key, _val in globals().items()
- if _key[0] != '_' and _key not in _imported_modules)
+ if _key[0] != '_' and _key not in _imports)
_gl = list(_glv.keys())
_tp = {}
for _key in _gl:
@@ -865,7 +866,7 @@
for _key, _val in list(_uc.items()):
if _key.startswith('_'):
pass
- elif _key in _imported_modules:
+ elif _key in _imports:
pass
elif _key in _gl:
nt = type(_val)
--
To view, visit https://gerrit.wikimedia.org/r/197444
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaeea9e6e5579153d0211b7625eec607ba65b8748
Gerrit-PatchSet: 2
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>