jenkins-bot has submitted this change and it was merged.
Change subject: Bugfix for older mediawiki short monthsnames
......................................................................
Bugfix for older mediawiki short monthsnames
- older short months names sometimes didn't ends with a
abbreviating dot. This causes the TimeStripper to fail with with
"incorrect month name in page",
TypeError: an integer is required
This path also registers undotted short months names to be
compared.
- start enumerate() with start=1
Change-Id: I25f467620b79fd39fba20e45aaeb0386b50101e4
---
M pywikibot/textlib.py
1 file changed, 5 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 70839ac..43dc65b 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1173,9 +1173,11 @@
self.site = site
self.origNames2monthNum = {}
- for n, (_long, _short) in enumerate(self.site.months_names):
- self.origNames2monthNum[_long] = n + 1
- self.origNames2monthNum[_short] = n + 1
+ for n, (_long, _short) in enumerate(self.site.months_names, start=1):
+ self.origNames2monthNum[_long] = n
+ self.origNames2monthNum[_short] = n
+ if _short.endswith('.'):
+ self.origNames2monthNum[_short[:-1]] = n
self.groups = [u'year', u'month', u'hour', u'time', u'day', u'minute', u'tzinfo']
--
To view, visit https://gerrit.wikimedia.org/r/136031
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I25f467620b79fd39fba20e45aaeb0386b50101e4
Gerrit-PatchSet: 2
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: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: (assertion fix) TypeError while raising APIError
......................................................................
(assertion fix) TypeError while raising APIError
APIError constructor includes two named keyword arguments and kwargs.
If json.loads returns something other than a dict, api.py tries
to raise an APIError exception passes a third unnamed argument to the
constructor, causing a TypeError exception to be raised.
Change-Id: Ieb7741d5737e6b0ad84b188b914f30411cdf0924
---
M pywikibot/data/api.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index a0f5aeb..d82e1a9 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -354,7 +354,7 @@
raise APIError("Unknown",
"Unable to process query response of type %s."
% type(result),
- {'data': result})
+ data=result)
if self['action'] == 'query':
if 'userinfo' in result.get('query', ()):
if hasattr(self.site, '_userinfo'):
--
To view, visit https://gerrit.wikimedia.org/r/136306
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb7741d5737e6b0ad84b188b914f30411cdf0924
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: new site method getglobaluserinfo() and new property globaluserinfo
......................................................................
new site method getglobaluserinfo() and new property globaluserinfo
This is similar to getuserinfo() and its property
Change-Id: Ief055d44a0aab6df44ff7084484069a36199b88f
---
M pywikibot/site.py
1 file changed, 33 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index e6743b2..2532960 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -815,6 +815,39 @@
userinfo = property(fget=getuserinfo, doc=getuserinfo.__doc__)
+ def getglobaluserinfo(self):
+ """Retrieve globaluserinfo from site and store in _globaluserinfo
+ attribute.
+
+ self._globaluserinfo will be a dict with the following keys and values:
+
+ - id: user id (numeric str)
+ - home: dbname of home wiki
+ - registration: registration date as Timestamp
+ - groups: list of groups (could be empty)
+ - rights: list of rights (could be empty)
+ - editcount: global editcount
+
+ """
+ if not hasattr(self, "_globaluserinfo"):
+ uirequest = api.Request(
+ site=self,
+ action="query",
+ meta="globaluserinfo",
+ guiprop="groups|rights|editcount"
+ )
+ uidata = uirequest.submit()
+ assert 'query' in uidata, \
+ "API userinfo response lacks 'query' key"
+ assert 'globaluserinfo' in uidata['query'], \
+ "API userinfo response lacks 'userinfo' key"
+ self._globaluserinfo = uidata['query']['globaluserinfo']
+ ts = self._globaluserinfo['registration']
+ self._globaluserinfo['registration'] = pywikibot.Timestamp.fromISOformat(ts)
+ return self._globaluserinfo
+
+ globaluserinfo = property(fget=getglobaluserinfo, doc=getuserinfo.__doc__)
+
def is_blocked(self, sysop=False):
"""Return true if and only if user is blocked.
--
To view, visit https://gerrit.wikimedia.org/r/135401
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ief055d44a0aab6df44ff7084484069a36199b88f
Gerrit-PatchSet: 2
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: (bugfix) remove maintaining gentoo-wiki which has been removed
......................................................................
(bugfix) remove maintaining gentoo-wiki which has been removed
gentoo-wiki is no longer supported directly and removed from
family folder
Change-Id: If30313977033aca986e955425ea4b244aa6b8206
---
M scripts/maintenance/wikimedia_sites.py
1 file changed, 0 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py
index 04e4e41..fa48954 100644
--- a/scripts/maintenance/wikimedia_sites.py
+++ b/scripts/maintenance/wikimedia_sites.py
@@ -24,7 +24,6 @@
familiesDict = {
'anarchopedia': 'anarchopedias',
- 'gentoo': 'gentoo',
'wikibooks': 'wikibooks',
'wikinews': 'wikinews',
'wikipedia': 'wikipedias',
--
To view, visit https://gerrit.wikimedia.org/r/136296
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If30313977033aca986e955425ea4b244aa6b8206
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
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: (bug 65309) check whether page already exist, code improvements
......................................................................
(bug 65309) check whether page already exist, code improvements
- check whether page already exist
- new core Bot style to handle options
- show options in doc string and with -help option
- new touch option to make a null edit on a page
- unicode strings for operator messages with variable contents
Change-Id: I2c574ace865ecc422524cd6682818297c326c750
---
M scripts/newitem.py
1 file changed, 46 insertions(+), 34 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/newitem.py b/scripts/newitem.py
index c05cdfc..c49b4cf 100644
--- a/scripts/newitem.py
+++ b/scripts/newitem.py
@@ -6,6 +6,16 @@
* When was the last edit on the page?
* Does the page contain interwiki's?
+This script understands various command-line arguments:
+
+-lastedit The minimum number of days that has passed since the page was
+ last edited.
+
+-pageage The minimum number of days that has passed since the page was
+ created.
+
+-touch Do a null edit on every page which has a wikibase item.
+
"""
#
# (C) Multichill, 2014
@@ -21,31 +31,28 @@
from datetime import timedelta
-class NewItemRobot:
- """
- A bot to create new items
- """
- def __init__(self, generator, pageAge, lastEdit):
- """
- Arguments:
- * generator - A generator that yields Page objects.
- * pageAge - The minimum number of days that has passed since
- the page was created
- * lastEdit - The minimum number of days that has passed since
- the page was last edited
+class NewItemRobot(pywikibot.Bot):
+ """ A bot to create new items """
- """
+ def __init__(self, generator, **kwargs):
+ """ Only accepts options defined in availableOptions """
+
+ self.availableOptions.update({
+ 'lastedit': 7,
+ 'pageage': 21,
+ 'touch': False,
+ })
+
+ super(NewItemRobot, self).__init__(**kwargs)
self.generator = pagegenerators.PreloadingGenerator(generator)
self.repo = pywikibot.Site().data_repository()
- self.pageAge = pageAge
+ self.pageAge = self.getOption('pageage')
+ self.lastEdit = self.getOption('lastedit')
self.pageAgeBefore = self.repo.getcurrenttime() - timedelta(days=self.pageAge)
- self.lastEdit = lastEdit
self.lastEditBefore = self.repo.getcurrenttime() - timedelta(days=self.lastEdit)
def run(self):
- """
- Starts the bot.
- """
+ """ Starts the bot. """
pywikibot.output('Page age is set to %s days so only pages created'
'\nbefore %s will be considered.'
% (self.pageAge, self.pageAgeBefore.isoformat()))
@@ -55,17 +62,21 @@
for page in self.generator:
pywikibot.output('Processing %s' % page)
+ if not page.exists():
+ pywikibot.output(u'%s does not exist anymore. Skipping...'
+ % page)
+ continue
item = pywikibot.ItemPage.fromPage(page)
if item.exists():
- pywikibot.output('%s already has an item: %s.\n'
- 'Doing a null edit on the page.'
- % (page, item))
- page.put(page.text)
+ pywikibot.output(u'%s already has an item: %s.' % (page, item))
+ if self.getOption('touch'):
+ pywikibot.output(u'Doing a null edit on the page.')
+ page.put(page.text)
elif page.isRedirectPage():
- pywikibot.output('%s is a redirect page. Skipping.' % page)
+ pywikibot.output(u'%s is a redirect page. Skipping.' % page)
elif page.editTime() > self.lastEditBefore:
pywikibot.output(
- 'Last edit on %s was on %s.\nToo recent. Skipping.'
+ u'Last edit on %s was on %s.\nToo recent. Skipping.'
% (page, page.editTime().isoformat()))
else:
(revId, revTimestamp, revUser,
@@ -73,7 +84,7 @@
total=1)[0]
if revTimestamp > self.pageAgeBefore:
pywikibot.output(
- 'Page creation of %s on %s is too recent. Skipping.'
+ u'Page creation of %s on %s is too recent. Skipping.'
% (page, page.editTime().isoformat()))
elif page.langlinks():
# FIXME: Implement this
@@ -103,27 +114,28 @@
def main():
- pageAge = 21
- lastEdit = 7
-
# Process global args and prepare generator args parser
local_args = pywikibot.handleArgs()
gen = pagegenerators.GeneratorFactory()
+ options = {}
for arg in local_args:
- if arg.startswith('-pageage:'):
- pageAge = int(arg[9:])
- elif arg.startswith('-lastedit:'):
- lastEdit = int(arg[10:])
+ if (
+ arg.startswith('-pageage:') or
+ arg.startswith('-lastedit:')):
+ key, val = arg.split(':', 1)
+ options[key[1:]] = int(val)
+ elif gen.handleArg(arg):
+ pass
else:
- gen.handleArg(arg)
+ options[arg[1:].lower()] = True
generator = gen.getCombinedGenerator()
if not generator:
pywikibot.showHelp()
return
- bot = NewItemRobot(generator, pageAge, lastEdit)
+ bot = NewItemRobot(generator, **options)
bot.run()
if __name__ == "__main__":
--
To view, visit https://gerrit.wikimedia.org/r/135749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2c574ace865ecc422524cd6682818297c326c750
Gerrit-PatchSet: 5
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: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>