Xqt has submitted this change and it was merged.
Change subject: [PEP8] changes
......................................................................
[PEP8] changes
Change-Id: Icfdde9e9c6fb32832b582ac88b52f1f0ced19f20
---
M upload.py
1 file changed, 29 insertions(+), 24 deletions(-)
Approvals:
Xqt: Looks good to me, approved
diff --git a/upload.py b/upload.py
index 11e76a5..8210770 100644
--- a/upload.py
+++ b/upload.py
@@ -19,11 +19,11 @@
"""
#
# (C) Rob W.W. Hooft, Andre Engels 2003-2004
-# (C) Pywikipedia bot team, 2003-2013
+# (C) Pywikibot team, 2003-2013
#
# Distributed under the terms of the MIT license.
#
-__version__='$Id$'
+__version__ = '$Id$'
#
import os
@@ -33,6 +33,7 @@
import wikipedia as pywikibot
import config
import query
+
def post_multipart(site, address, fields, files, cookies):
""" Post fields and files to an http host as multipart/form-data.
@@ -46,6 +47,7 @@
contentType, body = encode_multipart_formdata(fields, files)
return site.postData(address, body, contentType=contentType,
cookies=cookies)
+
def encode_multipart_formdata(fields, files):
"""
@@ -77,6 +79,7 @@
body = '\r\n'.join(lines)
content_type = 'multipart/form-data; boundary=%s' % boundary
return content_type, body
+
def get_content_type(filename):
return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
@@ -136,8 +139,8 @@
file = uo.open(self.url)
if 'text/html' in file.info().getheader('Content-Type'):
- print \
-"Couldn't download the image: the requested URL was not found on this server."
+ print("Couldn't download the image: the requested URL "
+ "was not found on this server.")
return
content_len = file.info().getheader('Content-Length')
@@ -170,13 +173,13 @@
dt += 60
else:
if pywikibot.verbose:
- pywikibot.warning(
-u"No check length to retrieved data is possible.")
+ pywikibot.warning(u"No check length to retrieved "
+ u"data is possible.")
else:
# Opening local files with MyURLopener would be possible, but we
# don't do it because it only accepts ASCII characters in the
# filename.
- file = open(self.url,"rb")
+ file = open(self.url, "rb")
self._contents = file.read()
file.close()
@@ -255,10 +258,11 @@
If the user chooses not to retry, return null.
"""
- if not self.targetSite.has_api() or self.targetSite.versionnumber() < 16:
+ if not self.targetSite.has_api() or \
+ self.targetSite.versionnumber() < 16:
return self._uploadImageOld(debug)
- if not hasattr(self,'_contents'):
+ if not hasattr(self, '_contents'):
self.read_file_content()
filename = self.process_filename()
@@ -289,14 +293,14 @@
if pywikibot.verbose:
pywikibot.output("%s" % data)
- if 'error' in data: # error occured
+ if 'error' in data: # error occured
errCode = data['error']['code']
pywikibot.output("%s" % data)
else:
data = data['upload']
- if data['result'] == u'Warning': #upload success but return warning.
+ if data['result'] == u'Warning': # upload success but return warning.
pywikibot.output("Got warning message:")
- for k,v in data['warnings'].iteritems():
+ for k, v in data['warnings'].iteritems():
if k == 'duplicate-archive':
pywikibot.output(
"\tThe file is duplicate a deleted file %s." % v)
@@ -328,10 +332,10 @@
#No any warning, upload and online complete.
elif data['result'] == u'Success':
pywikibot.output(u"Upload successful.")
- return filename #data['filename']
+ return filename # data['filename']
def _uploadImageOld(self, debug=False):
- if not hasattr(self,'_contents'):
+ if not hasattr(self, '_contents'):
self.read_file_content()
filename = self.process_filename()
@@ -343,24 +347,24 @@
'wpUploadDescription': self.description,
'wpUploadAffirm': '1',
'wpUpload': 'upload bestand',
- 'wpEditToken': self.targetSite.getToken(), # Get an edit token so we can do the upload
- 'wpDestFile': filename, # Set the new filename
+ 'wpEditToken': self.targetSite.getToken(), # Get an edit token so we can do the upload
+ 'wpDestFile': filename, # Set the new filename
}
# This somehow doesn't work.
if self.ignoreWarning:
formdata["wpIgnoreWarning"] = "1"
if self.uploadByUrl:
- formdata["wpUploadFileURL"] = self.url
+ formdata["wpUploadFileURL"] = self.url
formdata["wpSourceType"] = 'Url'
# try to encode the strings to the encoding used by the target site.
- # if that's not possible (e.g. because there are non-Latin-1 characters and
- # the home Wikipedia uses Latin-1), convert all non-ASCII characters to
- # HTML entities.
+ # if that's not possible (e.g. because there are non-Latin-1 characters
+ # and the home Wikipedia uses Latin-1), convert all non-ASCII
+ # characters to HTML entities.
for key in formdata:
assert isinstance(key, basestring), \
- "ERROR: %s is not a string but %s" % (key, type(key))
+ "ERROR: %s is not a string but %s" % (key, type(key))
try:
formdata[key] = formdata[key].encode(self.targetSite.encoding())
except (UnicodeEncodeError, UnicodeDecodeError):
@@ -381,7 +385,7 @@
self.targetSite, self.targetSite.upload_address(),
formdata.items(),
(('wpUploadFile', encodedFilename, self._contents),),
- cookies = self.targetSite.cookies())
+ cookies=self.targetSite.cookies())
# There are 2 ways MediaWiki can react on success: either it gives
# a 200 with a success message, or it gives a 302 (redirection).
# Do we know how the "success!" HTML page should look like?
@@ -389,7 +393,7 @@
# show an English interface, this detection will fail!
success_msg = self.targetSite.mediawiki_message('successfulupload')
if success_msg in returned_html or response.code == 302:
- pywikibot.output(u"Upload successful.")
+ pywikibot.output(u"Upload successful.")
# The following is not a good idea, because the server also gives a
# 200 when something went wrong.
## if response.code in [200, 302]:
@@ -427,7 +431,8 @@
return self._uploadImageOld(debug)
else:
answer = pywikibot.inputChoice(
-u'Upload of %s probably failed. Above you see the HTML page which was returned by MediaWiki. Try again?'
+ u'Upload of %s probably failed. Above you see the HTML '
+ u'page which was returned by MediaWiki. Try again?'
% filename, ['Yes', 'No'], ['y', 'N'], 'N')
if answer == "y":
return self._uploadImageOld(debug)
--
To view, visit https://gerrit.wikimedia.org/r/98366
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icfdde9e9c6fb32832b582ac88b52f1f0ced19f20
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Change delinker.txt documentation to use Git.
......................................................................
Change delinker.txt documentation to use Git.
Change-Id: If8f082edb82af947e1db7fa0072ae9ce6a15d09e
---
M commonsdelinker/delinker.txt
1 file changed, 3 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/commonsdelinker/delinker.txt b/commonsdelinker/delinker.txt
index 81eb8ca..a96979b 100644
--- a/commonsdelinker/delinker.txt
+++ b/commonsdelinker/delinker.txt
@@ -49,7 +49,7 @@
in plugins.txt.
== Requirements ==
-* A recent SVN checkout of the pywikipedia framework
+* A recent Git clone of the pywikipedia framework
* Python 2.4 or higher
* A MySQL database and the MySQLdb api for Python, version 1.2.1_p or higher
** In the future, probably also sqlite3 will be supported.
@@ -215,9 +215,8 @@
OTHER DEALINGS IN THE SOFTWARE.
The most recent version of this documentation can be found in the
-pywikipedia SVN, on <http://svn.wikimedia.org/svnroot/pywikipedia/
-trunk/pywikipedia/> and browsable on <http://svn.wikimedia.org/viewvc/
-pywikipedia/>. Copies maybe found on meta <http://meta.wikimedia.org/
+pywikipedia Git, <https://git.wikimedia.org/summary/
+pywikibot%2Fcompat.git>. Copies maybe found on meta <http://meta.wikimedia.org/
wiki/CommonsDelinker/For_operators> and BotWiki <http://botwiki.sno.cc/
wiki/Python:CommonsDelinker/For_operators>.
--
To view, visit https://gerrit.wikimedia.org/r/98125
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If8f082edb82af947e1db7fa0072ae9ce6a15d09e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Lewis Cawte <lewis(a)lewiscawte.me>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change and it was merged.
Change subject: [PEP8] changes
......................................................................
[PEP8] changes
Change-Id: Ifea4187e91ba15f14ed154ea8c163dc93feda1f2
---
M wikipedia.py
1 file changed, 30 insertions(+), 26 deletions(-)
Approvals:
Xqt: Looks good to me, approved
diff --git a/wikipedia.py b/wikipedia.py
index e5c9b2b..a5da2cf 100644
--- a/wikipedia.py
+++ b/wikipedia.py
@@ -561,7 +561,7 @@
if not withSection:
sectionName = self.section(underscore=underscore)
if sectionName:
- title = title[:-len(sectionName)-1]
+ title = title[:-len(sectionName) - 1]
return title
#@deprecated("Page.title(withNamespace=False)")
@@ -601,7 +601,7 @@
sectionName = self.section(underscore=underscore)
title = self.title(underscore=underscore)
if sectionName:
- return title[:-len(sectionName)-1]
+ return title[:-len(sectionName) - 1]
else:
return title
@@ -746,7 +746,7 @@
else:
# Make sure we re-raise an exception we got on an earlier attempt
if hasattr(self, '_redirarg') and not get_redirect:
- raise IsRedirectPage, self._redirarg
+ raise IsRedirectPage(self._redirarg)
elif hasattr(self, '_getexception'):
if self._getexception == IsRedirectPage and get_redirect:
pass
@@ -919,7 +919,7 @@
output(u'Getting page %s' % self.title(asLink=True))
path = self.site().edit_address(self.urlname())
if oldid:
- path += "&oldid="+oldid
+ path += "&oldid=" + oldid
# Make sure Brion doesn't get angry by waiting if the last time a page
# was retrieved was not long enough ago.
if throttle:
@@ -2192,12 +2192,12 @@
not calledModuleName() in ('category_redirect', 'cosmetic_changes',
'touch'):
if config.cosmetic_changes_mylang_only:
- cc = (self.site.family.name == config.family and
- self.site.lang == config.mylang) or \
- self.site.family.name in \
- config.cosmetic_changes_enable.keys() and \
+ cc = ((self.site.family.name == config.family and
+ self.site.lang == config.mylang) or
+ self.site.family.name in
+ config.cosmetic_changes_enable.keys() and
self.site.lang in config.cosmetic_changes_enable[
- self.site.family.name]
+ self.site.family.name])
else:
cc = True
cc = cc and not (self.site.family.name in
@@ -2421,10 +2421,14 @@
# 'editconflict':"Edit conflict detected",
raise EditConflict(u'An edit conflict has occured.')
elif errorCode == 'spamdetected':
- # 'spamdetected':"Your edit was refused because it contained a spam fragment: ``\$1''",
+ # 'spamdetected':
+ # "Your edit was refused because it contained a spam
+ # fragment: ``\$1''",
raise SpamfilterError(data['error']['info'][62:-2])
elif errorCode == 'pagedeleted':
- # 'pagedeleted':"The page has been deleted since you fetched its timestamp",
+ # 'pagedeleted':
+ # "The page has been deleted since you fetched its
+ # timestamp",
# Make sure your system clock is correct if this error
# occurs without any reason!
# raise EditConflict(u'Someone deleted the page.')
@@ -2453,7 +2457,9 @@
retry_delay = 30
continue
elif errorCode == 'contenttoobig':
- # 'contenttoobig':"The content you supplied exceeds the article size limit of \$1 kilobytes",
+ # 'contenttoobig':
+ # "The content you supplied exceeds the article size limit
+ # of \$1 kilobytes",
raise LongPageError(len(params['text']),
int(data['error']['info'][59:-10]))
elif errorCode in ['protectedpage', 'customcssjsprotected',
@@ -2609,7 +2615,7 @@
% wait)
dblagged = True
time.sleep(wait)
- wait = min(wait*2, 300)
+ wait = min(wait * 2, 300)
continue
# Squid error 503
raise ServerError(response.code)
@@ -3401,15 +3407,13 @@
now = time.time()
response, data = self.site().postForm(address, predata)
data = data.encode(self.site().encoding())
-## get_throttle.setDelay(time.time() - now)
output = []
- # TODO: parse XML using an actual XML parser instead of regex!
+ # TODO: parse XML using an actual XML parser instead of regex!
r = re.compile(
"\<revision\>.*?\<id\>(?P<id>.*?)\<\/id\>.*?\<timestamp\>"
"(?P<timestamp>.*?)\<\/timestamp\>.*?\<(?:ip|username)\>"
"(?P<user>.*?)\</(?:ip|username)\>.*?\<text.*?\>"
"(?P<content>.*?)\<\/text\>", re.DOTALL)
-## r = re.compile("\<revision\>.*?\<timestamp\>(.*?)\<\/timestamp\>.*?\<(?:ip|username)\>(.*?)\<",re.DOTALL)
return [(match.group('id'),
match.group('timestamp'),
unescape(match.group('user')),
@@ -4035,7 +4039,7 @@
if self._deletedRevs and self._deletedRevsModified:
for ts in self._deletedRevs:
if self._deletedRevs[ts][4]:
- formdata['ts'+ts] = '1'
+ formdata['ts' + ts] = '1'
self._deletedRevs = None
# TODO: Check for errors below (have we succeeded? etc):
@@ -5012,7 +5016,7 @@
else:
raise RuntimeError("unknown type: %s call User:Ladsgroup to fix "
"this" % self._contents['entity'][0])
- self._title = self._title+str(self._contents['entity'][1])
+ self._title += str(self._contents['entity'][1])
return self._contents
@deprecate_arg("get", None)
@@ -5692,8 +5696,8 @@
flag = u"is set to default ('%s'), but should be '%s'" \
% (ns, nshdr)
elif dflt == nshdr:
- flag = u"is '%s', but should be removed (default value '%s')" \
- % (ns, nshdr)
+ flag = (u"is '%s', but should be removed "
+ u"(default value '%s')" % (ns, nshdr))
else:
flag = u"is '%s', but should be '%s'" % (ns, nshdr)
warning(u"Outdated family file %s: namespace['%s'][%i] %s"
@@ -5875,8 +5879,8 @@
flag = u"is set to default ('%s'), but should be '%s'" \
% (ns, nshdr)
elif dflt == nshdr:
- flag = u"is '%s', but should be removed (default value '%s')" \
- % (ns, nshdr)
+ flag = (u"is '%s', but should be removed "
+ u"(default value '%s')" % (ns, nshdr))
else:
flag = u"is '%s', but should be '%s'" % (ns, nshdr)
warning(u"Outdated family file %s: namespace['%s'][%i] %s"
@@ -6035,12 +6039,12 @@
if len(old) % 2 == 0:
# The first two chars represent an Esperanto letter.
# Following x's are doubled.
- new = esperanto + ''.join([old[2 * i]
- for i in xrange(1, len(old)/2)])
+ new = esperanto + ''.join([old[2 * i] for i in
+ xrange(1, len(old) / 2)])
else:
# The first character stays latin; only the x's are doubled.
new = latin + ''.join([old[2 * i + 1]
- for i in xrange(0, len(old)/2)])
+ for i in xrange(0, len(old) / 2)])
result += text[pos: match.start() + pos] + new
pos += match.start() + len(old)
else:
@@ -7768,7 +7772,7 @@
'review', 'stable', 'gblblock', 'renameuser',
'globalauth', 'gblrights', 'abusefilter',
'articlefeedbackv5', 'newusers'):
- raise NotImplementedError, mode
+ raise NotImplementedError(mode)
params = {
'action': 'query',
'list': 'logevents',
--
To view, visit https://gerrit.wikimedia.org/r/98360
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifea4187e91ba15f14ed154ea8c163dc93feda1f2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Make argvu py3 compatible
......................................................................
Make argvu py3 compatible
Change-Id: Iff213b92ba7978da4d68daf42bf56d87023e771b
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 4 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index a5d6ecb..8f7ceb7 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -264,7 +264,10 @@
u'What is the solution of the CAPTCHA at this url ?')
def argvu(self):
- return [s.decode(self.encoding) for s in self.argv]
+ try:
+ return [s.decode(self.encoding) for s in self.argv]
+ except AttributeError: # in python 3, self.argv is unicode and thus cannot be decoded
+ return [s for s in self.argv]
class TerminalHandler(logging.Handler):
--
To view, visit https://gerrit.wikimedia.org/r/98288
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iff213b92ba7978da4d68daf42bf56d87023e771b
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: Change all xrange -> range
......................................................................
Change all xrange -> range
Change-Id: Ia890abf36debc950180a1da753c6795c885a7e1d
---
M pywikibot/date.py
M pywikibot/page.py
M pywikibot/pagegenerators.py
M pywikibot/userinterfaces/terminal_interface_base.py
M pywikibot/userinterfaces/win32_unicode.py
M pywikibot/version.py
M scripts/claimit.py
M scripts/cosmetic_changes.py
M scripts/harvest_template.py
M scripts/interwiki.py
M scripts/replace.py
M tests/site_tests.py
12 files changed, 40 insertions(+), 40 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py
index 6b2e59e..1982449 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -229,28 +229,28 @@
# Helper for KN: digits representation
_knDigits = u'೦೧೨೩೪೫೬೭೮೯'
-_knDigitsToLocal = dict([(ord(unicode(i)), _knDigits[i]) for i in xrange(10)])
-_knLocalToDigits = dict([(ord(_knDigits[i]), unicode(i)) for i in xrange(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 xrange(10)])
-_faLocalToDigits = dict([(ord(_faDigits[i]), unicode(i)) for i in xrange(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 xrange(10)])
-_hiLocalToDigits = dict([(ord(_hiDigits[i]), unicode(i)) for i in xrange(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 xrange(10)])
-_bnLocalToDigits = dict([(ord(_bnDigits[i]), unicode(i)) for i in xrange(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 xrange(10)])
-_guLocalToDigits = dict([(ord(_guDigits[i]), unicode(i)) for i in xrange(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):
@@ -410,7 +410,7 @@
if m:
# decode each found value using provided decoder
values = [decoders[i][2](m.group(i + 1))
- for i in xrange(len(decoders))]
+ for i in range(len(decoders))]
decValue = decf(values)
if isinstance(decValue, basestring):
@@ -438,7 +438,7 @@
% (len(params), len(decoders)))
# convert integer parameters into their textual representation
params = [MakeParameter(decoders[i], params[i])
- for i in xrange(len(params))]
+ for i in range(len(params))]
return strPattern % tuple(params)
else:
if 1 != len(decoders):
@@ -1928,7 +1928,7 @@
if len(patterns) != 12:
raise AssertionError(u'pattern %s does not have 12 elements' % lang)
- for i in xrange(12):
+ for i in range(12):
if patterns[i] is not None:
if isMnthOfYear:
formats[yrMnthFmts[i]][lang] = eval(
@@ -1943,7 +1943,7 @@
def makeMonthList(pattern):
- return [pattern % m for m in xrange(1, 13)]
+ return [pattern % m for m in range(1, 13)]
def makeMonthNamedList(lang, pattern, makeUpperCase=None):
@@ -1960,7 +1960,7 @@
f = lambda s: s[0].upper() + s[1:]
else:
f = lambda s: s[0].lower() + s[1:]
- return [pattern % f(monthName(lang, m)) for m in xrange(1, 13)]
+ return [pattern % f(monthName(lang, m)) for m in range(1, 13)]
#
# Add day of the month formats to the formatting table: "en:May 15"
@@ -2165,7 +2165,7 @@
# Brazil uses "1añ" for the 1st of every month, and number without suffix for
# all other days
brMonthNames = makeMonthNamedList('br', u"%s", True)
-for i in xrange(0, 12):
+for i in range(0, 12):
formats[dayMnthFmts[i]]['br'] = eval(
(u'lambda m: multi(m, [' +
u'(lambda v: dh_dayOfMnth(v, u"%%dañ %s"), lambda p: p == 1),' +
@@ -2195,7 +2195,7 @@
u"Décembre %d"])
addFmt2('he', True, u"%s %%d", True)
addFmt2('it', True, u"Attualità/Anno %%d - %s", True)
-addFmt ('ja', True, [u"「最近の出来事」%%d年%d月" % mm for mm in xrange(1, 13)])
+addFmt ('ja', True, [u"「最近の出来事」%%d年%d月" % mm for mm in range(1, 13)])
addFmt2('ka', True, u"%s, %%d")
addFmt ('ko', True, [u"%d년 1월", u"%d년 2월", u"%d년 3월", u"%d년 4월",
u"%d년 5월", u"%d년 6월", u"%d년 7월", u"%d년 8월",
@@ -2260,7 +2260,7 @@
_formatLimit_DayOfMonth31 = (lambda v: 1 <= v and v < 32, 1, 32)
_formatLimit_DayOfMonth30 = (lambda v: 1 <= v and v < 31, 1, 31)
_formatLimit_DayOfMonth29 = (lambda v: 1 <= v and v < 30, 1, 30)
-for monthId in xrange(12):
+for monthId in range(12):
if (monthId + 1) in (1, 3, 5, 7, 8, 10, 12):
# 31 days a month
formatLimits[dayMnthFmts[monthId]] = _formatLimit_DayOfMonth31
@@ -2355,7 +2355,7 @@
for code, convFunc in formats[formatName].items():
## import time
## startClock = time.clock()
- for value in xrange(start, stop, step):
+ for value in range(start, stop, step):
try:
if not predicate(value):
raise AssertionError(
diff --git a/pywikibot/page.py b/pywikibot/page.py
index c5636bf..0de6559 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1090,7 +1090,7 @@
intkeys[int(key)] = args[key]
except ValueError:
named[key] = args[key]
- for i in xrange(1, len(intkeys) + 1):
+ for i in range(1, len(intkeys) + 1):
# only those args with consecutive integer keys can be
# treated as positional; an integer could also be used
# (out of order) as the key for a named argument
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index baccca5..9580ec3 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -206,7 +206,7 @@
Only call this after all arguments have been parsed.
"""
namespaces = [int(n) for n in self.namespaces]
- for i in xrange(len(self.gens)):
+ for i in range(len(self.gens)):
if isinstance(self.gens[i], pywikibot.data.api.QueryGenerator):
if self.namespaces:
self.gens[i].set_namespace(namespaces)
@@ -768,7 +768,7 @@
if site is None:
site = pywikibot.Site()
# convert namespace names to namespace numbers
- for i in xrange(len(namespaces)):
+ for i in range(len(namespaces)):
ns = namespaces[i]
if isinstance(ns, basestring):
try:
@@ -1275,7 +1275,7 @@
if site is None:
site = pywikibot.Site()
pywikibot.output(u"Starting with year %i" % start)
- for i in xrange(start, end + 1):
+ for i in range(start, end + 1):
if i % 100 == 0:
pywikibot.output(u'Preparing %i...' % i)
# There is no year 0
@@ -1290,8 +1290,8 @@
fd = date.FormatDate(site)
firstPage = pywikibot.Page(site, fd(startMonth, 1))
pywikibot.output(u"Starting with %s" % firstPage.title(asLink=True))
- for month in xrange(startMonth, endMonth + 1):
- for day in xrange(1, date.getNumberOfDaysInMonth(month) + 1):
+ for month in range(startMonth, endMonth + 1):
+ for day in range(1, date.getNumberOfDaysInMonth(month) + 1):
yield pywikibot.Page(pywikibot.Link(fd(month, day), site))
if __name__ == "__main__":
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index a5d6ecb..28f3221 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -135,7 +135,7 @@
# Note: A transliteration replacement might be longer than the
# original character, e.g. ч is transliterated to ch.
prev = "-"
- for i in xrange(len(codecedText)):
+ for i in range(len(codecedText)):
# work on characters that couldn't be encoded, but not on
# original question marks.
if codecedText[i] == '?' and text[i] != u'?':
diff --git a/pywikibot/userinterfaces/win32_unicode.py b/pywikibot/userinterfaces/win32_unicode.py
index 97a611a..c34a6b1 100755
--- a/pywikibot/userinterfaces/win32_unicode.py
+++ b/pywikibot/userinterfaces/win32_unicode.py
@@ -235,7 +235,7 @@
argc = c_int(0)
argv_unicode = CommandLineToArgvW(GetCommandLineW(), byref(argc))
- argv = [argv_unicode[i].encode('utf-8') for i in xrange(0, argc.value)]
+ argv = [argv_unicode[i].encode('utf-8') for i in range(0, argc.value)]
if not hasattr(sys, 'frozen'):
# If this is an executable produced by py2exe or bbfreeze, then it will
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 5e3fc9d..6dd9514 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -94,13 +94,13 @@
tag = tag[:-len(name)]
date = time.gmtime(date / 1000000)
else:
- for i in xrange(3):
+ for i in range(3):
entries.readline()
tag = entries.readline().strip()
t = tag.split('://')
t[1] = t[1].replace('svn.wikimedia.org/svnroot/pywikipedia/', '')
tag = '[%s] %s' % (t[0], t[1])
- for i in xrange(4):
+ for i in range(4):
entries.readline()
date = time.strptime(entries.readline()[:19], '%Y-%m-%dT%H:%M:%S')
rev = entries.readline()[:-1]
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 9d42a7f..db8ff17 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -187,7 +187,7 @@
claims = list()
repo = pywikibot.Site().data_repository()
- for i in xrange(0, len(commandline_claims), 2):
+ for i in range(0, len(commandline_claims), 2):
claim = pywikibot.Claim(repo, commandline_claims[i])
if claim.getType() == 'wikibase-item':
target = pywikibot.ItemPage(repo, commandline_claims[i + 1])
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index d419752..9377964 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -350,7 +350,7 @@
# bug #3346901 should be implemented
continue
# lowerspaced and underscored namespaces
- for i in xrange(len(namespaces)):
+ for i in range(len(namespaces)):
item = namespaces[i].replace(' ', '[ _]')
item = u'[%s%s]' % (item[0], item[0].lower()) + item[1:]
namespaces[i] = item
@@ -765,7 +765,7 @@
return text
# replace persian/arabic digits
## deactivated due to bug #3539407
- for i in xrange(0, 10):
+ for i in range(0, 10):
text = pywikibot.replaceExcept(text, old[i], new[i], exceptions)
# do not change digits in class, style and table params
pattern = re.compile(u'\w+=(".+?"|\d+)', re.UNICODE)
@@ -775,7 +775,7 @@
exceptions.append(pattern)
exceptions.append('table') # exclude tables for now
# replace digits
- for i in xrange(0, 10):
+ for i in range(0, 10):
text = pywikibot.replaceExcept(text, str(i), new[i], exceptions)
return text
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index a0a947f..2507544 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -177,7 +177,7 @@
raise ValueError # or something.
fields = dict()
- for i in xrange(0, len(commandline_arguments), 2):
+ for i in range(0, len(commandline_arguments), 2):
fields[commandline_arguments[i]] = commandline_arguments[i + 1]
generator = gen.getCombinedGenerator()
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index d8764bb..7d5f8a5 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2147,7 +2147,7 @@
% fs.originPage)
pywikibot.output(u"NOTE: Number of pages queued is %d, trying to add %d more."
% (len(self.subjects), number))
- for i in xrange(number):
+ for i in range(number):
try:
while True:
try:
@@ -2306,7 +2306,7 @@
def queryStep(self):
self.oneQuery()
# Delete the ones that are done now.
- for i in xrange(len(self.subjects) - 1, -1, -1):
+ for i in range(len(self.subjects) - 1, -1, -1):
subj = self.subjects[i]
if subj.isDone():
subj.finish()
diff --git a/scripts/replace.py b/scripts/replace.py
index 94a93d6..0be0be8 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -556,7 +556,7 @@
)
elif (len(commandline_replacements) > 1):
if (fix is None):
- for i in xrange(0, len(commandline_replacements), 2):
+ for i in range(0, len(commandline_replacements), 2):
replacements.append((commandline_replacements[i],
commandline_replacements[i + 1]))
if not summary_commandline:
diff --git a/tests/site_tests.py b/tests/site_tests.py
index a3f6d81..b17b274 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -105,7 +105,7 @@
for b in builtins))
ns = mysite.namespaces()
self.assertType(ns, dict)
- self.assertTrue(all(x in ns for x in xrange(0, 16)))
+ self.assertTrue(all(x in ns for x in range(0, 16)))
# built-in namespaces always present
self.assertType(mysite.ns_normalize("project"), basestring)
self.assertTrue(all(isinstance(key, int)
@@ -471,7 +471,7 @@
self.assertTrue(prop in block)
# timestamps should be in descending order
timestamps = [block['timestamp'] for block in bl]
- for t in xrange(1, len(timestamps)):
+ for t in range(1, len(timestamps)):
self.assertTrue(timestamps[t] <= timestamps[t - 1])
b2 = list(mysite.blocks(total=10, reverse=True))
@@ -482,7 +482,7 @@
self.assertTrue(prop in block)
# timestamps should be in ascending order
timestamps = [block['timestamp'] for block in b2]
- for t in xrange(1, len(timestamps)):
+ for t in range(1, len(timestamps)):
self.assertTrue(timestamps[t] >= timestamps[t - 1])
for block in mysite.blocks(starttime="2008-07-01T00:00:01Z", total=5):
--
To view, visit https://gerrit.wikimedia.org/r/98285
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia890abf36debc950180a1da753c6795c885a7e1d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot