jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] BlockEntry: Allow flags to be an empty str
......................................................................
[FIX] BlockEntry: Allow flags to be an empty str
When flags is an empty string it wouldn't split it and thus returning the
string directly. Instead it should just return an empty list.
Bug: T101976
Change-Id: Ifc18270c5027d9fd5b76037534e477702e8429f6
---
M pywikibot/logentries.py
M tests/logentry_tests.py
2 files changed, 7 insertions(+), 2 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 40dfb14..a639628 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -157,8 +157,11 @@
if not hasattr(self, '_flags'):
self._flags = self._params['flags']
# pre mw 1.19 returned a delimited string.
- if self._flags and isinstance(self._flags, basestring):
- self._flags = self._flags.split(',')
+ if isinstance(self._flags, basestring):
+ if self._flags:
+ self._flags = self._flags.split(',')
+ else:
+ self._flags = []
return self._flags
def duration(self):
diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py
index 5c750e5..1b4bb8b 100644
--- a/tests/logentry_tests.py
+++ b/tests/logentry_tests.py
@@ -88,6 +88,8 @@
logentry = self._get_logentry('block')
if logentry.action() == 'block':
self.assertIsInstance(logentry.flags(), list)
+ # Check that there are no empty strings
+ self.assertTrue(all(logentry.flags()))
if logentry.expiry() is not None:
self.assertIsInstance(logentry.expiry(), pywikibot.Timestamp)
self.assertIsInstance(logentry.duration(), datetime.timedelta)
--
To view, visit https://gerrit.wikimedia.org/r/223867
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc18270c5027d9fd5b76037534e477702e8429f6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: [FIX] APISite.upload: Support exists-normalized
......................................................................
[FIX] APISite.upload: Support exists-normalized
The upload warning type 'exists-normalized' has been added in MW 1.22 but
wasn't supported in pywikibot yet.
Change-Id: Ic3d4517e1e864e4f7a420d826618fc479ed3361c
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 12eb996..86d0c04 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4962,6 +4962,8 @@
'duplicate': "Uploaded file is a duplicate of %(msg)s.",
'badfilename': "Target filename is invalid.",
'filetype-unwanted-type': "File %(msg)s type is unwanted type.",
+ 'exists-normalized': 'File exists with different extension as '
+ '"%(msg)s".',
}
# check for required user right
--
To view, visit https://gerrit.wikimedia.org/r/223866
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic3d4517e1e864e4f7a420d826618fc479ed3361c
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: [FIX] open_compressed: Wrap BZ2File in Py 2.7
......................................................................
[FIX] open_compressed: Wrap BZ2File in Py 2.7
Although the documentation specifies that BZ2File is compatible with the
with-statement since Python 2.7 and the code for both gzip and BZ2File were
changed in the same commit in cpython, only since Python 2.7.1 this is
supported.
It also separates the tests so it's easier to see if only one specific
compressor has a problem. It also tests that the wrapper does not block any
exception.
The docstring is also improved to reflect the use_extension parameter.
Bug: T101649
Change-Id: I3f7024746164cc1bb1d89f2ac52dfa41ca08a3a6
---
M pywikibot/tools/__init__.py
M tests/tools_tests.py
2 files changed, 48 insertions(+), 28 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 9636c46..8d9c4ff 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -750,22 +750,25 @@
they are always available. 7zip is only available when a 7za program is
available.
- The compression is selected via the file ending.
+ The compression is either selected via the magic number or file ending.
@param filename: The filename.
@type filename: str
+ @param use_extension: Use the file extension instead of the magic number
+ to determine the type of compression (default False).
+ @type use_extension: bool
@raises ValueError: When 7za is not available.
@raises OSError: When it's not a 7z archive but the file extension is 7z.
It is also raised by bz2 when its content is invalid. gzip does not
immediately raise that error but only on reading it.
- @return: A file like object returning the uncompressed data in binary mode.
- Before Python 2.7 it's wrapping the object returned by BZ2File and gzip
- in a ContextManagerWrapper so it's advantages/disadvantages apply there.
- @rtype: file like object
+ @return: A file-like object returning the uncompressed data in binary mode.
+ Before Python 2.7 the GzipFile object and before 2.7.1 the BZ2File are
+ wrapped in a ContextManagerWrapper with its advantages/disadvantages.
+ @rtype: file-like object
"""
- def wrap(wrapped):
+ def wrap(wrapped, sub_ver):
"""Wrap in a wrapper when this is below Python version 2.7."""
- if sys.version_info < (2, 7):
+ if sys.version_info < (2, 7, sub_ver):
return ContextManagerWrapper(wrapped)
else:
return wrapped
@@ -787,9 +790,9 @@
extension = ''
if extension == 'bz2':
- return wrap(bz2.BZ2File(filename))
+ return wrap(bz2.BZ2File(filename), 1)
elif extension == 'gz':
- return wrap(gzip.open(filename))
+ return wrap(gzip.open(filename), 0)
elif extension == '7z':
try:
process = subprocess.Popen(['7za', 'e', '-bd', '-so', filename],
diff --git a/tests/tools_tests.py b/tests/tools_tests.py
index ceb42cb..718f589 100644
--- a/tests/tools_tests.py
+++ b/tests/tools_tests.py
@@ -24,26 +24,26 @@
"""Test that ContextManagerWrapper is working correctly."""
+ class DummyClass(object):
+
+ """A dummy class which has some values and a close method."""
+
+ class_var = 42
+
+ def __init__(self):
+ """Create instance with dummy values."""
+ self.instance_var = 1337
+ self.closed = False
+
+ def close(self):
+ """Just store that it has been closed."""
+ self.closed = True
+
net = False
def test_wrapper(self):
"""Create a test instance and verify the wrapper redirects."""
- class DummyClass(object):
-
- """A dummy class which has some values and a close method."""
-
- class_var = 42
-
- def __init__(self):
- """Create instance with dummy values."""
- self.instance_var = 1337
- self.closed = False
-
- def close(self):
- """Just store that it has been closed."""
- self.closed = True
-
- obj = DummyClass()
+ obj = self.DummyClass()
wrapped = tools.ContextManagerWrapper(obj)
self.assertIs(wrapped.class_var, obj.class_var)
self.assertIs(wrapped.instance_var, obj.instance_var)
@@ -52,7 +52,18 @@
with wrapped as unwrapped:
self.assertFalse(obj.closed)
self.assertIs(unwrapped, obj)
+ unwrapped.class_var = 47
self.assertTrue(obj.closed)
+ self.assertEqual(wrapped.class_var, 47)
+
+ def test_exec_wrapper(self):
+ """Check that the wrapper permits exceptions."""
+ wrapper = tools.ContextManagerWrapper(self.DummyClass())
+ self.assertFalse(wrapper.closed)
+ with self.assertRaises(ZeroDivisionError):
+ with wrapper:
+ 1 / 0
+ self.assertTrue(wrapper.closed)
class OpenCompressedTestCase(TestCase):
@@ -82,13 +93,19 @@
with tools.open_compressed(*args) as f:
return f.read()
- def test_open_compressed(self):
- """Test open_compressed with all compressors in the standard library."""
+ def test_open_compressed_normal(self):
+ """Test open_compressed with no compression in the standard library."""
self.assertEqual(self._get_content(self.base_file), self.original_content)
+
+ def test_open_compressed_bz2(self):
+ """Test open_compressed with bz2 compressor in the standard library."""
self.assertEqual(self._get_content(self.base_file + '.bz2'), self.original_content)
- self.assertEqual(self._get_content(self.base_file + '.gz'), self.original_content)
self.assertEqual(self._get_content(self.base_file + '.bz2', True), self.original_content)
+ def test_open_compressed_gz(self):
+ """Test open_compressed with gz compressor in the standard library."""
+ self.assertEqual(self._get_content(self.base_file + '.gz'), self.original_content)
+
def test_open_compressed_7z(self):
"""Test open_compressed with 7za if installed."""
try:
--
To view, visit https://gerrit.wikimedia.org/r/223865
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3f7024746164cc1bb1d89f2ac52dfa41ca08a3a6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: Skip RC entries without a title
......................................................................
Skip RC entries without a title
The title in a log entry may have been suppressed,
and wont appear in the item data.
Bug: T78152
Change-Id: I2b27813eb2b6861d606177f69d2eefa813c0cbd0
---
M pywikibot/pagegenerators.py
1 file changed, 6 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 12e7523..dd96d21 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -994,6 +994,9 @@
showPatrolled=showPatrolled,
topOnly=topOnly, step=step, total=total,
user=user, excludeuser=excludeuser):
+ # The title in a log entry may have been suppressed
+ if 'title' not in item and item['type'] == 'log':
+ continue
yield pywikibot.Page(pywikibot.Link(item["title"], site))
@@ -2047,6 +2050,9 @@
from pywikibot.comms.rcstream import site_rc_listener
for entry in site_rc_listener(site, total=total):
+ # The title in a log entry may have been suppressed
+ if 'title' not in entry and entry['type'] == 'log':
+ continue
page = pywikibot.Page(site, entry['title'], entry['namespace'])
page._rcinfo = entry
yield page
--
To view, visit https://gerrit.wikimedia.org/r/223863
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2b27813eb2b6861d606177f69d2eefa813c0cbd0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: [FIX] PatrolEntry: Allow cur/prev id to be str
......................................................................
[FIX] PatrolEntry: Allow cur/prev id to be str
Sometimes PatrolEntry returns str instead of int for the revision ids. See also
bug T101603.
Change-Id: I8febb1b23bb54bba0dcef11e4e887583b5c238ba
---
M pywikibot/logentries.py
1 file changed, 7 insertions(+), 5 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 238f0b2..40dfb14 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -298,15 +298,17 @@
def current_id(self):
"""Return the current id."""
# key has been changed in mw 1.19; try the new mw style first
- return (self._params['curid']
- if 'curid' in self._params else self._params['cur'])
+ # sometimes it returns strs sometimes ints
+ return int(self._params['curid']
+ if 'curid' in self._params else self._params['cur'])
@property
def previous_id(self):
- # key has been changed in mw 1.19; try the new mw style first
"""Return the previous id."""
- return (self._params['previd']
- if 'previd' in self._params else self._params['prev'])
+ # key has been changed in mw 1.19; try the new mw style first
+ # sometimes it returns strs sometimes ints
+ return int(self._params['previd']
+ if 'previd' in self._params else self._params['prev'])
@property
def auto(self):
--
To view, visit https://gerrit.wikimedia.org/r/223862
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8febb1b23bb54bba0dcef11e4e887583b5c238ba
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: Fix some misspellings
......................................................................
Fix some misspellings
Change-Id: I6a32f8a2a7b7eac39756af859b4f383dc6bb9330
---
M README-conversion.txt
M pywikibot/bot.py
M pywikibot/cosmetic_changes.py
M pywikibot/site.py
M scripts/archivebot.py
M scripts/checkimages.py
M scripts/cosmetic_changes.py
M scripts/interwiki.py
M scripts/welcome.py
9 files changed, 15 insertions(+), 15 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/README-conversion.txt b/README-conversion.txt
index dd6c1c7..8422499 100644
--- a/README-conversion.txt
+++ b/README-conversion.txt
@@ -135,7 +135,7 @@
namespace. Any references to "userlib.User" can be replaced by
"pywikibot.User", but the old form is retained for backwards-compatibility.
-The following changes have occured in the User object:
+The following changes have occurred in the User object:
- contributions(): returns a pywikibot.Timestamp object instead of a Mediawiki one
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 041c5c9..feaa3d5 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -829,8 +829,8 @@
if m:
pywikibot.output(u'Pywikibot r%s' % m.group(1))
else:
- # Version ID not availlable on SVN repository.
- # Maybe these informations should be imported from version.py
+ # Version ID not available on SVN repository.
+ # Maybe this information should be imported from version.py
pywikibot.output(u'Pywikibot SVN repository')
pywikibot.output(u'Python %s' % sys.version)
@@ -1358,7 +1358,7 @@
class CreatingPageBot(CurrentPageBot):
- """A CurrentPageBot class which only treats not exisiting pages."""
+ """A CurrentPageBot class which only treats nonexistent pages."""
def treat(self, page):
"""Treat page if doesn't exist."""
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index bced95d..57a2c78 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -278,7 +278,7 @@
new_text = self._change(text)
except Exception as e:
if self.ignore == CANCEL_PAGE:
- pywikibot.warning(u'Skipped "{0}", because an error occured.'.format(self.title))
+ pywikibot.warning(u'Skipped "{0}", because an error occurred.'.format(self.title))
pywikibot.exception(e)
return False
else:
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ac0c761..12eb996 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2401,7 +2401,7 @@
never from the cache.
@type force: bool
@return: A tuple containing the major, minor version number and any
- text after that. If an error occured (0, 0, 0) is returned.
+ text after that. If an error occurred (0, 0, 0) is returned.
@rtype: int, int, str
"""
try:
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 6c48ccb..1e82623 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -11,7 +11,7 @@
Then goes through all pages (unless a specific page specified using options)
and archives old discussions. This is done by breaking a page into threads,
then scanning each thread for timestamps. Threads older than a specified
-treshold are then moved to another page (the archive), which can be named
+threshold are then moved to another page (the archive), which can be named
either basing on the thread's name or then name can contain a counter which
will be incremented when the archive reaches a certain size.
@@ -213,7 +213,7 @@
Return a regex that matches to variations of the template title.
It supports the transcluding variant as well as localized namespaces and
- case-insensitivity depending on the namspace.
+ case-insensitivity depending on the namespace.
@param tpl_page: The template page
@type tpl_page: Page
@@ -680,7 +680,7 @@
archiver.run()
time.sleep(10)
except Exception:
- pywikibot.error(u'Error occured while processing page %s' % pg)
+ pywikibot.error(u'Error occurred while processing page %s' % pg)
pywikibot.exception(tb=True)
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 28d6ade..267eb23 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -1709,7 +1709,7 @@
elif arg.startswith('-start'):
if len(arg) == 6:
firstPageTitle = pywikibot.input(
- u'From witch page do you want to start?')
+ u'From which page do you want to start?')
elif len(arg) > 6:
firstPageTitle = arg[7:]
firstPageTitle = firstPageTitle.split(":")[1:]
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index cf4553f..c7e1934 100644
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -18,7 +18,7 @@
the predefined message texts with original and replacements
inserted.
--ignore: Ignores if an error occured and either skips the page or
+-ignore: Ignores if an error occurred and either skips the page or
only that method. It can be set to 'page' or 'method'.
&warning;
@@ -80,7 +80,7 @@
pywikibot.output("Page %s is locked?!"
% self.current_page.title(asLink=True))
except pywikibot.EditConflict:
- pywikibot.output("An edit conflict has occured at %s."
+ pywikibot.output("An edit conflict has occurred at %s."
% self.current_page.title(asLink=True))
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index fbb6280..5f5ffb2 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2174,7 +2174,7 @@
try:
page = next(self.pageGenerator)
except IOError:
- pywikibot.output(u'IOError occured; skipping')
+ pywikibot.output(u'IOError occurred; skipping')
continue
if page in globalvar.skip:
pywikibot.output(u'Skipping: %s is in the skip list' % page)
diff --git a/scripts/welcome.py b/scripts/welcome.py
index cbd3dca..b77d9e2 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -676,7 +676,7 @@
'welcome-updating'))
return True
except pywikibot.EditConflict:
- pywikibot.output(u'An edit conflict has occured. Pausing for '
+ pywikibot.output(u'An edit conflict has occurred. Pausing for '
u'10 seconds before continuing.')
time.sleep(10)
@@ -789,7 +789,7 @@
self.welcomed_users.append(users)
except pywikibot.EditConflict:
showStatus(4)
- pywikibot.output(u'An edit conflict has occured, '
+ pywikibot.output(u'An edit conflict has occurred, '
u'skipping this user.')
if globalvar.makeWelcomeLog and \
--
To view, visit https://gerrit.wikimedia.org/r/223861
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6a32f8a2a7b7eac39756af859b4f383dc6bb9330
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>