jenkins-bot has submitted this change and it was merged.
Change subject: Use absolute imports of script interdependencies ......................................................................
Use absolute imports of script interdependencies
Python 3.4 does not permit implicit dependencies. Also order imports alphabetically and group by type per pep8.
Change-Id: Iee52149d768384dc2151b933df685a22c2f3ed3a --- M scripts/archivebot.py M scripts/casechecker.py M scripts/cfd.py M scripts/commonscat.py M scripts/imagetransfer.py M scripts/misspelling.py M scripts/nowcommons.py 7 files changed, 38 insertions(+), 23 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py index 49bcf45..84d1e96 100755 --- a/scripts/archivebot.py +++ b/scripts/archivebot.py @@ -331,7 +331,7 @@ self.archiver = archiver # for testing purposes we allow archiver to be None and we are able # to create the a DiscussionPage in this way: - # >>> import pwb, pywikibot as py + # >>> import pywikibot as py # >>> from scripts.archivebot import DiscussionPage # >>> d = DiscussionPage(py.Page(py.Site(), <talk page name>), None) if archiver is None: diff --git a/scripts/casechecker.py b/scripts/casechecker.py index 33afb18..55f03c9 100755 --- a/scripts/casechecker.py +++ b/scripts/casechecker.py @@ -9,14 +9,18 @@ from __future__ import print_function, unicode_literals __version__ = '$Id$'
-import os -import sys -import re import codecs +import os +import re +import sys + import pywikibot + from pywikibot import i18n from pywikibot.data import api from pywikibot.tools import first_lower, first_upper + +from scripts.category import CategoryMoveRobot as CategoryMoveBot
if sys.version_info[0] > 2: xrange = range @@ -417,9 +421,8 @@ elif not dst.exists(): src = self.Page(title) if page['ns'] == 14: - import category dst = self.Page(newTitle) - bot = category.CategoryMoveRobot( + bot = CategoryMoveBot( src.title(withNamespace=False), dst.title(withNamespace=False), self.autonomous, diff --git a/scripts/cfd.py b/scripts/cfd.py index ce8d389..9bbf5b7 100755 --- a/scripts/cfd.py +++ b/scripts/cfd.py @@ -23,9 +23,12 @@ #
import re + import pywikibot + from pywikibot import config2 as config -import category + +from scripts.category import CategoryMoveRobot as CategoryMoveBot
# The location of the CFD working page. cfdPage = u'Wikipedia:Categories for discussion/Working' @@ -139,9 +142,10 @@ pywikibot.output(summary, toStdout=True) robot = None else: - robot = category.CategoryMoveRobot(oldcat=src, newcat=dest, batch=True, - comment=summary, inplace=True, move_oldcat=True, - delete_oldcat=True, deletion_comment=True) + robot = CategoryMoveBot(oldcat=src, newcat=dest, batch=True, + comment=summary, inplace=True, + move_oldcat=True, delete_oldcat=True, + 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 @@ -153,8 +157,8 @@ src, thisDay) else: continue - robot = category.CategoryMoveRobot(oldcat=src, batch=True, comment=summary, - deletion_comment=True, inplace=True) + 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. pass diff --git a/scripts/commonscat.py b/scripts/commonscat.py index 00cc374..09e60a1 100755 --- a/scripts/commonscat.py +++ b/scripts/commonscat.py @@ -64,10 +64,12 @@
import re
-from add_text import add_text import pywikibot + from pywikibot import i18n, pagegenerators, Bot
+from scripts.add_text import add_text + docuReplacements = { '¶ms;': pagegenerators.parameterHelp } diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index 670c809..4421757 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -37,10 +37,13 @@
import re import sys + import pywikibot -import upload + from pywikibot import config, i18n, textlib
+from scripts import upload + copy_message = { 'ar': u"هذه الصورة تم نقلها من %s. الوصف الأصلي كان:\r\n\r\n%s", 'en': u"This image was copied from %s. The original description was:\r\n\r\n%s", diff --git a/scripts/misspelling.py b/scripts/misspelling.py index 05dc7b0..4407fdd 100755 --- a/scripts/misspelling.py +++ b/scripts/misspelling.py @@ -32,9 +32,11 @@ #
import pywikibot + from pywikibot import i18n, pagegenerators from pywikibot.tools import PY2 -from solve_disambiguation import DisambiguationRobot + +from scripts.solve_disambiguation import DisambiguationRobot
if not PY2: basestring = (str, ) diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py index 0066d61..124b1fa 100755 --- a/scripts/nowcommons.py +++ b/scripts/nowcommons.py @@ -61,15 +61,16 @@ __version__ = '$Id$' #
-import sys import re +import sys import webbrowser
import pywikibot + from pywikibot import i18n, Bot from pywikibot import pagegenerators as pg -import image -from imagetransfer import nowCommonsMessage + +from scripts.image import ImageRobot as ImageBot
nowCommons = { '_default': [ @@ -318,7 +319,7 @@
def run(self): commons = pywikibot.Site('commons', 'commons') - comment = i18n.translate(self.site, nowCommonsMessage, fallback=True) + comment = i18n.twtranslate(self.site, 'imagetransfer-nowcommons_notice')
for page in self.getPageGenerator(): if self.getOption('use_hash'): @@ -362,19 +363,19 @@ "\03{lightgreen}%s\03{default}".' % (localImagePage.title(withNamespace=False), commonsImagePage.title(withNamespace=False))) - oImageRobot = image.ImageRobot( + bot = ImageBot( pg.FileLinksGenerator(localImagePage), localImagePage.title(withNamespace=False), commonsImagePage.title(withNamespace=False), '', self.getOption('replacealways'), self.getOption('replaceloose')) - oImageRobot.run() + bot.run() # If the image is used with the urlname the # previous function won't work if len(list(pywikibot.FilePage(self.site, page.title()).usingPages())) > 0 and \ self.getOption('replaceloose'): - oImageRobot = image.ImageRobot( + bot = ImageBot( pg.FileLinksGenerator( localImagePage), localImagePage.title( @@ -383,7 +384,7 @@ withNamespace=False), '', self.getOption('replacealways'), self.getOption('replaceloose')) - oImageRobot.run() + bot.run() # refresh because we want the updated list usingPages = len(list(pywikibot.FilePage( self.site, page.title()).usingPages()))
pywikibot-commits@lists.wikimedia.org