jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/561959 )
Change subject: [IMPR] Doc improvements
......................................................................
[IMPR] Doc improvements
- Reword some items
- Keep all of the script specific options together
Change-Id: I721dd5c295deb365331265657c484953d4f1f673
---
M scripts/touch.py
1 file changed, 7 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/touch.py b/scripts/touch.py
index 95cad9c..b610845 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -3,20 +3,17 @@
"""
This bot goes over multiple pages of a wiki, and edits them without changes.
-This is for example used to get category links in templates
-working.
+This is for example used to get category links in templates working.
-This script understands various command-line arguments:
+Command-line arguments:
--purge Do not touch but purge the page
+-purge Purge the page instead of touching it
-¶ms;
-
-Touch arguments:
+Touch mode (default):
-botflag Force botflag in case of edits with changes.
-Purge arguments:
+Purge mode:
-converttitles Convert titles to other variants if necessary
-forcelinkupdate Update the links tables
@@ -24,9 +21,10 @@
for any page that uses this page as a template
-redirects Automatically resolve redirects
+¶ms;
"""
#
-# (C) Pywikibot team, 2009-2019
+# (C) Pywikibot team, 2009-2020
#
# Distributed under the terms of the MIT license.
#
--
To view, visit https://gerrit.wikimedia.org/r/561959
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I721dd5c295deb365331265657c484953d4f1f673
Gerrit-Change-Number: 561959
Gerrit-PatchSet: 4
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/558583 )
Change subject: [IMPR] Avoid deeply nested flow statements
......................................................................
[IMPR] Avoid deeply nested flow statements
- for loop is able to handle empty iterators
- use a tuple with endswith to reduce one for loop
Change-Id: I47c39266b26f6492faa8cc4a9c66a785808224a9
---
M scripts/imagerecat.py
1 file changed, 8 insertions(+), 8 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/imagerecat.py b/scripts/imagerecat.py
index d4db6aa..adeba2a 100755
--- a/scripts/imagerecat.py
+++ b/scripts/imagerecat.py
@@ -148,14 +148,14 @@
for country in countries:
if country in cat:
listCountries.append(country)
- if len(listByCountry) > 0:
- for bc in listByCountry:
- category = pywikibot.Category(
- pywikibot.Site('commons', 'commons'), 'Category:' + bc)
- for subcategory in category.subcategories():
- for country in listCountries:
- if subcategory.title(with_ns=False).endswith(country):
- result.append(subcategory.title(with_ns=False))
+
+ country_tuple = tuple(listCountries)
+ for bc in listByCountry:
+ category = pywikibot.Category(
+ pywikibot.Site('commons', 'commons'), 'Category:' + bc)
+ for subcategory in category.subcategories():
+ if subcategory.title(with_ns=False).endswith(country_tuple):
+ result.append(subcategory.title(with_ns=False))
return list(set(result))
--
To view, visit https://gerrit.wikimedia.org/r/558583
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I47c39266b26f6492faa8cc4a9c66a785808224a9
Gerrit-Change-Number: 558583
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/558544 )
Change subject: [IMPR] Avoid deeply nested flow statements
......................................................................
[IMPR] Avoid deeply nested flow statements
- continue for loop for autoskip
- check newname directly instead of its length
- remove "else" after "break"
Change-Id: I064003e4f395e5485e48613b2b722e658dc7de4c
---
M scripts/imagecopy.py
1 file changed, 47 insertions(+), 45 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py
index b31c3db..efadd9e 100644
--- a/scripts/imagecopy.py
+++ b/scripts/imagecopy.py
@@ -526,60 +526,62 @@
if not page.exists() or page.namespace() != 6 or page.isRedirectPage():
continue
- skip = False
imagepage = pywikibot.FilePage(page.site, page.title())
# First do autoskip.
if doiskip(imagepage.get()):
pywikibot.output('Skipping ' + page.title())
- skip = True
+ continue
+
+ # The first upload is last in the list.
+ try:
+ username = imagepage.latest_file_info.user
+ except NotImplementedError:
+ # No API, using the page file instead
+ (datetime, username, resolution, size,
+ comment) = imagepage.get_file_history().pop()
+
+ skip = False
+ if always:
+ newname = imagepage.title(with_ns=False)
+ CommonsPage = pywikibot.Page(pywikibot.Site('commons',
+ 'commons'),
+ 'File:' + newname)
+ if CommonsPage.exists():
+ continue
else:
- # The first upload is last in the list.
- try:
- username = imagepage.latest_file_info.user
- except NotImplementedError:
- # No API, using the page file instead
- (datetime, username, resolution, size,
- comment) = imagepage.get_file_history().pop()
- if always:
- newname = imagepage.title(with_ns=False)
- CommonsPage = pywikibot.Page(pywikibot.Site('commons',
- 'commons'),
- 'File:' + newname)
- if CommonsPage.exists():
- skip = True
- else:
- while True:
- # Do TkdialogIC to accept/reject and change the name
- newname, skip = TkdialogIC(
- imagepage.title(with_ns=False),
- imagepage.get(), username,
- imagepage.permalink(with_protocol=True),
- imagepage.templates()).getnewname()
+ while True:
+ # Do TkdialogIC to accept/reject and change the name
+ newname, skip = TkdialogIC(
+ imagepage.title(with_ns=False),
+ imagepage.get(), username,
+ imagepage.permalink(with_protocol=True),
+ imagepage.templates()).getnewname()
- if skip:
- pywikibot.output('Skipping this image')
- break
+ if skip:
+ pywikibot.output('Skipping this image')
+ break
- # Did we enter a new name?
- if len(newname) == 0:
- # Take the old name
- newname = imagepage.title(with_ns=False)
- else:
- newname = newname.decode('utf-8')
+ # Did we enter a new name?
+ if not newname:
+ # Take the old name
+ newname = imagepage.title(with_ns=False)
+ else:
+ newname = newname.decode('utf-8')
- # Check if the image already exists
- CommonsPage = pywikibot.Page(
- imagepage.site.image_repository(),
- 'File:' + newname)
- if not CommonsPage.exists():
- break
- else:
- pywikibot.output(
- 'Image already exists, pick another name or '
- 'skip this image')
- # We don't overwrite images, pick another name, go to
- # the start of the loop
+ # Check if the image already exists
+ CommonsPage = pywikibot.Page(
+ imagepage.site.image_repository(),
+ 'File:' + newname)
+
+ if not CommonsPage.exists():
+ break
+
+ pywikibot.output(
+ 'Image already exists, pick another name or '
+ 'skip this image')
+ # We don't overwrite images, pick another name, go to
+ # the start of the loop
if not skip:
imageTransfer(imagepage, newname, category,
--
To view, visit https://gerrit.wikimedia.org/r/558544
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I064003e4f395e5485e48613b2b722e658dc7de4c
Gerrit-Change-Number: 558544
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)