Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/756024
)
Change subject: [IMPR] Simplify int assignment
......................................................................
[IMPR] Simplify int assignment
Change-Id: I6e8d2486d40266b5f5f2998c8815f19ecf409e77
---
M scripts/archive/wikisourcetext.py
M scripts/djvutext.py
2 files changed, 6 insertions(+), 12 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
Xqt: Verified; Looks good to me, approved
diff --git a/scripts/archive/wikisourcetext.py b/scripts/archive/wikisourcetext.py
index 6604c31..835b460 100755
--- a/scripts/archive/wikisourcetext.py
+++ b/scripts/archive/wikisourcetext.py
@@ -53,7 +53,7 @@
-always don't bother asking to confirm any of the changes.
"""
#
-# (C) Pywikibot team, 2016-2021
+# (C) Pywikibot team, 2016-2022
#
# Distributed under the terms of the MIT license.
#
@@ -252,11 +252,8 @@
pages = pages.split(',')
for interval in range(len(pages)):
start, sep, end = pages[interval].partition('-')
- start = 1 if not start else int(start)
- if not sep:
- end = start
- else:
- end = int(end) if end else index.num_pages
+ start = int(start or 1)
+ end = int(end or index.num_pages) if sep else start
pages[interval] = (start, end)
# gen yields ProofreadPage objects.
diff --git a/scripts/djvutext.py b/scripts/djvutext.py
index 5c65787..638ea06 100755
--- a/scripts/djvutext.py
+++ b/scripts/djvutext.py
@@ -32,7 +32,7 @@
"""
#
-# (C) Pywikibot team, 2008-2021
+# (C) Pywikibot team, 2008-2022
#
# Distributed under the terms of the MIT license.
#
@@ -182,11 +182,8 @@
pages = pages.split(',')
for i, page_interval in enumerate(pages):
start, sep, end = page_interval.partition('-')
- start = 1 if not start else int(start)
- if not sep:
- end = start
- else:
- end = int(end) if end else djvu.number_of_images()
+ start = int(start or 1)
+ end = int(end or djvu.number_of_images()) if sep else start
pages[i] = (start, end)
site = pywikibot.Site()
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/756024
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6e8d2486d40266b5f5f2998c8815f19ecf409e77
Gerrit-Change-Number: 756024
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged