jenkins-bot has submitted this change and it was merged.
Change subject: [SYNC] pep8 changes for isbn.py and sync with compat ......................................................................
[SYNC] pep8 changes for isbn.py and sync with compat
Change-Id: I5afb85b841705d5be1f2bde9823d29eb76626ea2 --- M scripts/isbn.py 1 file changed, 43 insertions(+), 20 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/isbn.py b/scripts/isbn.py index b2eb52a..9af931e 100755 --- a/scripts/isbn.py +++ b/scripts/isbn.py @@ -36,7 +36,7 @@
""" # -# (C) Pywikibot team, 2013 +# (C) Pywikibot team, 2009-2013 # # Distributed under the terms of the MIT license. # @@ -1215,7 +1215,8 @@ publisherRanges = ranges[groupNumber] break else: - raise InvalidIsbnException('ISBN %s: group number unknown.' % self.code) + raise InvalidIsbnException('ISBN %s: group number unknown.' + % self.code)
# Determine the publisher for (start, end) in publisherRanges: @@ -1225,7 +1226,8 @@ rest = rest[length:] break else: - raise InvalidIsbnException('ISBN %s: publisher number unknown.' % self.code) + raise InvalidIsbnException('ISBN %s: publisher number unknown.' + % self.code)
# The rest is the item number and the 1-digit checksum. result += rest[:-1] + '-' + rest[-1] @@ -1251,14 +1253,17 @@ if c.isdigit(): result.append(int(c)) elif c != '-': - raise InvalidIsbnException('The ISBN %s contains invalid characters.' % self.code) + raise InvalidIsbnException( + 'The ISBN %s contains invalid characters.' % self.code) return result
def checkValidity(self): if len(self.digits()) != 13: - raise InvalidIsbnException('The ISBN %s is not 13 digits long.' % self.code) + raise InvalidIsbnException('The ISBN %s is not 13 digits long.' + % self.code) if self.calculateChecksum() != self.digits()[-1]: - raise InvalidIsbnException('The ISBN checksum of %s is incorrect.' % self.code) + raise InvalidIsbnException('The ISBN checksum of %s is incorrect.' + % self.code)
def calculateChecksum(self): # See http://en.wikipedia.org/wiki/ISBN#Check_digit_in_ISBN_13 @@ -1287,7 +1292,8 @@ if c.isdigit() or c in 'Xx': result.append(c) elif c != '-': - raise InvalidIsbnException('The ISBN %s contains invalid characters.' % self.code) + raise InvalidIsbnException( + 'The ISBN %s contains invalid characters.' % self.code) return result
def checkChecksum(self): @@ -1304,14 +1310,19 @@ #print checksum lastDigit = self.digits()[-1] #print lastDigit - if not ((checksum == 10 and lastDigit in 'Xx') or (lastDigit.isdigit() and checksum == int(lastDigit))): - raise InvalidIsbnException('The ISBN checksum of %s is incorrect.' % self.code) + if not ((checksum == 10 and lastDigit in 'Xx') or + (lastDigit.isdigit() and checksum == int(lastDigit))): + raise InvalidIsbnException('The ISBN checksum of %s is incorrect.' + % self.code)
def checkValidity(self): if len(self.digits()) != 10: - raise InvalidIsbnException('The ISBN %s is not 10 digits long.' % self.code) + raise InvalidIsbnException('The ISBN %s is not 10 digits long.' + % self.code) if 'X' in self.digits()[:-1] or 'x' in self.digits()[:-1]: - raise InvalidIsbnException('ISBN %s: X is only allowed at the end of the ISBN.' % self.code) + raise InvalidIsbnException( + 'ISBN %s: X is only allowed at the end of the ISBN.' + % self.code) self.checkChecksum()
def toISBN13(self): @@ -1342,7 +1353,8 @@ try: i = ISBN10(code) except InvalidIsbnException, e10: - raise InvalidIsbnException(u'ISBN-13: %s / ISBN-10: %s' % (e13, e10)) + raise InvalidIsbnException(u'ISBN-13: %s / ISBN-10: %s' + % (e13, e10)) return i
@@ -1387,6 +1399,7 @@
class IsbnBot: + def __init__(self, generator, to13=False, format=False, always=False): self.generator = generator self.to13 = to13 @@ -1413,9 +1426,11 @@ newText = self.isbnR.sub(_hyphenateIsbnNumber, newText) self.save(page, newText) except pywikibot.NoPage: - pywikibot.output(u"Page %s does not exist?!" % page.title(asLink=True)) + pywikibot.output(u"Page %s does not exist?!" + % page.title(asLink=True)) except pywikibot.IsRedirectPage: - pywikibot.output(u"Page %s is a redirect; skipping." % page.title(asLink=True)) + pywikibot.output(u"Page %s is a redirect; skipping." + % page.title(asLink=True)) except pywikibot.LockedPage: pywikibot.output(u"Page %s is locked?!" % page.title(asLink=True))
@@ -1423,10 +1438,13 @@ if text != page.get(): # Show the title of the page we're working on. # Highlight the title in purple. - pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) + pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" + % page.title()) pywikibot.showDiff(page.get(), text) if not self.always: - choice = pywikibot.inputChoice(u'Do you want to accept these changes?', ['Yes', 'No', 'Always yes'], ['y', 'N', 'a'], 'N') + choice = pywikibot.inputChoice( + u'Do you want to accept these changes?', + ['Yes', 'No', 'Always yes'], ['y', 'N', 'a'], 'N') if choice == 'n': return elif choice == 'a': @@ -1436,11 +1454,15 @@ try: page.put(text, comment=self.comment) except pywikibot.EditConflict: - pywikibot.output(u'Skipping %s because of edit conflict' % (page.title(),)) + pywikibot.output(u'Skipping %s because of edit conflict' + % (page.title(),)) except pywikibot.SpamfilterError, e: - pywikibot.output(u'Cannot change %s because of blacklist entry %s' % (page.title(), e.url)) + pywikibot.output( + u'Cannot change %s because of blacklist entry %s' + % (page.title(), e.url)) except pywikibot.LockedPage: - pywikibot.output(u'Skipping %s (locked page)' % (page.title(),)) + pywikibot.output(u'Skipping %s (locked page)' + % (page.title(),)) else: # Save the page in the background. No need to catch exceptions. page.put(text, comment=self.comment, async=True) @@ -1487,7 +1509,8 @@ site = pywikibot.getSite() site.login() if pageTitle: - gen = iter([pywikibot.Page(pywikibot.Link(t, site)) for t in pageTitle]) + gen = iter([pywikibot.Page(pywikibot.Link(t, site)) + for t in pageTitle]) if not gen: gen = genFactory.getCombinedGenerator() if not gen:
pywikibot-commits@lists.wikimedia.org