jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] isbn: Simplify hyphenateIsbnNumber
......................................................................
[IMPROV] isbn: Simplify hyphenateIsbnNumber
As is_valid is called in any case before hyphenating it, it can be
called in one place before any selection happens. Also is_valid does
call getIsbn anyway so the exception at the end can't happen when it
didn't happen in is_valid.
Change-Id: I64dcea54a41ee48724881b201ee3f837002bca40
---
M scripts/isbn.py
1 file changed, 6 insertions(+), 11 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/isbn.py b/scripts/isbn.py
index b9b118e..769f303 100755
--- a/scripts/isbn.py
+++ b/scripts/isbn.py
@@ -1382,14 +1382,15 @@
isbn = match.group('code')
isbn = isbn.upper()
try:
+ is_valid(isbn)
+ except InvalidIsbnException:
+ return isbn
+
+ try:
stdnum.isbn
except NameError:
pass
else:
- try:
- is_valid(isbn)
- except InvalidIsbnException:
- return isbn
i = stdnum.isbn.format(isbn)
return i
@@ -1399,18 +1400,12 @@
pass
else:
try:
- is_valid(isbn)
i = isbn_hyphenate.hyphenate(isbn)
- except (InvalidIsbnException, isbn_hyphenate.IsbnMalformedError,
+ except (isbn_hyphenate.IsbnMalformedError,
isbn_hyphenate.IsbnUnableToHyphenateError):
return isbn
return i
- try:
- is_valid(isbn)
- except InvalidIsbnException:
- # don't change
- return isbn
i = getIsbn(isbn)
i.format()
return i.code
--
To view, visit
https://gerrit.wikimedia.org/r/207058
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I64dcea54a41ee48724881b201ee3f837002bca40
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.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: jenkins-bot <>