jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Fix argument parsing for logevents
......................................................................
[bugfix] Fix argument parsing for logevents
- arg must not end with ':'
- additional parameters of old <mode>log option is fetched by preparsed value
Change-Id: Iaf0621567af9ab874f6311864d90362d9a2c438a
---
M pywikibot/pagegenerators.py
1 file changed, 12 insertions(+), 13 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 521dd98..498d00e 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -823,34 +823,33 @@
'Maximum subpage depth:')
self.subpage_max_depth = int(value)
return True
- elif arg == '-logevents:':
+ elif arg == '-logevents':
gen = self._parse_log_events(*value.split(','))
elif arg.startswith('-'):
- mode, log, user = arg.partition('log')
+ mode, log, tail = arg.partition('log')
# exclude -log, -nolog
- if log == 'log' and mode not in ['-', '-no']:
+ if log == 'log' and mode not in ['-', '-no'] and not tail:
mode = mode[1:]
- user = user[1:]
total = 500
- if user:
+ if value:
try:
- total = int(user)
+ total = int(value)
except:
- params = user.split(';')
+ params = value.split(';')
if len(params) == 2:
- user, total = params
+ value, total = params
else:
- user = params[0]
+ value = params[0]
else:
- user = None
+ value = None
else:
- user = None
+ value = None
issue_deprecation_warning(
'The usage of "{0}"'.format(arg),
'-logevents:"{0}"'.format(
- ','.join((mode, user or '', str(total)))),
+ ','.join((mode, value or '', str(total)))),
2, ArgumentDeprecationWarning)
- gen = self._parse_log_events(mode, user, total)
+ gen = self._parse_log_events(mode, value, total)
if gen:
self.gens.append(gen)
--
To view, visit https://gerrit.wikimedia.org/r/269858
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf0621567af9ab874f6311864d90362d9a2c438a
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Reduce line length to 100 characters
......................................................................
Reduce line length to 100 characters
This reduces the line length of all files to at most 100 characters.
Change-Id: Ia45d36ea51fd0e69f0a7407fbea83b4e13b56e44
---
M pywikibot/cosmetic_changes.py
M pywikibot/family.py
M pywikibot/page.py
M scripts/cfd.py
M scripts/claimit.py
M scripts/imagecopy.py
M scripts/imagecopy_self.py
M scripts/panoramiopicker.py
M tests/namespace_tests.py
M tox.ini
10 files changed, 271 insertions(+), 175 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
Xqt: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index bf16474..e623e46 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -384,7 +384,8 @@
# TODO: Taking main cats to top
# for name in categories:
- # if re.search(u"(.+?)\|(.{,1}?)",name.title()) or name.title()==name.title().split(":")[0]+title:
+ # if (re.search(u"(.+?)\|(.{,1}?)",name.title()) or
+ # name.title() == name.title().split(":")[0] + title):
# categories.remove(name)
# categories.insert(0, name)
text = textlib.replaceCategoryLinks(text, categories,
@@ -606,7 +607,8 @@
# group <linktrail> is the link trail after ]] which are part of the word.
# note that the definition of 'letter' varies from language to language.
linkR = re.compile(
- r'(?P<newline>[\n]*)\[\[(?P<titleWithSection>[^\]\|]+)(\|(?P<label>[^\]\|]*))?\]\](?P<linktrail>' +
+ r'(?P<newline>[\n]*)\[\[(?P<titleWithSection>[^\]\|]+)'
+ r'(\|(?P<label>[^\]\|]*))?\]\](?P<linktrail>' +
self.site.linktrail() + ')')
text = textlib.replaceExcept(text, linkR, handleOneLink,
diff --git a/pywikibot/family.py b/pywikibot/family.py
index bdfaca3..f430048 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -914,12 +914,6 @@
myfamily = AutoFamily(fam, family_file)
Family._families[fam] = myfamily
return Family._families[fam]
- elif fam == 'lockwiki':
- raise UnknownFamily(
- "Family 'lockwiki' has been removed as it not a public wiki.\n"
- "You may install your own family file for this wiki, and a "
- "old family file may be found at:\n"
- "http://git.wikimedia.org/commitdiff/pywikibot%2Fcore.git/dfdc0c9150fa8e0982…")
try:
# Ignore warnings due to dots in family names.
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 0349676..8e6f4c2 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2390,8 +2390,8 @@
comment = info['comment']
lines.append(u'| %s || %s || %s || %s || <nowiki>%s</nowiki>'
% (datetime, username, resolution, size, comment))
- return u'{| border="1"\n! date/time || username || resolution || size || edit summary\n|----\n' + \
- u'\n|----\n'.join(lines) + '\n|}'
+ return ('{| border="1"\n! date/time || username || resolution || size '
+ '|| edit summary\n|----\n\n|----\n'.join(lines) + '\n|}')
def usingPages(self, step=None, total=None, content=False):
"""
diff --git a/scripts/cfd.py b/scripts/cfd.py
index 849cfb6..63ca86b 100755
--- a/scripts/cfd.py
+++ b/scripts/cfd.py
@@ -125,11 +125,13 @@
dest = m.result.group(2)
thisDay = findDay(src, day)
if mode == "Move" and thisDay != "None":
- summary = "Robot - Moving category " + src + " to [[:Category:" + dest + "]] per [[WP:CFD|CFD]] at " + \
- thisDay + "."
+ summary = (
+ 'Robot - Moving category ' + src + ' to [[:Category:' +
+ dest + ']] per [[WP:CFD|CFD]] at ' + thisDay + '.')
elif mode == "Speedy":
- summary = "Robot - Speedily moving category " + src + " to [[:Category:" + dest + \
- "]] per [[WP:CFDS|CFDS]]."
+ summary = (
+ 'Robot - Speedily moving category ' + src +
+ ' to [[:Category:' + dest + ']] per [[WP:CFDS|CFDS]].')
else:
continue
# If the category is redirect, we do NOT want to move articles to
@@ -148,19 +150,22 @@
deletion_comment=True)
elif m.check(deletecat, line):
src = m.result.group(1)
- # I currently don't see any reason to handle these two cases separately, though
- # if are guaranteed that the category in the "Delete" case is empty, it might be
- # easier to call delete.py on it.
+ # I currently don't see any reason to handle these two cases
+ # separately, though if are guaranteed that the category in the
+ # "Delete" case is empty, it might be easier to call delete.py on
+ # it.
thisDay = findDay(src, day)
if (mode == "Empty" or mode == "Delete") and thisDay != "None":
- summary = 'Robot - Removing category {0} per [[WP:CFD|CFD]] at {1}.'.format(
- src, thisDay)
+ summary = (
+ 'Robot - Removing category {0} per [[WP:CFD|CFD]] '
+ 'at {1}.'.format(src, thisDay))
else:
continue
robot = CategoryMoveBot(oldcat=src, batch=True, comment=summary,
deletion_comment=True, inplace=True)
else:
- # This line does not fit any of our regular expressions, so ignore it.
+ # This line does not fit any of our regular expressions,
+ # so ignore it.
pass
if summary != "" and robot is not None:
pywikibot.output(summary, toStdout=True)
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 93a7a4d..cd2993c 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -101,26 +101,44 @@
# If claim with same property already exists...
if claim.getID() in item.claims:
if self.exists_arg is None or 'p' not in self.exists_arg:
- pywikibot.log('Skipping %s because claim with same property already exists' % (claim.getID(),))
- pywikibot.log('Use the -exists:p option to override this behavior')
+ pywikibot.log(
+ 'Skipping %s because claim with same property '
+ 'already exists' % (claim.getID(),))
+ pywikibot.log(
+ 'Use -exists:p option to override this behavior')
skip = True
else:
- existing_claims = item.claims[claim.getID()] # Existing claims on page of same property
+ # Existing claims on page of same property
+ existing_claims = item.claims[claim.getID()]
for existing in existing_claims:
skip = True # Default value
- # If some attribute of the claim being added matches some attribute in an existing claim
- # of the same property, skip the claim, unless the 'exists' argument overrides it.
- if claim.getTarget() == existing.getTarget() and 't' not in self.exists_arg:
- pywikibot.log('Skipping %s because claim with same target already exists' % (claim.getID(),))
- pywikibot.log('Append \'t\' to the -exists argument to override this behavior')
+ # If some attribute of the claim being added
+ # matches some attribute in an existing claim of
+ # the same property, skip the claim, unless the
+ # 'exists' argument overrides it.
+ if (claim.getTarget() == existing.getTarget() and
+ 't' not in self.exists_arg):
+ pywikibot.log(
+ 'Skipping %s because claim with same target already exists'
+ % (claim.getID(),))
+ pywikibot.log(
+ 'Append \'t\' to -exists argument to override this behavior')
break
- if listsEqual(claim.getSources(), existing.getSources()) and 's' not in self.exists_arg:
- pywikibot.log('Skipping %s because claim with same sources already exists' % (claim.getID(),))
- pywikibot.log('Append \'s\' to the -exists argument to override this behavior')
+ if (listsEqual(claim.getSources(), existing.getSources()) and
+ 's' not in self.exists_arg):
+ pywikibot.log(
+ 'Skipping %s because claim with same sources already exists'
+ % (claim.getID(),))
+ pywikibot.log(
+ 'Append \'s\' to -exists argument to override this behavior')
break
- if listsEqual(claim.qualifiers, existing.qualifiers) and 'q' not in self.exists_arg:
- pywikibot.log('Skipping %s because claim with same qualifiers already exists' % (claim.getID(),))
- pywikibot.log('Append \'q\' to the -exists argument to override this behavior')
+ if (listsEqual(claim.qualifiers, existing.qualifiers) and
+ 'q' not in self.exists_arg):
+ pywikibot.log(
+ 'Skipping %s because claim with same '
+ 'qualifiers already exists' % (claim.getID(),))
+ pywikibot.log(
+ 'Append \'q\' to -exists argument to override this behavior')
break
skip = False
if not skip:
diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py
index 0450fc7..d1b5d6f 100644
--- a/scripts/imagecopy.py
+++ b/scripts/imagecopy.py
@@ -254,7 +254,8 @@
def run(self):
tosend = {'language': self.imagePage.site.language().encode('utf-8'),
- 'image': self.imagePage.title(withNamespace=False).encode('utf-8'),
+ 'image': self.imagePage.title(
+ withNamespace=False).encode('utf-8'),
'newname': self.newname.encode('utf-8'),
'project': self.imagePage.site.family.name.encode('utf-8'),
'username': '',
@@ -276,20 +277,23 @@
CH = self.fixAuthor(CH)
pywikibot.output(CH)
- # I want every picture to be tagged with the bottemplate so i can check my contributions later.
- CH = u'\n\n{{BotMoveToCommons|' + self.imagePage.site.language() + \
- '.' + self.imagePage.site.family.name + \
- '|year={{subst:CURRENTYEAR}}|month={{subst:CURRENTMONTHNAME}}|day={{subst:CURRENTDAY}}}}' + \
- CH
+ # I want every picture to be tagged with the bottemplate so i can check
+ # my contributions later.
+ CH = ('\n\n{{BotMoveToCommons|' + self.imagePage.site.language() +
+ '.' + self.imagePage.site.family.name +
+ '|year={{subst:CURRENTYEAR}}|month={{subst:CURRENTMONTHNAME}}'
+ '|day={{subst:CURRENTDAY}}}}' + CH)
if self.category:
- CH = CH.replace(u'{{subst:Unc}} <!-- Remove this line once you have added categories -->', u'')
+ CH = CH.replace('{{subst:Unc}} <!-- Remove this line once you have '
+ 'added categories -->', '')
CH += u'[[Category:' + self.category + u']]'
bot = upload.UploadRobot(url=self.imagePage.fileUrl(), description=CH,
useFilename=self.newname, keepFilename=True,
verifyDescription=False, ignoreWarning=True,
- targetSite=pywikibot.Site('commons', 'commons'))
+ targetSite=pywikibot.Site('commons',
+ 'commons'))
bot.run()
# Should check if the image actually was uploaded
@@ -301,20 +305,23 @@
# Remove the move to commons templates
if self.imagePage.site.language() in moveToCommonsTemplate:
- for moveTemplate in moveToCommonsTemplate[self.imagePage.site.language()]:
+ for moveTemplate in moveToCommonsTemplate[
+ self.imagePage.site.language()]:
imtxt = re.sub(u'(?i)\{\{' + moveTemplate + u'[^\}]*\}\}',
u'', imtxt)
# add {{NowCommons}}
if self.imagePage.site.language() in nowCommonsTemplate:
- addTemplate = nowCommonsTemplate[self.imagePage.site.language()] % self.newname
+ addTemplate = nowCommonsTemplate[
+ self.imagePage.site.language()] % self.newname
else:
addTemplate = nowCommonsTemplate['_default'] % self.newname
- commentText = i18n.twtranslate(self.imagePage.site,
- 'commons-file-now-available',
- {'localfile': self.imagePage.title(withNamespace=False),
- 'commonsfile': self.newname})
+ commentText = i18n.twtranslate(
+ self.imagePage.site,
+ 'commons-file-now-available',
+ {'localfile': self.imagePage.title(withNamespace=False),
+ 'commonsfile': self.newname})
pywikibot.showDiff(self.imagePage.get(), imtxt + addTemplate)
self.imagePage.put(imtxt + addTemplate, comment=commentText)
@@ -322,27 +329,31 @@
self.gen = pagegenerators.FileLinksGenerator(self.imagePage)
self.preloadingGen = pagegenerators.PreloadingGenerator(self.gen)
- # If the image is uploaded under a different name, replace all instances
+ # If the image is uploaded under a different name, replace all
+ # instances
if self.imagePage.title(withNamespace=False) != self.newname:
- moveSummary = i18n.twtranslate(self.imagePage.site,
- 'commons-file-moved',
- {'localfile': self.imagePage.title(withNamespace=False),
- 'commonsfile': self.newname})
+ moveSummary = i18n.twtranslate(
+ self.imagePage.site,
+ 'commons-file-moved',
+ {'localfile': self.imagePage.title(withNamespace=False),
+ 'commonsfile': self.newname})
- imagebot = image.ImageRobot(generator=self.preloadingGen,
- oldImage=self.imagePage.title(withNamespace=False),
- newImage=self.newname,
- summary=moveSummary, always=True,
- loose=True)
+ imagebot = image.ImageRobot(
+ generator=self.preloadingGen,
+ oldImage=self.imagePage.title(withNamespace=False),
+ newImage=self.newname,
+ summary=moveSummary, always=True, loose=True)
imagebot.run()
return
def fixAuthor(self, pageText):
"""Fix the author field in the information template."""
informationRegex = re.compile(
- u'\|Author\=Original uploader was (?P<author>\[\[:\w+:\w+:\w+\|\w+\]\] at \[.+\])')
+ '\|Author\=Original uploader was '
+ '(?P<author>\[\[:\w+:\w+:\w+\|\w+\]\] at \[.+\])')
selfRegex = re.compile(
- u'\{\{self\|author\=(?P<author>\[\[:\w+:\w+:\w+\|\w+\]\] at \[.+\])\|')
+ '\{\{self\|author\='
+ '(?P<author>\[\[:\w+:\w+:\w+\|\w+\]\] at \[.+\])\|')
# Find the |Author=Original uploader was ....
informationMatch = informationRegex.search(pageText)
@@ -400,7 +411,8 @@
imageinfo = Tkinter.Label(self.root, text='Uploaded by %s.' % uploader)
textarea = Tkinter.Text(self.root)
textarea.insert(Tkinter.END, content.encode('utf-8'))
- textarea.config(state=Tkinter.DISABLED, height=8, width=40, padx=0, pady=0,
+ textarea.config(state=Tkinter.DISABLED,
+ height=8, width=40, padx=0, pady=0,
wrap=Tkinter.WORD, yscrollcommand=scrollbar.set)
scrollbar.config(command=textarea.yview)
self.entry = Tkinter.Entry(self.root)
@@ -413,7 +425,8 @@
command=self.add2_auto_skip)
browser_button = Tkinter.Button(self.root, text='View in browser',
command=self.open_in_browser)
- skip_button = Tkinter.Button(self.root, text="Skip", command=self.skip_file)
+ skip_button = Tkinter.Button(self.root, text='Skip',
+ command=self.skip_file)
ok_button = Tkinter.Button(self.root, text="OK", command=self.ok_file)
# Start grid
@@ -437,7 +450,12 @@
self.root.destroy()
def getnewname(self):
- """Activate the dialog and return the new name and if the image is skipped."""
+ """
+ Activate dialog.
+
+ @return: new name and if the image is skipped
+ @rtype: tuple
+ """
self.root.mainloop()
return (self.changename, self.skip)
@@ -546,13 +564,17 @@
if not CommonsPage.exists():
break
else:
- pywikibot.output('Image already exists, pick another name or skip this image')
- # We dont overwrite images, pick another name, go to the start of the loop
+ pywikibot.output(
+ 'Image already exists, pick another name or '
+ 'skip this image')
+ # We dont overwrite images, pick another name, go to
+ # the start of the loop
if not skip:
imageTransfer(imagepage, newname, category).start()
- pywikibot.output(u'Still ' + str(threading.activeCount()) + u' active threads, lets wait')
+ pywikibot.output('Still ' + str(threading.activeCount()) +
+ ' active threads, lets wait')
for openthread in threading.enumerate():
if openthread != threading.currentThread():
openthread.join()
diff --git a/scripts/imagecopy_self.py b/scripts/imagecopy_self.py
index d4a0a1b..ff5a386 100644
--- a/scripts/imagecopy_self.py
+++ b/scripts/imagecopy_self.py
@@ -162,54 +162,72 @@
licenseTemplates = {
- 'de': [(u'\{\{Bild-CC-by-sa/3\.0/de\}\}[\s\r\n]*\{\{Bild-CC-by-sa/3\.0\}\}[\s\r\n]*\{\{Bild-GFDL-Neu\}\}',
- u'{{Self|Cc-by-sa-3.0-de|Cc-by-sa-3.0|GFDL|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%' +
- u'(family)s.org %(lang)s.%(family)s]}}'),
- (u'\{\{Bild-GFDL\}\}[\s\r\n]*\{\{Bild-CC-by-sa/(\d\.\d)\}\}',
- u'{{Self|GFDL|Cc-by-sa-3.0-migrated|Cc-by-sa-\\1|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang' +
- u')s.%(family)s.org %(lang)s.%(family)s]}}'),
- (u'\{\{Bild-GFDL\}\}',
- u'{{Self|GFDL|Cc-by-sa-3.0-migrated|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%(family)s' +
- u'.org %(lang)s.%(family)s]}}'),
- (u'\{\{Bild-CC-by-sa/(\d\.\d)\}\}',
- u'{{Self|Cc-by-sa-\\1|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%(family)s.org %(lang)s.' +
- u'%(family)s]}}'),
- (u'\{\{Bild-CC-by-sa/(\d\.\d)/de\}\}',
- u'{{Self|Cc-by-sa-\\1-de|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%(family)s.org' +
- u' %(lang)s.%(family)s]}}'),
- (u'\{\{Bild-CC-by/(\d\.\d)\}\}',
- u'{{Self|Cc-by-\\1|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%(family)s.org' +
- u' %(lang)s.%(family)s]}}'),
- (u'\{\{Bild-CC-by/(\d\.\d)/de\}\}',
- u'{{Self|Cc-by-\\1-de|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%(family)s.org' +
- u' %(lang)s.%(family)s]}}'),
- ],
- 'en': [(u'\{\{(self|self2)\|([^\}]+)\}\}',
- u'{{Self|\\2|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%(family)s.org' +
- u' %(lang)s.%(family)s]}}'),
- (u'\{\{(GFDL-self|GFDL-self-no-disclaimers)\|([^\}]+)\}\}',
- u'{{Self|GFDL|\\2|author=[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%(family)s.org' +
- u'%(lang)s.%(family)s]}}'),
- (u'\{\{GFDL-self-with-disclaimers\|([^\}]+)\}\}',
- u'{{Self|GFDL-with-disclaimers|\\1|author=[[:%(lang)s:User:%(author)s|%(author)s]] at' +
- u'[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
- (u'\{\{PD-self(\|date=[^\}]+)?\}\}',
- u'{{PD-user-w|%(lang)s|%(family)s|%(author)s}}'),
- (u'\{\{Multilicense replacing placeholder(\|[^\}\|=]+=[^\}\|]+)*(?P<migration>\|[^\}\|=]+=[^\}\|]+)' +
- u'(\|[^\}\|=]+=[^\}\|]+)*\}\}',
- u'{{Self|GFDL|Cc-by-sa-2.5,2.0,1.0\\g<migration>|author=[[:%(lang)s:User:%(author)s|%(author)s]]' +
- u' at [http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
- (u'\{\{Multilicense replacing placeholder new(\|class=[^\}]+)?\}\}',
- u'{{Self|GFDL|Cc-by-sa-3.0,2.5,2.0,1.0|author=[[:%(lang)s:User:%(author)s|%(author)s]] at' +
- u'[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
- ],
- 'lb': [(u'\{\{(self|self2)\|([^\}]+)\}\}', u'{{Self|\\2|author=[[:%(lang)s:User:%(author)s|%(author)s]]' +
- u' at [http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
- ],
- 'nds-nl': [(u'\{\{PD-eigenwark\}\}', u'{{PD-user-w|%(lang)s|%(family)s|%(author)s}}'),
- ],
- 'shared': [(u'\{\{(self|self2)\|([^\}]+)\}\}', u'{{Self|\\2|author=%(author)s at old wikivoyage shared}}'),
- ],
+ 'de': [
+ ('\{\{Bild-CC-by-sa/3\.0/de\}\}[\s\r\n]*\{\{Bild-CC-by-sa/3\.0\}\}'
+ '[\s\r\n]*\{\{Bild-GFDL-Neu\}\}',
+ '{{Self|Cc-by-sa-3.0-de|Cc-by-sa-3.0|GFDL|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at [http://%(lang)s.%'
+ '(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{Bild-GFDL\}\}[\s\r\n]*\{\{Bild-CC-by-sa/(\d\.\d)\}\}',
+ '{{Self|GFDL|Cc-by-sa-3.0-migrated|Cc-by-sa-\\1|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{Bild-GFDL\}\}',
+ '{{Self|GFDL|Cc-by-sa-3.0-migrated|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{Bild-CC-by-sa/(\d\.\d)\}\}',
+ '{{Self|Cc-by-sa-\\1|author=[[:%(lang)s:User:%(author)s|%(author)s]] '
+ 'at [http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{Bild-CC-by-sa/(\d\.\d)/de\}\}',
+ '{{Self|Cc-by-sa-\\1-de|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{Bild-CC-by/(\d\.\d)\}\}',
+ '{{Self|Cc-by-\\1|author=[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{Bild-CC-by/(\d\.\d)/de\}\}',
+ '{{Self|Cc-by-\\1-de|author=[[:%(lang)s:User:%(author)s|%(author)s]] '
+ 'at [http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ],
+ 'en': [
+ ('\{\{(self|self2)\|([^\}]+)\}\}',
+ '{{Self|\\2|author=[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{(GFDL-self|GFDL-self-no-disclaimers)\|([^\}]+)\}\}',
+ '{{Self|GFDL|\\2|author=[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{GFDL-self-with-disclaimers\|([^\}]+)\}\}',
+ '{{Self|GFDL-with-disclaimers|\\1|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{PD-self(\|date=[^\}]+)?\}\}',
+ '{{PD-user-w|%(lang)s|%(family)s|%(author)s}}'),
+ ('\{\{Multilicense replacing placeholder'
+ '(\|[^\}\|=]+=[^\}\|]+)*(?P<migration>\|[^\}\|=]+=[^\}\|]+)'
+ '(\|[^\}\|=]+=[^\}\|]+)*\}\}',
+ '{{Self|GFDL|Cc-by-sa-2.5,2.0,1.0\\g<migration>|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ('\{\{Multilicense replacing placeholder new(\|class=[^\}]+)?\}\}',
+ '{{Self|GFDL|Cc-by-sa-3.0,2.5,2.0,1.0|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at'
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ],
+ 'lb': [
+ ('\{\{(self|self2)\|([^\}]+)\}\}',
+ '{{Self|\\2|author='
+ '[[:%(lang)s:User:%(author)s|%(author)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]}}'),
+ ],
+ 'nds-nl': [
+ ('\{\{PD-eigenwark\}\}',
+ '{{PD-user-w|%(lang)s|%(family)s|%(author)s}}'),
+ ],
+ 'shared': [
+ ('\{\{(self|self2)\|([^\}]+)\}\}',
+ '{{Self|\\2|author=%(author)s at old wikivoyage shared}}'),
+ ],
}
sourceGarbage = {
@@ -388,9 +406,11 @@
u'skip': False}
def getNewFieldsFromInformation(self, imagepage):
- """Try to extract fields from current information template for the new information template."""
- # fields = [u'location', u'description', u'source', u'date', u'author', u'permission', u'other versions']
- # FIXME: The implementation for German has to be checked for the "strange" fields
+ """Extract fields from current information template for new template."""
+ # fields = ['location', 'description', 'source', 'date', 'author',
+ # 'permission', 'other versions']
+ # FIXME: The implementation for German has to be checked for the
+ # "strange" fields
description = u''
source = u''
@@ -414,11 +434,14 @@
# To lowercase, remove underscores and strip of spaces
field = field.lower().replace(u'_', u' ').strip()
# See if first part is in fields list
- if field in informationFields.get(imagepage.site.language()).keys():
+ if field in informationFields.get(
+ imagepage.site.language()).keys():
# Ok, field is good, store it.
- contents[informationFields.get(imagepage.site.language()).get(field)] = value.strip()
+ contents[informationFields.get(
+ imagepage.site.language()).get(field)] = value.strip()
- # We now got the contents from the old information template. Let's get the info for the new one
+ # We now got the contents from the old information template.
+ # Let's get the info for the new one
# Description
# FIXME: Add {{<lang>|<original text>}} if <lang is valid at Commons
@@ -470,11 +493,11 @@
return (description, date, source, author, permission, other_versions)
def getNewFieldsFromFreetext(self, imagepage):
- """Try to extract fields from free text for the new information template."""
+ """Extract fields from free text for the new information template."""
text = imagepage.get()
# text = re.sub(u'== Summary ==', u'', text, re.IGNORECASE)
# text = re.sub(u'== Licensing ==', u'', text, re.IGNORECASE)
- # text = re.sub(u'\{\{(self|self2)\|[^\}]+\}\}', u'', text, re.IGNORECASE)
+ # text = re.sub('\{\{(self|self2)\|[^\}]+\}\}', '', text, re.IGNORECASE)
for toRemove in sourceGarbage[imagepage.site.language()]:
text = re.sub(toRemove, u'', text, flags=re.IGNORECASE)
@@ -499,28 +522,31 @@
"""
uploadtime = imagepage.getFileVersionHistory()[-1][0]
uploadDatetime = datetime.strptime(uploadtime, u'%Y-%m-%dT%H:%M:%SZ')
- return (u'{{Date|' + str(uploadDatetime.year) + u'|' + str(uploadDatetime.month) + u'|' + str(uploadDatetime.day) +
+ return (u'{{Date|' + str(uploadDatetime.year) + u'|' +
+ str(uploadDatetime.month) + u'|' + str(uploadDatetime.day) +
u'}} (original upload date)')
def getSource(self, imagepage, source=u''):
- """Get the text to put in the source field of the new information template."""
+ """Get text to put in the source field of new information template."""
site = imagepage.site()
lang = site.code
family = site.family.name
if source == u'':
source = u'{{Own}}'
- return source.strip() + u'<BR />Transferred from [http://%(lang)s.%(family)s.org %(lang)s.%(family)s]' \
- % {u'lang': lang, u'family': family}
+ return (source.strip() +
+ '<BR />Transferred from [http://%(lang)s.%(family)s.org '
+ '%(lang)s.%(family)s]') % {u'lang': lang, u'family': family}
def getAuthorText(self, imagepage):
- """Get the original uploader to put in the author field of the new information template."""
+ """Get uploader to put in the author field of information template."""
site = imagepage.site()
lang = site.code
family = site.family.name
firstuploader = self.getAuthor(imagepage)
- return (u'[[:%(lang)s:User:%(firstuploader)s|%(firstuploader)s]] at [http://%(lang)s.%(family)s.org %(lang)s.%(family)s]'
+ return ('[[:%(lang)s:User:%(firstuploader)s|%(firstuploader)s]] at '
+ '[http://%(lang)s.%(family)s.org %(lang)s.%(family)s]'
% {u'lang': lang, u'family': family,
u'firstuploader': firstuploader})
@@ -629,7 +655,8 @@
else:
pywikibot.output('Image already exists, pick another name '
'or skip this image')
- # We dont overwrite images, pick another name, go to the start of the loop
+ # We dont overwrite images, pick another name, go to the
+ # start of the loop
# Put the fields in the queue to be uploaded
self.uploadQueue.put(fields)
@@ -639,7 +666,13 @@
"""The dialog window for image info."""
- def __init__(self, fields): # imagepage, description, date, source, author, licensetemplate, categories):
+ def __init__(self, fields):
+ """Constructor.
+
+ fields:
+ imagepage, description, date, source, author, licensetemplate,
+ categories
+ """
self.root = Tkinter.Tk()
# "%dx%d%+d%+d" % (width, height, xoffset, yoffset)
# Always appear the same size and in the bottom-left corner
@@ -670,27 +703,34 @@
self.scrollbar = Tkinter.Scrollbar(self.root, orient=Tkinter.VERTICAL)
self.old_description = Tkinter.Text(self.root)
- self.old_description.insert(Tkinter.END, self.imagepage.get().encode('utf-8'))
- self.old_description.config(state=Tkinter.DISABLED, height=8, width=140, padx=0, pady=0, wrap=Tkinter.WORD,
+ self.old_description.insert(Tkinter.END,
+ self.imagepage.get().encode('utf-8'))
+ self.old_description.config(state=Tkinter.DISABLED,
+ height=8, width=140, padx=0, pady=0,
+ wrap=Tkinter.WORD,
yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.old_description.yview)
- self.old_description_label = Tkinter.Label(self.root,
- text=u'The old description was : ')
+ self.old_description_label = Tkinter.Label(
+ self.root, text='The old description was : ')
self.new_description_label = Tkinter.Label(self.root,
- text=u'The new fields are : ')
+ text='The new fields are : ')
self.filename_label = Tkinter.Label(self.root, text=u'Filename : ')
- self.information_description_label = Tkinter.Label(self.root,
- text=u'Description : ')
+ self.information_description_label = Tkinter.Label(
+ self.root, text='Description : ')
self.information_date_label = Tkinter.Label(self.root, text=u'Date : ')
- self.information_source_label = Tkinter.Label(self.root, text=u'Source : ')
- self.information_author_label = Tkinter.Label(self.root, text=u'Author : ')
- self.information_permission_label = Tkinter.Label(self.root, text=u'Permission : ')
- self.information_other_versions_label = Tkinter.Label(self.root, text=u'Other versions : ')
+ self.information_source_label = Tkinter.Label(self.root,
+ text='Source : ')
+ self.information_author_label = Tkinter.Label(self.root,
+ text='Author : ')
+ self.information_permission_label = Tkinter.Label(self.root,
+ text='Permission : ')
+ self.information_other_versions_label = Tkinter.Label(
+ self.root, text='Other versions : ')
- self.information_licensetemplate_label = Tkinter.Label(self.root,
- text=u'License : ')
+ self.information_licensetemplate_label = Tkinter.Label(
+ self.root, text='License : ')
self.information_categories_label = Tkinter.Label(self.root,
text=u'Categories : ')
@@ -726,10 +766,13 @@
self.information_licensetemplate.insert(0, self.licensetemplate)
self.information_categories.insert(0, self.categories)
- self.browser_button = Tkinter.Button(self.root, text='View in browser',
+ self.browser_button = Tkinter.Button(self.root,
+ text='View in browser',
command=self.open_in_browser)
- self.skip_button = Tkinter.Button(self.root, text="Skip", command=self.skipFile)
- self.ok_button = Tkinter.Button(self.root, text="OK", command=self.ok_file)
+ self.skip_button = Tkinter.Button(self.root, text='Skip',
+ command=self.skipFile)
+ self.ok_button = Tkinter.Button(self.root, text='OK',
+ command=self.ok_file)
# Start grid
self.old_description_label.grid(row=0, column=0, columnspan=3)
@@ -780,7 +823,7 @@
self.root.destroy()
def getnewmetadata(self):
- """Activate the dialog and return the new name and if the image is skipped."""
+ """Activate dialog and return new name and if the image is skipped."""
self.root.mainloop()
return {u'imagepage': self.imagepage,
@@ -828,10 +871,12 @@
cid = self.buildNewImageDescription(fields)
pywikibot.output(cid)
bot = upload.UploadRobot(url=fields.get('imagepage').fileUrl(),
- description=cid, useFilename=fields.get('filename'),
+ description=cid,
+ useFilename=fields.get('filename'),
keepFilename=True, verifyDescription=False,
ignoreWarning=True,
- targetSite=pywikibot.Site('commons', 'commons'))
+ targetSite=pywikibot.Site('commons',
+ 'commons'))
bot.run()
self.tagNowcommons(fields.get('imagepage'), fields.get('filename'))
@@ -872,7 +917,7 @@
return cid
def getOriginalUploadLog(self, imagepage):
- """Get the original upload log to put at the bottom of the image description page at Commons."""
+ """Get upload log to put at the bottom of the image description page."""
filehistory = imagepage.getFileVersionHistory()
filehistory.reverse()
@@ -884,22 +929,25 @@
imagepage.title()).replace(u'&redirect=no&useskin=monobook', u'')
result = u'== {{Original upload log}} ==\n'
- result += (u'The original description page is/was [http://%(lang)s.%(family)s.org%(sourceimage)s here]. All following' +
- u'user names refer to %(lang)s.%(family)s.\n'
+ result += ('The original description page is/was '
+ '[http://%(lang)s.%(family)s.org%(sourceimage)s here]. '
+ 'All following user names refer to %(lang)s.%(family)s.\n'
% {u'lang': lang, u'family': family,
u'sourceimage': sourceimage})
for (timestamp, username, resolution, size, comment) in filehistory:
date = datetime.strptime(
timestamp, u'%Y-%m-%dT%H:%M:%SZ').strftime('%Y-%m-%d %H:%M')
- result += (u'* %(date)s [[:%(lang)s:user:%(username)s|%(username)s]] %(resolution)s' +
- u' (%(size)s bytes) \'\'<nowiki>%(comment)s</nowiki>\'\'\n' % {
- u'lang': lang,
- u'family': family,
- u'date': date,
- u'username': username,
- u'resolution': resolution,
- u'size': size,
- u'comment': comment})
+ result += (
+ '* %(date)s [[:%(lang)s:user:%(username)s|%(username)s]] '
+ "%(resolution)s (%(size)s bytes) ''"
+ "<nowiki>%(comment)s</nowiki>''\n" % {
+ 'lang': lang,
+ 'family': family,
+ 'date': date,
+ 'username': username,
+ 'resolution': resolution,
+ 'size': size,
+ 'comment': comment})
return result
@@ -913,7 +961,8 @@
# Remove the move to commons templates
if imagepage.site.language() in moveToCommonsTemplate:
- for moveTemplate in moveToCommonsTemplate[imagepage.site.language()]:
+ for moveTemplate in moveToCommonsTemplate[
+ imagepage.site.language()]:
imtxt = re.sub(u'(?i)\{\{' + moveTemplate +
u'[^\}]*\}\}', u'', imtxt)
@@ -933,7 +982,7 @@
imagepage.put(imtxt + addTemplate, comment=commentText)
def replaceUsage(self, imagepage, filename):
- """If the image is uploaded under a different name, replace all usage."""
+ """replace all usage if image is uploaded under a different name."""
if imagepage.title(withNamespace=False) != filename:
gen = pagegenerators.FileLinksGenerator(imagepage)
preloadingGen = pagegenerators.PreloadingGenerator(gen)
@@ -943,10 +992,11 @@
{'localfile': imagepage.title(withNamespace=False),
'commonsfile': filename})
- imagebot = image.ImageRobot(generator=preloadingGen,
- oldImage=imagepage.title(withNamespace=False),
- newImage=filename, summary=moveSummary,
- always=True, loose=True)
+ imagebot = image.ImageRobot(
+ generator=preloadingGen,
+ oldImage=imagepage.title(withNamespace=False),
+ newImage=filename, summary=moveSummary,
+ always=True, loose=True)
imagebot.run()
diff --git a/scripts/panoramiopicker.py b/scripts/panoramiopicker.py
index 5506abd..3d738cb 100644
--- a/scripts/panoramiopicker.py
+++ b/scripts/panoramiopicker.py
@@ -176,7 +176,9 @@
if photoInfo.get(u'license') == u'by-sa':
desc += u'{{Cc-by-sa-3.0}}\n'
if panoramioreview:
- desc += u'{{Panoramioreview|%s|{{subst:CURRENTYEAR}}-{{subst:CURRENTMONTH}}-{{subst:CURRENTDAY2}}}}\n' % (reviewer,)
+ desc += ('{{Panoramioreview|%s|{{subst:CURRENTYEAR}}-'
+ '{{subst:CURRENTMONTH}}-{{subst:CURRENTDAY2}}}}\n'
+ % reviewer)
else:
desc += u'{{Panoramioreview}}\n'
@@ -254,7 +256,8 @@
"""Loop over a set of Panoramio photos."""
i = 0
has_more = True
- url = u'http://www.panoramio.com/map/get_panoramas.php?set=%s&from=%s&to=%s&size=or…'
+ url = ('http://www.panoramio.com/map/get_panoramas.php?'
+ 'set=%s&from=%s&to=%s&size=original')
while has_more:
gotInfo = False
maxtries = 10
diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py
index 2ed8bf9..922ec3b 100644
--- a/tests/namespace_tests.py
+++ b/tests/namespace_tests.py
@@ -211,14 +211,16 @@
a.defaultcontentmodel = 'bar'
s = repr(a)
- r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], defaultcontentmodel=%r)" \
- % (unicode('Foo'), unicode('Foo'), unicode('bar'))
+ r = ('Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], '
+ 'defaultcontentmodel=%r)' %
+ (unicode('Foo'), unicode('Foo'), unicode('bar')))
self.assertEqual(s, r)
a.case = 'upper'
s = repr(a)
- r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], case=%r, defaultcontentmodel=%r)" \
- % (unicode('Foo'), unicode('Foo'), unicode('upper'), unicode('bar'))
+ r = ('Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], '
+ 'case=%r, defaultcontentmodel=%r)' %
+ (unicode('Foo'), unicode('Foo'), unicode('upper'), unicode('bar')))
self.assertEqual(s, r)
b = eval(repr(a))
diff --git a/tox.ini b/tox.ini
index 5437e66..0708150 100644
--- a/tox.ini
+++ b/tox.ini
@@ -112,7 +112,7 @@
# P102,P103: string does contain unindexed parameters; see I36355923
ignore = E402,D105,D211,FI10,FI12,FI13,FI15,FI5,H101,H201,H236,H301,H404,H405,I100,I101
exclude = .tox,.git,./*.egg,ez_setup.py,build,externals,user-config.py,./scripts/i18n/*
-max_line_length = 130
+max_line_length = 100
accept-encodings = utf-8
require-code = true
putty-ignore =
@@ -141,7 +141,7 @@
# see explanations above
ignore = E402
exclude = .tox,.git,./*.egg,ez_setup.py,build,externals,user-config.py,./scripts/i18n/*
-max_line_length = 130
+max_line_length = 100
[pep257]
# see explanations above
--
To view, visit https://gerrit.wikimedia.org/r/186957
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia45d36ea51fd0e69f0a7407fbea83b4e13b56e44
Gerrit-PatchSet: 23
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(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: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [fix] test_detect_failure is no longer valid,
......................................................................
[fix] test_detect_failure is no longer valid,
marked ist with @unittest.expectedFailure until we find another wiki.
Change-Id: Ib9eb16b0222e0182c234e7b1e7b0e28b84f17bc5
---
M tests/site_detect_tests.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_detect_tests.py b/tests/site_detect_tests.py
index 6a8ea4a..beef3b5 100644
--- a/tests/site_detect_tests.py
+++ b/tests/site_detect_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Test for site detection."""
#
-# (C) Pywikibot team, 2014-2015
+# (C) Pywikibot team, 2014-2016
#
# Distributed under the terms of the MIT license.
#
@@ -210,6 +210,7 @@
self.assertSite('http://tfwiki.net/wiki/$1')
self.assertAllPass()
+ @unittest.expectedFailure # Test no longer valid
def test_detect_failure(self):
"""Test detection failure for MediaWiki sites with an API."""
# SSL certificate verification fails
--
To view, visit https://gerrit.wikimedia.org/r/269929
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib9eb16b0222e0182c234e7b1e7b0e28b84f17bc5
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: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: casechecker.py: replace xuniqueCombinations with library functions
......................................................................
casechecker.py: replace xuniqueCombinations with library functions
Replace xuniqueCombinations() with itertools.combinations().
Change-Id: Ifb31aa0963e1edb1d6fc735882d5d9fe43b5b6c3
---
M scripts/casechecker.py
1 file changed, 3 insertions(+), 18 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/casechecker.py b/scripts/casechecker.py
index 06ee014..30f4c8c 100755
--- a/scripts/casechecker.py
+++ b/scripts/casechecker.py
@@ -10,6 +10,7 @@
__version__ = '$Id$'
import codecs
+import itertools
import os
import re
from string import ascii_letters
@@ -27,22 +28,6 @@
if sys.version_info[0] > 2:
xrange = range
-
-#
-# Permutations code was taken from
-# https://code.activestate.com/recipes/190465/
-#
-def xuniqueCombinations(items, n):
- if n == 0:
- yield []
- else:
- for i in xrange(len(items)):
- for cc in xuniqueCombinations(items[i + 1:], n - 1):
- yield [items[i]] + cc
-# End of permutation code
-#
-
-#
# Windows Concole colors
# This code makes this script Windows ONLY!!!
# Feel free to adapt it to another platform
@@ -609,8 +594,8 @@
# latin character.
for itemCntToPick in xrange(0, len(ambigBadWords) + 1):
title2 = title
- for uc in xuniqueCombinations(list(ambigBadWords),
- itemCntToPick):
+ for uc in itertools.combinations(list(ambigBadWords),
+ itemCntToPick):
wordsToLat = ambigBadWords.copy()
for bw in uc:
title2 = title2.replace(bw, mapLcl[bw])
--
To view, visit https://gerrit.wikimedia.org/r/272003
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifb31aa0963e1edb1d6fc735882d5d9fe43b5b6c3
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
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: [bugfix] Deprecate -quick option
......................................................................
[bugfix] Deprecate -quick option
Also remove known issue which is related to old screen scraping code
Bug: T75019
Change-Id: Id1572614294640f25fd6db5ed15fa7ae50245fe2
---
M scripts/welcome.py
1 file changed, 10 insertions(+), 28 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/welcome.py b/scripts/welcome.py
index 7ebcfa6..b531656 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -89,8 +89,6 @@
-quiet Prevents users without contributions are displayed
- -quick Provide quick check by API bulk-retrieve user datas
-
********************************* GUIDE ***********************************
Report, Bad and white list guide:
@@ -147,12 +145,6 @@
NOTE: The white space and <pre></pre> aren't required but I suggest you to
use them.
-*************************** Known issues/FIXMEs ****************************
-* *
-* The regex to load the user might be slightly different from project to *
-* project. (In this case, write to Filnik or the PWRF for help...) *
-* Use a class to group together the functions used. *
-* *
******************************** Badwords **********************************
The list of Badwords of the code is opened. If you think that a word is
@@ -173,8 +165,8 @@
# (C) Filnik, 2007-2011
# (C) Daniel Herding, 2007
# (C) Alex Shih-Han Lin, 2009-2010
-# (C) xqt, 2009-2015
-# (C) Pywikibot team, 2008-2015
+# (C) xqt, 2009-2016
+# (C) Pywikibot team, 2008-2016
#
# Distributed under the terms of the MIT license.
#
@@ -193,9 +185,9 @@
import pywikibot
-from pywikibot import config
-from pywikibot import i18n
+from pywikibot import config, i18n
from pywikibot.tools.formatter import color_format
+from pywikibot.tools import issue_deprecation_warning
if sys.version_info[0] > 2:
unicode = str
@@ -206,16 +198,11 @@
# page/user/summary/etc so the need to specify language and project have
# 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.
+# 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.
############################################################################
-############################################################################
-############################################################################
-
-# The text below are dictionaries. Copy the 'en' line, change 'en' in your
-# language (e.g. 'de') and modify/translate the text.
# The page where the bot will save the log (e.g. Wikipedia:Welcome log).
#
@@ -442,7 +429,6 @@
defaultSign = '--~~~~' # default signature
queryLimit = 50 # number of users that the bot load to check
quiet = False # Prevents users without contributions are displayed
- quick = False # Provide quick check by API bulk-retrieve user datas
class WelcomeBot(object):
@@ -732,12 +718,8 @@
def run(self):
while True:
welcomed_count = 0
- if globalvar.quick and self.site.has_api():
- us = [x for x in self.parseNewUserLog()]
- showStatus()
- pywikibot.User.getall(self.site, us)
- else:
- us = (pywikibot.User(self.site, users.user()) for users in self.parseNewUserLog())
+ us = (pywikibot.User(self.site, users.user())
+ for users in self.parseNewUserLog())
for users in us:
if users.isBlocked():
showStatus(3)
@@ -982,7 +964,7 @@
elif arg == '-quiet':
globalvar.quiet = True
elif arg == '-quick':
- globalvar.quick = True
+ issue_deprecation_warning('The usage of "-quick" option', None, 2)
# Filename and Pywikibot path
# file where is stored the random signature index
--
To view, visit https://gerrit.wikimedia.org/r/269945
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id1572614294640f25fd6db5ed15fa7ae50245fe2
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: interwiki cleanup
......................................................................
interwiki cleanup
interlanguage links are hold by wikidata. interwiki_putfirst dictionary is
not used anymore for most of mw sites and it's content is outdated since more
than 4 years.
Change-Id: I79ccd6b82f341b424cb7d7b43a642d1b62ff0ca9
---
M pywikibot/families/wikibooks_family.py
M pywikibot/families/wikinews_family.py
M pywikibot/families/wikipedia_family.py
M pywikibot/families/wikiquote_family.py
M pywikibot/families/wikisource_family.py
5 files changed, 0 insertions(+), 131 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/wikibooks_family.py b/pywikibot/families/wikibooks_family.py
index b2972ae..4b9ac23 100644
--- a/pywikibot/families/wikibooks_family.py
+++ b/pywikibot/families/wikibooks_family.py
@@ -126,22 +126,6 @@
'af', 'ang', 'ca', 'fa', 'fy', 'it', 'nl', 'ru', 'th', 'zh',
]
- # Which languages have a special order for putting interlanguage links,
- # and what order is it? If a language is not in interwiki_putfirst,
- # alphabetical order on language code is used. For languages that are in
- # interwiki_putfirst, interwiki_putfirst is checked first, and
- # languages are put in the order given there. All other languages are
- # put after those, in code-alphabetical order.
- self.interwiki_putfirst = {
- 'en': self.alphabetic,
- 'fi': self.alphabetic,
- 'fr': self.alphabetic,
- 'he': ['en'],
- 'hu': ['en'],
- 'pl': self.alphabetic,
- 'simple': self.alphabetic
- }
-
# Subpages for documentation.
# TODO: List is incomplete, to be completed for missing languages.
self.doc_subpages = {
diff --git a/pywikibot/families/wikinews_family.py b/pywikibot/families/wikinews_family.py
index a80743a..e6a94d6 100644
--- a/pywikibot/families/wikinews_family.py
+++ b/pywikibot/families/wikinews_family.py
@@ -39,20 +39,5 @@
# https://meta.wikimedia.org/wiki/Bot_policy/Implementation#Current_implement…
self.cross_allowed = ['ca', 'cs', 'en', 'fa', 'ko', ]
- # Which languages have a special order for putting interlanguage links,
- # and what order is it? If a language is not in interwiki_putfirst,
- # alphabetical order on language code is used. For languages that are in
- # interwiki_putfirst, interwiki_putfirst is checked first, and
- # languages are put in the order given there. All other languages are
- # put after those, in code-alphabetical order.
- self.interwiki_putfirst = {
- 'en': self.alphabetic,
- 'fi': self.alphabetic,
- 'fr': self.alphabetic,
- 'he': ['en'],
- 'hu': ['en'],
- 'pl': self.alphabetic,
- }
-
# TODO:
# Change site_tests.py when wikinews will have doc_subpage.
diff --git a/pywikibot/families/wikipedia_family.py b/pywikibot/families/wikipedia_family.py
index 576b5d6..6c11b45 100644
--- a/pywikibot/families/wikipedia_family.py
+++ b/pywikibot/families/wikipedia_family.py
@@ -288,73 +288,6 @@
# but some languages don't use this.
self.nocapitalize = ['jbo']
- # Which languages have a special order for putting interlanguage links,
- # and what order is it? If a language is not in interwiki_putfirst,
- # alphabetical order on language code is used. For languages that are in
- # interwiki_putfirst, interwiki_putfirst is checked first, and
- # languages are put in the order given there. All other languages are
- # put after those, in code-alphabetical order.
-
- self.alphabetic_sr = [
- 'ace', 'kbd', 'af', 'ak', 'als', 'am', 'ang', 'ab', 'ar', 'an',
- 'arc', 'roa-rup', 'frp', 'arz', 'as', 'ast', 'gn', 'av', 'ay', 'az',
- 'bjn', 'id', 'ms', 'bg', 'bm', 'zh-min-nan', 'nan', 'map-bms', 'jv',
- 'su', 'ba', 'be', 'be-tarask', 'bh', 'bcl', 'bi', 'bn', 'bo', 'bar',
- 'bs', 'bpy', 'br', 'bug', 'bxr', 'ca', 'ceb', 'ch', 'cbk-zam', 'sn',
- 'tum', 'ny', 'cho', 'chr', 'co', 'cy', 'cv', 'cs', 'da', 'dk',
- 'pdc', 'de', 'nv', 'dsb', 'na', 'dv', 'dz', 'mh', 'et', 'el', 'eml',
- 'en', 'myv', 'es', 'eo', 'ext', 'eu', 'ee', 'fa', 'hif', 'fo', 'fr',
- 'fy', 'ff', 'fur', 'ga', 'gv', 'sm', 'gag', 'gd', 'gl', 'gan', 'ki',
- 'glk', 'got', 'gu', 'ha', 'hak', 'xal', 'haw', 'he', 'hi', 'ho',
- 'hsb', 'hr', 'hy', 'io', 'ig', 'ii', 'ilo', 'ia', 'ie', 'iu', 'ik',
- 'os', 'xh', 'zu', 'is', 'it', 'ja', 'ka', 'kl', 'kr', 'pam', 'krc',
- 'csb', 'kk', 'kw', 'rw', 'ky', 'mrj', 'rn', 'sw', 'km', 'kn', 'ko',
- 'kv', 'kg', 'ht', 'ks', 'ku', 'kj', 'lad', 'lbe', 'la', 'ltg', 'lv',
- 'to', 'lb', 'lez', 'lt', 'lij', 'li', 'ln', 'lo', 'jbo', 'lg',
- 'lmo', 'hu', 'mk', 'mg', 'mt', 'mi', 'min', 'cdo', 'mwl', 'ml',
- 'mdf', 'mo', 'mn', 'mr', 'mus', 'my', 'mzn', 'nah', 'fj', 'ne',
- 'nl', 'nds-nl', 'cr', 'new', 'nap', 'ce', 'frr', 'pih', 'no', 'nb',
- 'nn', 'nrm', 'nov', 'oc', 'mhr', 'or', 'om', 'ng', 'hz', 'uz', 'pa',
- 'pfl', 'pag', 'pap', 'koi', 'pi', 'pcd', 'pms', 'nds', 'pnb', 'pl',
- 'pt', 'pnt', 'ps', 'aa', 'kaa', 'crh', 'ty', 'ksh', 'ro', 'rmy',
- 'rm', 'qu', 'ru', 'rue', 'sa', 'sah', 'se', 'sg', 'sc', 'sco', 'sd',
- 'stq', 'st', 'nso', 'tn', 'sq', 'si', 'scn', 'simple', 'ss', 'sk',
- 'sl', 'cu', 'szl', 'so', 'ckb', 'srn', 'sr', 'sh', 'fi', 'sv', 'ta',
- 'shi', 'tl', 'kab', 'roa-tara', 'tt', 'te', 'tet', 'th', 'ti', 'vi',
- 'tg', 'tokipona', 'tp', 'tpi', 'chy', 've', 'tr', 'tk', 'tw', 'tyv',
- 'udm', 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vo', 'fiu-vro', 'wa',
- 'vls', 'war', 'wo', 'wuu', 'ts', 'xmf', 'yi', 'yo', 'diq', 'zea',
- 'zh', 'zh-tw', 'zh-cn', 'zh-classical', 'zh-yue', 'bat-smg',
- ]
-
- self.interwiki_putfirst = {
- 'be-tarask': self.alphabetic,
- 'en': self.alphabetic,
- 'et': self.alphabetic_revised,
- 'fi': self.alphabetic_revised,
- 'fiu-vro': self.alphabetic_revised,
- 'fy': self.fyinterwiki,
- 'he': ['en'],
- 'hu': ['en'],
- 'lb': self.alphabetic,
- 'mk': self.alphabetic,
- 'ms': self.alphabetic_revised,
- 'nds': ['nds-nl'],
- 'nds-nl': ['nds'],
- 'nn': ['no', 'sv', 'da'] + self.alphabetic,
- 'no': self.alphabetic,
- 'nv': ['en', 'es'] + self.alphabetic,
- 'pdc': ['de', 'en'],
- 'pl': self.alphabetic,
- 'simple': self.alphabetic,
- 'sr': self.alphabetic_sr,
- 'sv': self.alphabetic,
- 'te': ['en', 'hi', 'kn', 'ta', 'ml'],
- 'ur': ['ar', 'fa', 'en'] + self.alphabetic,
- 'vi': self.alphabetic_revised,
- 'yi': ['en', 'he', 'de']
- }
-
# Languages that used to be coded in iso-8859-1
self.latin1old = [
'de', 'en', 'et', 'es', 'ia', 'la', 'af', 'cs', 'fr', 'pt', 'sl',
diff --git a/pywikibot/families/wikiquote_family.py b/pywikibot/families/wikiquote_family.py
index fc50f85..4992260 100644
--- a/pywikibot/families/wikiquote_family.py
+++ b/pywikibot/families/wikiquote_family.py
@@ -88,23 +88,6 @@
'wo', 'zh',
]
- # Which languages have a special order for putting interlanguage links,
- # and what order is it? If a language is not in interwiki_putfirst,
- # alphabetical order on language code is used. For languages that are in
- # interwiki_putfirst, interwiki_putfirst is checked first, and
- # languages are put in the order given there. All other languages are
- # put after those, in code-alphabetical order.
- self.interwiki_putfirst = {
- 'en': self.alphabetic,
- 'fi': self.alphabetic,
- 'fr': self.alphabetic,
- 'he': ['en'],
- 'hu': ['en'],
- 'pl': self.alphabetic,
- 'simple': self.alphabetic,
- 'pt': self.alphabetic,
- }
-
# Subpages for documentation.
# TODO: List is incomplete, to be completed for missing languages.
self.doc_subpages = {
diff --git a/pywikibot/families/wikisource_family.py b/pywikibot/families/wikisource_family.py
index 4a01b54..ead1392 100644
--- a/pywikibot/families/wikisource_family.py
+++ b/pywikibot/families/wikisource_family.py
@@ -45,22 +45,6 @@
'ca', 'el', 'fa', 'it', 'ko', 'no', 'pl', 'vi', 'zh',
]
- # Which languages have a special order for putting interlanguage links,
- # and what order is it? If a language is not in interwiki_putfirst,
- # alphabetical order on language code is used. For languages that are in
- # interwiki_putfirst, interwiki_putfirst is checked first, and
- # languages are put in the order given there. All other languages are
- # put after those, in code-alphabetical order.
- self.interwiki_putfirst = {
- 'en': self.alphabetic,
- 'fi': self.alphabetic,
- 'fr': self.alphabetic,
- 'he': ['en'],
- 'hu': ['en'],
- 'pl': self.alphabetic,
- 'simple': self.alphabetic
- }
-
self.authornamespaces = {
'_default': [0],
'ar': [102],
--
To view, visit https://gerrit.wikimedia.org/r/271742
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I79ccd6b82f341b424cb7d7b43a642d1b62ff0ca9
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: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Improve fixArabicLetters, add tests
......................................................................
Improve fixArabicLetters, add tests
- Fixed bugs related to python3.
- Corrected use of replaceExcept.
- Added two tests, one for German Wikipedia, one for Persian Wikipedia.
Signed-off-by: xqt <info(a)gno.de>
Change-Id: I421a1f9d2a7ff89584b7b8403b29245402f6cf86
---
M pywikibot/cosmetic_changes.py
M tests/cosmetic_changes_tests.py
2 files changed, 25 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 7fedee0..bf16474 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -50,7 +50,7 @@
"""
#
# (C) xqt, 2009-2015
-# (C) Pywikibot team, 2006-2015
+# (C) Pywikibot team, 2006-2016
#
# Distributed under the terms of the MIT license.
#
@@ -854,7 +854,7 @@
def fixArabicLetters(self, text):
if self.site.code not in ['ckb', 'fa']:
- return
+ return text
exceptions = [
'gallery',
'file',
@@ -880,11 +880,11 @@
faChrs = u'ءاآأإئؤبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیةيك' + digits['fa']
new = digits.pop(self.site.code)
# This only works if there are only two items in digits dict
- old = digits[digits.keys()[0]]
+ old = digits[list(digits.keys())[0]]
# not to let bot edits in latin content
exceptions.append(re.compile(u"[^%(fa)s] *?\"*? *?, *?[^%(fa)s]"
% {'fa': faChrs}))
- text = textlib.replaceExcept(text, u',', u'،', exceptions)
+ text = textlib.replaceExcept(text, ',', '،', exceptions, site=self.site)
if self.site.code == 'ckb':
text = textlib.replaceExcept(text,
'\u0647([.\u060c_<\\]\\s])',
diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py
index cf8b7ae..80a0595 100644
--- a/tests/cosmetic_changes_tests.py
+++ b/tests/cosmetic_changes_tests.py
@@ -214,6 +214,12 @@
self.assertEqual('42 °C',
self.cct.fixTypo('42 ºC'))
+ def test_fixArabicLetters(self):
+ """Test fixArabicLetters."""
+ text = '1234,كىي'
+ # fixArabicLetters must not change text when site is not fa or ckb
+ self.assertEqual(text, self.cct.fixArabicLetters(text))
+
class TestLiveCosmeticChanges(TestCosmeticChanges):
@@ -287,6 +293,21 @@
self.cct.replaceDeprecatedTemplates('{{Quelle|Test}}'))
+class TestCosmeticChangesPersian(TestCosmeticChanges):
+
+ """Test cosmetic changes methods in Persian Wikipedia."""
+
+ family = 'wikipedia'
+ code = 'fa'
+
+ def test_fixArabicLetters(self):
+ """Test fixArabicLetters."""
+ self.assertEqual(self.cct.fixArabicLetters('A,b,ا,۴,'),
+ 'A,b،ا،۴،')
+ self.assertEqual(self.cct.fixArabicLetters('كي'),
+ 'کی')
+ # Once numbering fixes are enabled we can add tests.
+
if __name__ == '__main__':
try:
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/249114
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I421a1f9d2a7ff89584b7b8403b29245402f6cf86
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Ebrahim <ebrahim(a)gnu.org>
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: Add math test to wikibase_tests.py
......................................................................
Add math test to wikibase_tests.py
A follow-up to Ia7345072a1be00920dac37edd15204137222e6a8 now that
there are math properties on Wikidata.
Change-Id: I11608ff50d7cf63c8a0bb994983b16f0a6e17d9f
---
M tests/wikibase_tests.py
1 file changed, 8 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 4ae1542..2c841ba 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -661,6 +661,14 @@
claim.setTarget(target)
self.assertEqual(claim.target, target)
+ def test_set_math(self):
+ """Test setting claim of math type."""
+ wikidata = self.get_repo()
+ claim = pywikibot.Claim(wikidata, 'P2535')
+ self.assertEqual(claim.type, 'math')
+ claim.setTarget('a^2 + b^2 = c^2')
+ self.assertEqual(claim.target, 'a^2 + b^2 = c^2')
+
def test_set_date(self):
"""Test setting claim of time type."""
wikidata = self.get_repo()
--
To view, visit https://gerrit.wikimedia.org/r/270988
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I11608ff50d7cf63c8a0bb994983b16f0a6e17d9f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <lokal.profil(a)gmail.com>
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: pwb.py: make sure pywikibot is correctly loaded before starting a script
......................................................................
pwb.py: make sure pywikibot is correctly loaded before starting a script
generate_user_files.py will load pywikibot with PYWIKIBOT2_NO_USER_CONFIG=2,
which works correctly, but will overwrite command line arguments (pywikibot.argvu).
This makes sure pywikibot is fully loaded before we try to change argv/argvu, by setting
PYWIKIBOT2_NO_USER_CONFIG=2 ourselves if no user-config.py is found.
In addition, add the missing argvu parameter to generate_user_files.py.
Bug: T126880
Change-Id: I0f84e5b739942154f8fe164b47d19cfac47266c0
---
M pwb.py
1 file changed, 8 insertions(+), 5 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index fe2eeec..0c31b26 100755
--- a/pwb.py
+++ b/pwb.py
@@ -64,9 +64,10 @@
try:
import pywikibot # noqa
pwb = pywikibot
- except RuntimeError:
- pwb = lambda: None
- pwb.argvu = []
+ except RuntimeError: # no user-config.py provided
+ os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2'
+ import pywikibot # noqa
+ pwb = pywikibot
def run_python_file(filename, argv, argvu, package=None):
@@ -206,11 +207,13 @@
except RuntimeError as err:
# user-config.py to be created
print("NOTE: 'user-config.py' was not found!")
- if filename is not None and not filename.startswith('generate_'):
+ if not filename.startswith('generate_'):
print("Please follow the prompts to create it:")
run_python_file('generate_user_files.py',
['generate_user_files.py'],
- [])
+ [u'generate_user_files.py'])
+ # because we have loaded pywikibot without user-config.py loaded, we need to re-start
+ # the entire process. Ask the user to do so.
sys.exit(1)
--
To view, visit https://gerrit.wikimedia.org/r/270641
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0f84e5b739942154f8fe164b47d19cfac47266c0
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: pwb.py: make sure pywikibot is correctly loaded before starting a script
......................................................................
pwb.py: make sure pywikibot is correctly loaded before starting a script
generate_user_files.py will load pywikibot with PYWIKIBOT2_NO_USER_CONFIG=2,
which works correctly, but will overwrite command line arguments (pywikibot.argvu).
This makes sure pywikibot is fully loaded before we try to change argv/argvu, by setting
PYWIKIBOT2_NO_USER_CONFIG=2 ourselves if no user-config.py is found.
In addition, add the missing argvu parameter to generate_user_files.py.
Bug: T126880
Change-Id: I0f84e5b739942154f8fe164b47d19cfac47266c0
---
M pwb.py
1 file changed, 6 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index a630c5f..395019e 100755
--- a/pwb.py
+++ b/pwb.py
@@ -77,8 +77,9 @@
except RuntimeError:
remove_modules()
- pwb = lambda: None # noqa: E731
- pwb.argvu = []
+ os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2'
+ import pywikibot # noqa
+ pwb = pywikibot
def run_python_file(filename, argv, argvu, package=None):
@@ -191,7 +192,9 @@
print("Please follow the prompts to create it:")
run_python_file('generate_user_files.py',
['generate_user_files.py'],
- [])
+ ['generate_user_files.py'])
+ # because we have loaded pywikibot without user-config.py loaded, we need to re-start
+ # the entire process. Ask the user to do so.
sys.exit(1)
--
To view, visit https://gerrit.wikimedia.org/r/270642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0f84e5b739942154f8fe164b47d19cfac47266c0
Gerrit-PatchSet: 2
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Block "wbcreateredirect" action when -simulate option is given
......................................................................
Block "wbcreateredirect" action when -simulate option is given
Bug: T126958
Change-Id: Ida658235189cb0ecc3f13ebee32214e2db0d1134
---
M pywikibot/data/api.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index c6f2f0c..0881e62 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1438,6 +1438,7 @@
"wbsetaliases", "wblinktitles", "wbsetsitelink",
"wbcreateclaim", "wbremoveclaims", "wbsetclaimvalue",
"wbsetreference", "wbremovereferences", "wbsetclaim",
+ 'wbcreateredirect',
)
# Client side verification that the request is being performed
# by a logged in user, and warn if it isn't a config username.
--
To view, visit https://gerrit.wikimedia.org/r/270698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ida658235189cb0ecc3f13ebee32214e2db0d1134
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: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: print warning when message was not found in Python script.
......................................................................
print warning when message was not found in Python script.
Change-Id: I5ad6b6c7a82ef37c7d38a1eb55c1a8b6b725ecab
---
M scripts/maintenance/make_i18n_dict.py
1 file changed, 2 insertions(+), 0 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 de37f2c..fa9cca1 100755
--- a/scripts/maintenance/make_i18n_dict.py
+++ b/scripts/maintenance/make_i18n_dict.py
@@ -59,6 +59,8 @@
for msg in args:
if hasattr(self.script, msg):
self.messages[msg] = msg
+ else:
+ print('message {0} not found'.format(msg))
for new, old in kwargs.items():
self.messages[old] = new.replace('_', '-')
self.dict = {}
--
To view, visit https://gerrit.wikimedia.org/r/234947
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5ad6b6c7a82ef37c7d38a1eb55c1a8b6b725ecab
Gerrit-PatchSet: 3
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>