jenkins-bot has submitted this change and it was merged.
Change subject: Improve epydoc formatting
......................................................................
Improve epydoc formatting
Change-Id: I888e606054a0afec65f9ada8f997e7bb18376b0e
---
M scripts/maintenance/make_i18n_dict.py
1 file changed, 9 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/make_i18n_dict.py b/scripts/maintenance/make_i18n_dict.py
index 2283bdf..81d80ea 100755
--- a/scripts/maintenance/make_i18n_dict.py
+++ b/scripts/maintenance/make_i18n_dict.py
@@ -5,29 +5,34 @@
usage:
-run IDLE at topmost level
+run IDLE at topmost level:
+
>>> import pwb
>>> from scripts.maintenance.make_i18n_dict import i18nBot
>>> bot = i18nBot('<scriptname>', '<msg dict>')
>>> bot.run()
If you have more than one message dictionary, give all these names to the bot:
+
>>> bot = i18nBot('<scriptname>', '<msg dict1>', '<msg dict2>', '<msg dict3>')
If you want to rename the message index use keyword arguments. This may be
mixed with preleading positonal argumens:
+
>>> bot = i18nBot('<scriptname>', '<msg dict1>', the_other_msg='<msg dict2>')
If you have the messages as instance constants you may call the bot as follows:
+
>>> bot = i18nBot('<scriptname>.<class instance>', '<msg dict1>', '<msg dict2>')
It's also possible to make json files too by using to_json method after
-instantiating the bot. It also calls bot.run() to create the dictionaries.
+instantiating the bot. It also calls C{bot.run()} to create the dictionaries:
+
>>> bot.to_json()
"""
#
-# (C) xqt, 2013-2015
-# (C) Pywikibot team, 2013-2015
+# (C) xqt, 2013-2016
+# (C) Pywikibot team, 2013-2016
#
# Distributed under the terms of the MIT license.
#
--
To view, visit https://gerrit.wikimedia.org/r/270477
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I888e606054a0afec65f9ada8f997e7bb18376b0e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
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: [IMPR] Implement missing options behaviours
......................................................................
[IMPR] Implement missing options behaviours
- implement -offset option but test the Timestamp instead of the string length
- implement -timeoffset option
- implement -sul option. parseNewUserLog generator retrieves
pywikibot.User items instead of logEntry objects.
Only yield 'create' actions or when -sul is given 'autocreate' too.
Other action result are skipped.
- Fix arg parsing for -file and -sign
- Fix doc for L10N dict lists. Some of them are replaced by i18n from twn.
Bug: T143545
Change-Id: I26c76aa64ef934116756804986555db62bb64317
---
M scripts/welcome.py
1 file changed, 26 insertions(+), 16 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/welcome.py b/scripts/welcome.py
index f3d9957..0f2f908 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -176,6 +176,7 @@
#
import codecs
+from datetime import timedelta
import locale
import re
import sys
@@ -199,8 +200,8 @@
# been eliminated.
# FIXME: Not all language/project combinations have been defined yet.
# Add the following strings to customise for a language:
-# logbook, talk_page, netext, user, con, report_page
-# bad_pag, report_text, logt, random_sign and whitelist_pg.
+# logbook, netext, report_page, bad_pag, report_text, random_sign,
+# whitelist_pg, final_new_text_additions, logpage_header
############################################################################
@@ -411,7 +412,7 @@
attachEditCount = 1 # number of edits that an user required to be welcomed
dumpToLog = 15 # number of users that are required to add the log :)
- offset = 0 # skip users newer than that timestamp
+ offset = None # skip users newer than that timestamp
timeoffset = 0 # skip users newer than # minutes
recursive = True # define if the Bot is recursive or not
timeRecur = 3600 # how much time (sec.) the bot sleeps before restart
@@ -663,8 +664,17 @@
time.sleep(10)
def parseNewUserLog(self):
- """Retrieve ne users."""
- return self.site.logevents('newusers', total=globalvar.queryLimit)
+ """Retrieve new users."""
+ if globalvar.timeoffset != 0:
+ start = self.site.server_time() - timedelta(
+ minutes=globalvar.timeoffset)
+ else:
+ start = globalvar.offset
+ for ue in self.site.logevents('newusers', total=globalvar.queryLimit,
+ start=start):
+ if ue.action == 'create' or (
+ ue.action == 'autocreate' and globalvar.welcomeAuto):
+ yield pywikibot.User(ue.page())
def defineSign(self, force=False):
"""Setup signature."""
@@ -712,9 +722,7 @@
"""Run the bot."""
while True:
welcomed_count = 0
- us = (pywikibot.User(self.site, users.user())
- for users in self.parseNewUserLog())
- for users in us:
+ for users in self.parseNewUserLog():
if users.isBlocked():
showStatus(3)
pywikibot.output(u'%s has been blocked!' % users.name())
@@ -905,26 +913,28 @@
globalvar.timeRecur = int(arg[6:])
elif arg.startswith('-offset'):
if len(arg) == 7:
- globalvar.offset = int(pywikibot.input(
- u'Which time offset for new users would you like to use? (yyyymmddhhmmss)'))
+ val = pywikibot.input(
+ 'Which time offset for new users would you like to use? (yyyymmddhhmmss)')
else:
- globalvar.offset = int(arg[8:])
- if len(str(globalvar.offset)) != 14:
+ val = arg[8:]
+ try:
+ globalvar.offset = pywikibot.Timestamp.fromtimestampformat(val)
+ except ValueError:
# upon request, we might want to check for software version here
raise ValueError(
"Mediawiki has changed, -offset:# is not supported "
"anymore, but -offset:TIMESTAMP is, assuming TIMESTAMP "
"is yyyymmddhhmmss. -timeoffset is now also supported. "
"Please read this script source header for documentation.")
- elif arg.startswith('-file:'):
+ elif arg.startswith('-file'):
globalvar.randomSign = True
- if len(arg) == 6:
+ if len(arg) <= 6:
globalvar.signFileName = pywikibot.input(
u'Where have you saved your signatures?')
else:
globalvar.signFileName = arg[6:]
- elif arg.startswith('-sign:'):
- if len(arg) == 6:
+ elif arg.startswith('-sign'):
+ if len(arg) <= 6:
globalvar.defaultSign = pywikibot.input(
u'Which signature to use?')
else:
--
To view, visit https://gerrit.wikimedia.org/r/312031
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I26c76aa64ef934116756804986555db62bb64317
Gerrit-PatchSet: 6
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Remove '-' code from original language_by_size list
......................................................................
[bugfix] Remove '-' code from original language_by_size list
'-' is added to language_by_size list by a statement but it must not
be part of the original list inside family file. When updating this
list remove it first.
Bug: T131752
Change-Id: Ib40babf588f3349eaf65f60bf76cbc4e08bb93ef
---
M scripts/maintenance/wikimedia_sites.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py
index 0cd0264..c858b38 100755
--- a/scripts/maintenance/wikimedia_sites.py
+++ b/scripts/maintenance/wikimedia_sites.py
@@ -43,6 +43,9 @@
pywikibot.output('\nChecking family %s:' % family)
original = Family.load(family).languages_by_size
+ for code in exceptions:
+ if code in original:
+ original.remove(code)
obsolete = Family.load(family).obsolete
new = []
--
To view, visit https://gerrit.wikimedia.org/r/292124
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib40babf588f3349eaf65f60bf76cbc4e08bb93ef
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Darthbhyrava <hbhyrava(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: MtDu <justin.d128(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: win32_unicode: always use byte std streams
......................................................................
win32_unicode: always use byte std streams
On Python 3, sys.std* expect text data, while on Python 2, sys.std*
expect
bytes. The interface we provide (win32_unicode.std*) is bytes-based
(specifically,
utf-8 encoded text). Python 3 provides sys.std*.buffer as bytes
interface, so we
use that instead of sys.std*.
Bug: T147654
Change-Id: Ida7dba2def00d60160054919b3084945f629571b
---
M pywikibot/userinterfaces/win32_unicode.py
1 file changed, 32 insertions(+), 17 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/win32_unicode.py b/pywikibot/userinterfaces/win32_unicode.py
index 2425fc9..8295c51 100755
--- a/pywikibot/userinterfaces/win32_unicode.py
+++ b/pywikibot/userinterfaces/win32_unicode.py
@@ -35,18 +35,42 @@
OSWIN32 = (sys.platform == "win32")
+
+# If any exception occurs in this code, we'll probably try to print it on stderr,
+# which makes for frustrating debugging if stderr is directed to our wrapper.
+# So be paranoid about catching errors and reporting them to original_stderr,
+# so that we can at least see them.
+def _complain(message):
+ print(isinstance(message, str) and message or repr(message),
+ file=sys.stderr) # noqa: print
+
+
if sys.version_info[0] > 2:
unicode = str
PY3 = True
+ try:
+ stdout = sys.stdout.buffer
+ stderr = sys.stderr.buffer
+ stdin = sys.stdin.buffer
+ except AttributeError as e:
+ _complain("Cannot find buffer interface for stdout, stderr or stdin.\n"
+ "Using (incorrect) text interfaces instead. This is likely to\n"
+ "break on non-ascii text.")
+ stdout = sys.stdout
+ stderr = sys.stderr
+ stdin = sys.stdin
+
else:
PY3 = False
+ stdout = sys.stdout
+ stderr = sys.stderr
+ stdin = sys.stdin
-stdin = sys.stdin
-stdout = sys.stdout
-stderr = sys.stderr
argv = sys.argv
-original_stderr = sys.stderr
+original_stdout = stdout
+original_stderr = stderr
+original_stdin = stdin
if OSWIN32:
from ctypes import WINFUNCTYPE, windll, POINTER, WinError
@@ -167,15 +191,6 @@
return std.fileno()
except UnsupportedOperation:
pass
-
-
-# If any exception occurs in this code, we'll probably try to print it on stderr,
-# which makes for frustrating debugging if stderr is directed to our wrapper.
-# So be paranoid about catching errors and reporting them to original_stderr,
-# so that we can at least see them.
-def _complain(message):
- print(isinstance(message, str) and message or repr(message),
- file=original_stderr) # noqa: print
def register_cp65001():
@@ -316,17 +331,17 @@
stdin = UnicodeInput(hStdin, name='<Unicode console stdin>')
if real_stdout:
- stdout = UnicodeOutput(hStdout, sys.stdout, STDOUT_FILENO,
+ stdout = UnicodeOutput(hStdout, original_stdout, STDOUT_FILENO,
'<Unicode console stdout>')
else:
- stdout = UnicodeOutput(None, sys.stdout, old_stdout_fileno,
+ stdout = UnicodeOutput(None, original_stdout, old_stdout_fileno,
'<Unicode redirected stdout>')
if real_stderr:
- stderr = UnicodeOutput(hStderr, sys.stderr, STDERR_FILENO,
+ stderr = UnicodeOutput(hStderr, original_stderr, STDERR_FILENO,
'<Unicode console stderr>')
else:
- stderr = UnicodeOutput(None, sys.stderr, old_stderr_fileno,
+ stderr = UnicodeOutput(None, original_stderr, old_stderr_fileno,
'<Unicode redirected stderr>')
except Exception as e:
_complain("exception %r while fixing up sys.stdout and sys.stderr" % (e,))
--
To view, visit https://gerrit.wikimedia.org/r/314858
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ida7dba2def00d60160054919b3084945f629571b
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: Allow non-urlencoded permalink
......................................................................
Allow non-urlencoded permalink
With browsers increasing their support for non-ascii urls the need
for the urlencode of the title is not always guaranteed. Adding an
optional parameter to permalink ensures this option becomes
available.
Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
(cherry picked from commit 7f12117a61ab3df5c1ee7f6deb718e66fde1a200)
---
M pywikibot/page.py
1 file changed, 6 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index a78ed9a..6f72ded 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -418,16 +418,20 @@
# TODO: what about redirects, errors?
return self._revisions[oldid].text
- def permalink(self, oldid=None):
+ def permalink(self, oldid=None, percent_encoded=True):
"""Return the permalink URL of an old revision of this page.
@param oldid: The revid of the revision desired.
"""
+ if percent_encoded:
+ title = self.title(asUrl=True)
+ else:
+ title = self.title(asUrl=False).replace(' ', '_')
return "//%s%s/index.php?title=%s&oldid=%s" \
% (self.site.hostname(),
self.site.scriptpath(),
- self.title(asUrl=True),
+ title,
(oldid if oldid is not None else self.latest_revision_id))
@property
--
To view, visit https://gerrit.wikimedia.org/r/313759
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Lokal Profil <lokal.profil(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: [bugfix] use wikistats lib to update languages_by_size
......................................................................
[bugfix] use wikistats lib to update languages_by_size
- This also solves T143509
Bug: T143509
Change-Id: Iad218316ccd439c38106a1def29c2284c68356f1
---
M scripts/maintenance/wikimedia_sites.py
1 file changed, 25 insertions(+), 33 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py
index f8f4a3f..0cd0264 100755
--- a/scripts/maintenance/wikimedia_sites.py
+++ b/scripts/maintenance/wikimedia_sites.py
@@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
"""Script that updates the language lists in Wikimedia family files."""
#
-# (C) xqt, 2009-2014
-# (C) Pywikibot team, 2008-2014
+# (C) xqt, 2009-2016
+# (C) Pywikibot team, 2008-2016
#
# Distributed under the terms of the MIT license.
#
@@ -15,49 +15,41 @@
import codecs
import re
-import requests
-
-from xml.etree import cElementTree
-
import pywikibot
+from pywikibot.data import wikistats
from pywikibot.family import Family
-URL = 'https://wikistats.wmflabs.org/api.php?action=dump&table=%s&format=xml'
-
-familiesDict = {
- 'anarchopedia': 'anarchopedias',
- 'wikibooks': 'wikibooks',
- 'wikinews': 'wikinews',
- 'wikipedia': 'wikipedias',
- 'wikiquote': 'wikiquotes',
- 'wikisource': 'wikisources',
- 'wikiversity': 'wikiversity',
- 'wikivoyage': 'wikivoyage',
- 'wiktionary': 'wiktionaries',
-}
+# supported families by this script
+families_list = [
+ 'anarchopedia',
+ 'wikibooks',
+ 'wikinews',
+ 'wikipedia',
+ 'wikiquote',
+ 'wikisource',
+ 'wikiversity',
+ 'wikivoyage',
+ 'wiktionary',
+]
exceptions = ['-']
def update_family(families):
"""Update family files."""
- for family in families or familiesDict.keys():
+ ws = wikistats.WikiStats()
+ for family in families or families_list:
pywikibot.output('\nChecking family %s:' % family)
original = Family.load(family).languages_by_size
obsolete = Family.load(family).obsolete
- feed = requests.get(URL % familiesDict[family])
- tree = cElementTree.parse(feed)
-
new = []
- for field in tree.findall('row/field'):
- if field.get('name') == 'prefix':
- code = field.text
- if not (code in obsolete or code in exceptions):
- new.append(code)
- continue
+ table = ws.languages_by_size(family)
+ for code in table:
+ if not (code in obsolete or code in exceptions):
+ new.append(code)
# put the missing languages to the right place
missing = original != new and set(original) - set(new)
@@ -100,8 +92,8 @@
if __name__ == '__main__':
- fam = []
- for arg in pywikibot.handleArgs():
- if arg in familiesDict.keys() and arg not in fam:
- fam.append(arg)
+ fam = set()
+ for arg in pywikibot.handle_args():
+ if arg in families_list:
+ fam.add(arg)
update_family(fam)
--
To view, visit https://gerrit.wikimedia.org/r/270269
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iad218316ccd439c38106a1def29c2284c68356f1
Gerrit-PatchSet: 9
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>