jenkins-bot has submitted this change and it was merged.
Change subject: [PEP8] pep8 changes
......................................................................
[PEP8] pep8 changes
Change-Id: I9f6283462b2bed90b5d737ed976521901fb17506
---
M commons_category_redirect.py
1 file changed, 27 insertions(+), 19 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/commons_category_redirect.py b/commons_category_redirect.py
index 534bd13..b1a06a5 100644
--- a/commons_category_redirect.py
+++ b/commons_category_redirect.py
@@ -1,60 +1,67 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-Script to clean up http://commons.wikimedia.org/wiki/Category:Non-empty_category_redirects
+Script to clean up
+http://commons.wikimedia.org/wiki/Category:Non-empty_category_redirects
-Moves all images, pages and categories in redirect categories to the target category.
+Moves all images, pages and categories in redirect categories to the target
+category.
"""
#
# (C) Multichill, 2008
-# (C) Pywikipedia team, 2008-2011
+# (C) Pywikibot team, 2008-2013
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id$'
-import wikipedia as pywikibot
-import config, catlib
-from category import *
from datetime import datetime
from datetime import timedelta
-redirect_templates = [u'Category redirect', u'Categoryredirect', u'See cat', u'Seecat', u'Catredirect', u'Cat redirect', u'CatRed', u'Catredir']
+import wikipedia as pywikibot
+import config
+import catlib
+from category import *
+
+redirect_templates = [u'Category redirect', u'Categoryredirect', u'See cat',
+ u'Seecat', u'Catredirect', u'Cat redirect', u'CatRed',
+ u'Catredir']
move_message = u'Moving from [[%s|%s]] to [[%s|%s]] (following [[Template:Category redirect|category redirect]])'
-cooldown = 7 # days
+cooldown = 7 # days
+
def get_redirect_cat(category=None):
- '''
- Return the target category
- '''
+ """ Return the target category """
destination = None
site = pywikibot.getSite(u'commons', u'commons')
for template in category.templatesWithParams():
if ((template[0] in redirect_templates) and (len(template[1]) > 0)):
#destination = template[1][0];
- destination =catlib.Category(site, template[1][0])
+ destination = catlib.Category(site, template[1][0])
if not destination.exists():
return None
return destination
+
def readyToEdit(old_category):
- ''' If the category is edited more recenty than cooldown, return false,
+ """ If the category is edited more recenty than cooldown, return false,
otherwise true.
- '''
- dateformat ="%Y%m%d%H%M%S"
+ """
+ dateformat = "%Y%m%d%H%M%S"
today = datetime.now()
deadline = today + timedelta(days=-cooldown)
old_category.get()
return (deadline.strftime(dateformat) > old_category.editTime())
+
def main():
- ''' Main loop. Loop over all categories of
+ """ Main loop. Loop over all categories of
Category:Non-empty_category_redirects and move all content.
- '''
+ """
site = pywikibot.getSite(u'commons', u'commons')
dirtycat = catlib.Category(site, u'Category:Non-empty category redirects')
@@ -62,8 +69,8 @@
catbot = None
for old_category in dirtycat.subcategories():
- # We want to wait several days after the last edit before we start moving
- # things around. This it to prevent edit wars and vandals.
+ # We want to wait several days after the last edit before we start
+ # moving things around. This it to prevent edit wars and vandals.
if(readyToEdit(old_category)):
destination = get_redirect_cat(old_category)
if destination:
@@ -94,6 +101,7 @@
except:
pywikibot.output(u'Dummy edit at %s failed' % old_category.title())
+
if __name__ == "__main__":
try:
main()
--
To view, visit https://gerrit.wikimedia.org/r/95812
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9f6283462b2bed90b5d737ed976521901fb17506
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change and it was merged.
Change subject: [PEP8] remaining pep8 changes
......................................................................
[PEP8] remaining pep8 changes
Change-Id: I915cba5f57ee3f8e9901ccee039ca2fda932373e
---
M checkimages.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/checkimages.py b/checkimages.py
index da98deb..8f25dfc 100644
--- a/checkimages.py
+++ b/checkimages.py
@@ -1209,7 +1209,7 @@
# Don't report, but continue with the check
# (we don't now if this is the first time we check this file
# or not)
- return True
+ return True
# The talk page includes "_" between the two names, in this way I
# replace them to " "
--
To view, visit https://gerrit.wikimedia.org/r/95811
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I915cba5f57ee3f8e9901ccee039ca2fda932373e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot