jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Replace deprecated site.language() method with site.lang property ......................................................................
[IMPR] Replace deprecated site.language() method with site.lang property
Change-Id: I5cd27cbe175d4365c689158a92fcd083c9061900 --- M scripts/imagecopy.py M scripts/imagecopy_self.py 2 files changed, 21 insertions(+), 22 deletions(-)
Approvals: Xqt: Looks good to me, approved Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py index 6882ebb..ce82757 100644 --- a/scripts/imagecopy.py +++ b/scripts/imagecopy.py @@ -77,7 +77,7 @@ # # Another rewrite by: # (C) Multichill 2008-2011 -# (C) Pywikibot team, 2007-2015 +# (C) Pywikibot team, 2007-2016 # # Distributed under the terms of the MIT license. # @@ -256,7 +256,7 @@
def run(self): """Run the bot.""" - tosend = {'language': self.imagePage.site.language().encode('utf-8'), + tosend = {'language': self.imagePage.site.lang.encode('utf-8'), 'image': self.imagePage.title( withNamespace=False).encode('utf-8'), 'newname': self.newname.encode('utf-8'), @@ -282,7 +282,7 @@
# 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() + + CH = ('\n\n{{BotMoveToCommons|' + self.imagePage.site.lang + '.' + self.imagePage.site.family.name + '|year={{subst:CURRENTYEAR}}|month={{subst:CURRENTMONTHNAME}}' '|day={{subst:CURRENTDAY}}}}' + CH) @@ -307,16 +307,16 @@ imtxt = self.imagePage.get(force=True)
# Remove the move to commons templates - if self.imagePage.site.language() in moveToCommonsTemplate: + if self.imagePage.site.lang in moveToCommonsTemplate: for moveTemplate in moveToCommonsTemplate[ - self.imagePage.site.language()]: + self.imagePage.site.lang]: imtxt = re.sub(u'(?i){{' + moveTemplate + u'[^}]*}}', u'', imtxt)
# add {{NowCommons}} - if self.imagePage.site.language() in nowCommonsTemplate: + if self.imagePage.site.lang in nowCommonsTemplate: addTemplate = nowCommonsTemplate[ - self.imagePage.site.language()] % self.newname + self.imagePage.site.lang] % self.newname else: addTemplate = nowCommonsTemplate['_default'] % self.newname
diff --git a/scripts/imagecopy_self.py b/scripts/imagecopy_self.py index 362b02a..93599b9 100644 --- a/scripts/imagecopy_self.py +++ b/scripts/imagecopy_self.py @@ -45,7 +45,7 @@ # English Wikipedia specific bot by: # (C) Multichill 2010-2012 # -# (C) Pywikibot team, 2010-2015 +# (C) Pywikibot team, 2010-2016 # # Distributed under the terms of the MIT license. # @@ -357,7 +357,7 @@
text = imagepage.get() foundMatch = False - for (regex, replacement) in licenseTemplates[page.site.language()]: + for (regex, replacement) in licenseTemplates[page.site.lang]: match = re.search(regex, text, flags=re.IGNORECASE) if match: foundMatch = True @@ -375,7 +375,7 @@
""" for template in imagepage.templates(): - if template in skipTemplates[imagepage.site.language()]: + if template in skipTemplates[imagepage.site.lang]: pywikibot.output( u'Found %s which is on the template skip list' % template) return True @@ -422,8 +422,7 @@ other_versions = u'' contents = {}
- for key, value in informationFields.get( - imagepage.site.language()).items(): + for key, value in informationFields.get(imagepage.site.lang).items(): contents[value] = u''
templates = imagepage.templatesWithParams() @@ -437,10 +436,10 @@ field = field.lower().replace(u'_', u' ').strip() # See if first part is in fields list if field in informationFields.get( - imagepage.site.language()).keys(): + imagepage.site.lang).keys(): # Ok, field is good, store it. contents[informationFields.get( - imagepage.site.language()).get(field)] = value.strip() + imagepage.site.lang).get(field)] = value.strip()
# We now got the contents from the old information template. # Let's get the info for the new one @@ -480,7 +479,7 @@ # Still have to filter out crap like "see below" or "yes" if contents[u'permission']: # Strip of the license temlate if it's in the permission section - for (regex, repl) in licenseTemplates[imagepage.site.language()]: + for (regex, repl) in licenseTemplates[imagepage.site.lang]: contents[u'permission'] = re.sub(regex, u'', contents[u'permission'], flags=re.IGNORECASE) @@ -501,10 +500,10 @@ # text = re.sub(u'== Licensing ==', u'', text, re.IGNORECASE) # text = re.sub('{{(self|self2)|[^}]+}}', '', text, re.IGNORECASE)
- for toRemove in sourceGarbage[imagepage.site.language()]: + for toRemove in sourceGarbage[imagepage.site.lang]: text = re.sub(toRemove, u'', text, flags=re.IGNORECASE)
- for (regex, repl) in licenseTemplates[imagepage.site.language()]: + for (regex, repl) in licenseTemplates[imagepage.site.lang]: text = re.sub(regex, u'', text, flags=re.IGNORECASE)
text = pywikibot.removeCategoryLinks(text, imagepage.site()).strip() @@ -577,7 +576,7 @@ family = site.family.name result = u'' for (regex, - replacement) in licenseTemplates[imagepage.site.language()]: + replacement) in licenseTemplates[imagepage.site.lang]: match = re.search(regex, text, flags=re.IGNORECASE) if match: result = re.sub(regex, replacement, match.group(0), @@ -967,16 +966,16 @@ imtxt = imagepage.get(force=True)
# Remove the move to commons templates - if imagepage.site.language() in moveToCommonsTemplate: + if imagepage.site.lang in moveToCommonsTemplate: for moveTemplate in moveToCommonsTemplate[ - imagepage.site.language()]: + imagepage.site.lang]: imtxt = re.sub(u'(?i){{' + moveTemplate + u'[^}]*}}', u'', imtxt)
# add {{NowCommons}} - if imagepage.site.language() in nowCommonsTemplate: + if imagepage.site.lang in nowCommonsTemplate: addTemplate = nowCommonsTemplate[ - imagepage.site.language()] % filename + imagepage.site.lang] % filename else: addTemplate = nowCommonsTemplate['_default'] % filename