jenkins-bot has submitted this change and it was merged.
Change subject: Add ordereddict dependency for Python 2.6
......................................................................
Add ordereddict dependency for Python 2.6
For Python2.6, add dependency on the ordereddict module in setup.py,
and report an error in pwb.py and tests.__init__ if the ordereddict
module is not available.
Change-Id: I09388eee1ceccd9d95c34fef4dbd2e3d421c162c
---
M pwb.py
M setup.py
M tests/__init__.py
3 files changed, 36 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index c8f0cf8..31a585a 100644
--- a/pwb.py
+++ b/pwb.py
@@ -125,6 +125,15 @@
"Try running 'git submodule update --init'.")
sys.exit(1)
+if sys.version_info[0] == 2 and sys.version_info[1] == 6:
+ try:
+ import ordereddict
+ except ImportError as e:
+ print("ImportError: %s" % e)
+ print("pywikibot depends on module ordereddict in Python 2.6.")
+ print("Upgrade to Python 2.7, or run 'pip install ordereddict'")
+ sys.exit(1)
+
if "PYWIKIBOT2_DIR" not in os.environ:
os.environ["PYWIKIBOT2_DIR"] = os.path.split(__file__)[0]
diff --git a/setup.py b/setup.py
index 6682b3f..4dfcbce 100644
--- a/setup.py
+++ b/setup.py
@@ -42,6 +42,7 @@
test_deps.append('unittest2')
script_deps['replicate_wiki.py'] = ['argparse']
testcollector = "tests.utils.collector"
+ dependencies.append('ordereddict')
if sys.version_info[0] == 3:
if not os.environ.get('PY3', False):
diff --git a/tests/__init__.py b/tests/__init__.py
index a7fc7fc..6f85ad7 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -7,6 +7,32 @@
__version__ = '$Id$'
import os
+import sys
+
+# Verify that the unit tests have a base working environment:
+# - httplib2 is mandatory
+# - ordereddict is only needed as a fallback for python 2.6
+# - mwparserfromhell is optional, so is only imported in textlib_tests
+try:
+ import httplib2
+except ImportError as e:
+ print("ImportError: %s" % e)
+ sys.exit(1)
+
+try:
+ from collections import OrderedDict
+except ImportError:
+ try:
+ from ordereddict import OrderedDict
+ except ImportError as e:
+ print("ImportError: %s" % e)
+ if sys.version_info[0] == 2 and sys.version_info[1] == 6:
+ print(
+ "pywikibot depends on module ordereddict in Python 2.6.\n"
+ "Run 'pip install ordereddict' to run these tests under "
+ "Python 2.6")
+ sys.exit(1)
+
import pywikibot.data.api
from pywikibot.data.api import Request as _original_Request
from pywikibot.data.api import CachedRequest
--
To view, visit https://gerrit.wikimedia.org/r/138318
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I09388eee1ceccd9d95c34fef4dbd2e3d421c162c
Gerrit-PatchSet: 8
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Bthfan <bth-fan(a)mcsmurf.de>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Underlying lk <a375070(a)drdrb.net>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Updated all docstrings to be PEP257 complaint.
......................................................................
Updated all docstrings to be PEP257 complaint.
Used pep257 from pypi to verify changes:
https://pypi.python.org/pypi/pep257
Didn't add any docstrings only made already existing complaint,
so the script is still posting D102 errors (D102: Docstring missing).
Change-Id: I8e07842dc3a08eba4e91bbf9d831f4f3cb9b9a4c
---
M scripts/category.py
1 file changed, 53 insertions(+), 27 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index f5f5719..f0b0ebf 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -132,10 +132,9 @@
class CategoryDatabase:
- """This is a temporary knowledge base saving for each category the contained
- subcategories and articles, so that category pages do not need to be loaded
- over and over again
+ """Temporary database saving pages and subcategories for each category.
+ This prevents loading the category pages over and over again.
"""
def __init__(self, rebuild=False, filename='category.dump.bz2'):
@@ -165,10 +164,10 @@
self.superclassDB = {}
def getSubcats(self, supercat):
- """For a given supercategory, return a list of Categorys for all its
- subcategories. Saves this list in a temporary database so that it won't
- be loaded from the server next time it's required.
+ """Return the list of subcategories for a given supercategory.
+ Saves this list in a temporary database so that it won't be loaded from
+ the server next time it's required.
"""
# if we already know which subcategories exist here
if supercat in self.catContentDB:
@@ -181,10 +180,10 @@
return subcatset
def getArticles(self, cat):
- """For a given category, return a list of Pages for all its articles.
+ """Return the list of pages for a given category.
+
Saves this list in a temporary database so that it won't be loaded from
the server next time it's required.
-
"""
# if we already know which articles exist here
if cat in self.catContentDB:
@@ -207,8 +206,11 @@
return supercatset
def dump(self, filename='category.dump.bz2'):
- """Save the contents of the dictionaries superclassDB and catContentDB
- to disk.
+ """Save the dictionaries to disk if not empty.
+
+ Pickle the contents of the dictionaries superclassDB and catContentDB
+ if at least one is not empty. If both are empty, removes the file from
+ the disk.
"""
if not os.path.isabs(filename):
filename = config.datafilepath(filename)
@@ -394,9 +396,13 @@
class CategoryMoveRobot(object):
- """Bot to move pages from one category to another or to remove
- pages from categories. The bot moves per default pages and
- subcategories.
+ """Change or remove the category from the pages.
+
+ If the new category is given changes the category from the old to the new
+ one. Otherwise remove the category from the page and the category if it's
+ empty.
+
+ Per default the operation applies to pages and subcategories.
"""
DELETION_COMMENT_AUTOMATIC = 0
@@ -494,7 +500,13 @@
def run(self):
"""The main bot function that does all the work.
- For readability it is splitted into several helper functions.
+
+ For readability it is splitted into several helper functions:
+ - _movecat()
+ - _movetalk()
+ - _hist()
+ - _change()
+ - _delete()
"""
if self.newcat and self.move_oldcat and not self.newcat.exists():
if "move-categorypages" in self.site.userinfo["rights"]:
@@ -516,7 +528,9 @@
def _delete(self):
"""Private function to delete the category page and its talk page.
- Do not use this function from outside the class.
+
+ Do not use this function from outside the class. Automatically marks
+ the pages if they can't be removed due to missing permissions.
"""
self.oldcat.delete(self.deletion_comment,
not self.batch, mark=True)
@@ -527,6 +541,7 @@
def _change(self, gen):
"""Private function to move category contents.
+
Do not use this function from outside the class.
@param gen: Generator containing pages or categories.
@@ -540,6 +555,7 @@
def _movecat(self):
"""Private function to move the category page.
+
Do not use this function from outside the class.
"""
# Some preparing
@@ -565,6 +581,7 @@
def _movetalk(self):
"""Private function to move the category talk page.
+
Do not use this function from outside the class.
"""
if self.oldtalk.exists():
@@ -574,9 +591,10 @@
self.oldtalk.move(self.newtalk.title(), comment)
def _hist(self):
- """Private function to create a history table with the history
- of the old category on the new talk page.
- Do not use this function from outside the class.
+ """Private function to copy the history of the to-be-deleted category.
+
+ Do not use this function from outside the class. It adds a table with
+ the history of the old category on the new talk page.
"""
history = self.oldcat.getVersionHistoryTable()
title = i18n.twtranslate(self.site, 'category-section-title',
@@ -588,9 +606,12 @@
self.newtalk.save(comment)
def _makecat(self, var):
- """Private helper function to get a Category object either from
- a string or use just use the given one (for backwards
- compatibility).
+ """Private helper function to get a Category object.
+
+ Checks if the instance given is a Category object and returns it.
+ Otherwise creates a new object using the value as the title (for
+ backwards compatibility).
+ @param var: Either the title as a string or a Category object.
"""
if not isinstance(var, pywikibot.Category):
var = pywikibot.Category(self.site, var)
@@ -679,8 +700,7 @@
class CategoryTidyRobot:
- """Script to help a human to tidy up a category by moving its articles into
- subcategories
+ """Script to help by moving articles of the category into subcategories.
Specify the category name on the command line. The program will pick up the
page, and look for all subcategories and supercategories, and show them with
@@ -713,6 +733,8 @@
def move_to_category(self, article, original_cat, current_cat):
"""
+ Ask if it should be moved to one of the subcategories.
+
Given an article which is in category original_cat, ask the user if
it should be moved to one of original_cat's subcategories.
Recursively run through subcategories' subcategories.
@@ -861,8 +883,10 @@
self.site = pywikibot.Site()
def treeview(self, cat, currentDepth=0, parent=None):
- """ Return a multi-line string which contains a tree view of all
- subcategories of cat, up to level maxDepth. Recursively calls itself.
+ """ Return a tree view of all subcategories of cat.
+
+ The multi-line string contains a tree view of all subcategories of cat,
+ up to level maxDepth. Recursively calls itself.
Parameters:
* cat - the Category of the node we're currently opening
@@ -904,8 +928,10 @@
return result
def run(self):
- """Print the multi-line string generated by treeview or save it to a
- file.
+ """Handle the multi-line string generated by treeview.
+
+ After string was generated by treeview it is either printed to the
+ console or saved it to a file.
Parameters:
* catTitle - the title of the category which will be the tree's root
--
To view, visit https://gerrit.wikimedia.org/r/151438
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8e07842dc3a08eba4e91bbf9d831f4f3cb9b9a4c
Gerrit-PatchSet: 2
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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: Replaced CategoryRemoveRobot with CategoryMoveRobot.
......................................................................
Replaced CategoryRemoveRobot with CategoryMoveRobot.
Deprecated CategoryRemoveRobot.__init__().
Changed the call in the main() function.
Change-Id: I4dc8ffe66530aad46283be53423d1e9eb33f8b49
---
M scripts/category.py
1 file changed, 39 insertions(+), 73 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index 4d7d5b8..f5f5719 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -106,7 +106,7 @@
import pywikibot
from pywikibot import config, pagegenerators
from pywikibot import i18n
-from pywikibot import deprecate_arg
+from pywikibot import deprecate_arg, deprecated
# This is required for the text that is shown when you run this script
# with the parameter -help.
@@ -597,6 +597,35 @@
return var
+class CategoryRemoveRobot(CategoryMoveRobot):
+
+ """Removes the category tag for a given category.
+
+ It always removes the category tag for all pages in that given category.
+
+ If pagesonly parameter is False it removes also the category from all
+ subcategories, without prompting. If the category is empty, it will be
+ tagged for deleting. Does not remove category tags pointing at
+ subcategories.
+
+ @deprecated: Using CategoryRemoveRobot is deprecated, use
+ CategoryMoveRobot without newcat param instead.
+ """
+
+ @deprecated('CategoryMoveRobot.__init__()')
+ def __init__(self, catTitle, batchMode=False, editSummary='',
+ useSummaryForDeletion=CategoryMoveRobot.DELETION_COMMENT_AUTOMATIC,
+ titleRegex=None, inPlace=False, pagesonly=False):
+ CategoryMoveRobot.__init__(
+ oldcat=catTitle,
+ batch=batchMode,
+ comment=editSummary,
+ deletion_comment=useSummaryForDeletion,
+ title_regex=titleRegex,
+ inplace=inPlace,
+ pagesonly=pagesonly)
+
+
class CategoryListifyRobot:
"""Create a list containing all of the members in a category."""
@@ -646,75 +675,6 @@
% self.list.title())
else:
self.list.put(listString, comment=self.editSummary)
-
-
-class CategoryRemoveRobot:
-
- """Remove the category tag from all pages in a given category
- and if pagesonly parameter is False also from the category pages of all
- subcategories, without prompting.
- If the category is empty, it will be tagged for deletion.
- Do not remove category tags pointing at subcategories.
-
- """
-
- def __init__(self, catTitle, batchMode=False, editSummary='',
- useSummaryForDeletion=True, titleRegex=None, inPlace=False,
- pagesonly=False):
- self.editSummary = editSummary
- self.site = pywikibot.Site()
- self.cat = pywikibot.Category(self.site, catTitle)
- # get edit summary message
- self.useSummaryForDeletion = useSummaryForDeletion
- self.batchMode = batchMode
- self.titleRegex = titleRegex
- self.inPlace = inPlace
- self.pagesonly = pagesonly
- if not self.editSummary:
- self.editSummary = i18n.twtranslate(self.site, 'category-removing',
- {'oldcat': self.cat.title()})
-
- def run(self):
- empty = True
- for article in self.cat.articles():
- empty = False
- if not self.titleRegex or re.search(self.titleRegex,
- article.title()):
- article.change_category(self.cat, None,
- comment=self.editSummary,
- inPlace=self.inPlace)
- if empty:
- pywikibot.output(u'There are no pages in category %s'
- % self.cat.title())
- if self.pagesonly:
- return
-
- # Also removes the category tag from subcategories' pages
- empty = True
- for subcategory in self.cat.subcategories():
- empty = False
- subcategory.change_category(self.cat, None,
- comment=self.editSummary,
- inPlace=self.inPlace)
- if empty:
- pywikibot.output(u'There are no subcategories in category %s'
- % self.cat.title())
- # Deletes the category page
- if self.cat.exists() and self.cat.isEmptyCategory():
- if self.useSummaryForDeletion and self.editSummary:
- reason = self.editSummary
- else:
- reason = i18n.twtranslate(self.site, 'category-was-disbanded')
- talkPage = self.cat.toggleTalkPage()
- try:
- self.cat.delete(reason, not self.batchMode)
- except pywikibot.NoUsername:
- pywikibot.output(
- u'You\'re not setup sysop info, category will not delete.'
- % self.cat.site())
- return
- if (talkPage.exists()):
- talkPage.delete(reason=reason, prompt=not self.batchMode)
class CategoryTidyRobot:
@@ -1068,9 +1028,15 @@
if not fromGiven:
oldCatTitle = pywikibot.input(u'Please enter the name of the '
u'category that should be removed:')
- bot = CategoryRemoveRobot(oldCatTitle, batchMode, editSummary,
- useSummaryForDeletion, inPlace=inPlace,
- pagesonly=pagesonly)
+ bot = CategoryMoveRobot(oldcat=oldCatTitle,
+ batch=batchMode,
+ comment=editSummary,
+ inplace=inPlace,
+ delete_oldcat=deleteEmptySourceCat,
+ title_regex=titleRegex,
+ history=withHistory,
+ pagesonly=pagesonly,
+ deletion_comment=useSummaryForDeletion)
bot.run()
elif action == 'move':
if not fromGiven:
--
To view, visit https://gerrit.wikimedia.org/r/126822
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4dc8ffe66530aad46283be53423d1e9eb33f8b49
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Pyfisch <pyfisch(a)gmail.com>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Added deletion_comment param to CategoryMoveRobot
......................................................................
Added deletion_comment param to CategoryMoveRobot
deletion_comment is added for merging
CategoryMoveRobot and CategoryRemoveRobot,
deletion_comment replaces useSummaryForDeletion
and does much more.
It has 3 options:
1. Plain string for deletion comment.
2. Same comment as used as move summary.
3. Automatic message.
Change-Id: I9a1c0ceb0a2de4ed1f4e87ab83b1e590d1843d40
---
M scripts/category.py
1 file changed, 62 insertions(+), 25 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index 7a1c76a..4d7d5b8 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -399,6 +399,9 @@
subcategories.
"""
+ DELETION_COMMENT_AUTOMATIC = 0
+ DELETION_COMMENT_SAME_AS_EDIT_COMMENT = 1
+
@deprecate_arg("oldCatTitle", "oldcat")
@deprecate_arg("newCatTitle", "newcat")
@deprecate_arg("batchMode", "batch")
@@ -410,7 +413,8 @@
@deprecate_arg("withHistory", "history")
def __init__(self, oldcat, newcat=None, batch=False, comment='',
inplace=False, move_oldcat=True, delete_oldcat=True,
- title_regex=None, history=False, pagesonly=False):
+ title_regex=None, history=False, pagesonly=False,
+ deletion_comment=DELETION_COMMENT_AUTOMATIC):
"""Store all given parameters in the objects attributes.
@param oldcat: The move source.
@@ -428,6 +432,12 @@
@param history: If True the history of the oldcat is posted on
the talkpage of newcat.
@param pagesonly: If True only move pages, not subcategories.
+ @param deletion_comment: Either string or special value:
+ DELETION_COMMENT_AUTOMATIC: use a generated message,
+ DELETION_COMMENT_SAME_AS_EDIT_COMMENT: use the same message for
+ delete that is also used for move.
+ If the value is not recognized, it's interpreted as
+ DELETION_COMMENT_AUTOMATIC.
"""
self.site = pywikibot.Site()
# Create attributes for the categories and their talk pages.
@@ -447,22 +457,40 @@
self.title_regex = title_regex
self.history = history
self.pagesonly = pagesonly
+ template_vars = {'oldcat': self.oldcat.title(withNamespace=False)}
+ if self.newcat:
+ template_vars.update({
+ 'newcat': self.newcat.title(withNamespace=False),
+ 'title': self.newcat.title(withNamespace=False)})
# Set edit summary for changed pages.
- self.comment = comment
- if not self.comment:
+ if comment:
+ self.comment = comment
+ elif self.newcat:
+ self.comment = i18n.twtranslate(self.site,
+ 'category-replacing',
+ template_vars)
+ else:
+ self.comment = i18n.twtranslate(self.site,
+ 'category-removing',
+ template_vars)
+ # Set deletion reason for category page and talkpage.
+ if isinstance(deletion_comment, basestring):
+ # Deletion comment is set to given string.
+ self.deletion_comment = deletion_comment
+ elif deletion_comment == self.DELETION_COMMENT_SAME_AS_EDIT_COMMENT:
+ # Use the edit comment as the deletion comment.
+ self.deletion_comment = self.comment
+ else:
+ # Deletion comment is set to internationalized default.
if self.newcat:
- template_vars = {
- 'oldcat': self.oldcat.title(withNamespace=False),
- 'newcat': self.newcat.title(withNamespace=False)}
- self.comment = i18n.twtranslate(self.site,
- 'category-replacing',
- template_vars)
+ # Category is moved.
+ self.deletion_comment = i18n.twtranslate(self.site,
+ 'category-was-moved',
+ template_vars)
else:
- template_vars = {'oldcat': self.oldcat.title(
- withNamespace=False)}
- self.comment = i18n.twtranslate(self.site,
- 'category-removing',
- template_vars)
+ # Category is deleted.
+ self.deletion_comment = i18n.twtranslate(self.site,
+ 'category-was-disbanded')
def run(self):
"""The main bot function that does all the work.
@@ -490,14 +518,12 @@
"""Private function to delete the category page and its talk page.
Do not use this function from outside the class.
"""
- template_vars = {'newcat': self.newcat.title(withNamespace=False),
- 'title': self.newcat.title(withNamespace=False)}
- comment = i18n.twtranslate(self.site,
- 'category-was-moved',
- template_vars)
- self.oldcat.delete(comment, not self.batch, mark=True)
+ self.oldcat.delete(self.deletion_comment,
+ not self.batch, mark=True)
if self.oldtalk.exists():
- self.oldtalk.delete(comment, not self.batch, mark=True)
+ self.oldtalk.delete(self.deletion_comment,
+ not self.batch,
+ mark=True)
def _change(self, gen):
"""Private function to move category contents.
@@ -965,8 +991,9 @@
# The generator gives the pages that should be worked upon.
gen = None
- # If this is set to true then the custom edit summary given for removing
+ # When this is True then the custom edit summary given for removing
# categories from articles will also be used as the deletion reason.
+ # Otherwise it will generate deletion specific comments.
useSummaryForDeletion = True
action = None
sort_by_last_name = False
@@ -1052,10 +1079,20 @@
if not toGiven:
newCatTitle = pywikibot.input(
u'Please enter the new name of the category:')
- bot = CategoryMoveRobot(oldCatTitle, newCatTitle, batchMode,
- editSummary, inPlace,
+ if useSummaryForDeletion:
+ deletion_comment = CategoryMoveRobot.DELETION_COMMENT_SAME_AS_EDIT_COMMENT
+ else:
+ deletion_comment = CategoryMoveRobot.DELETION_COMMENT_AUTOMATIC
+ bot = CategoryMoveRobot(oldcat=oldCatTitle,
+ newcat=newCatTitle,
+ batch=batchMode,
+ comment=editSummary,
+ inplace=inPlace,
delete_oldcat=deleteEmptySourceCat,
- title_regex=titleRegex, history=withHistory)
+ title_regex=titleRegex,
+ history=withHistory,
+ pagesonly=pagesonly,
+ deletion_comment=deletion_comment)
bot.run()
elif action == 'tidy':
catTitle = pywikibot.input(u'Which category do you want to tidy up?')
--
To view, visit https://gerrit.wikimedia.org/r/126742
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9a1c0ceb0a2de4ed1f4e87ab83b1e590d1843d40
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Pyfisch <pyfisch(a)gmail.com>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Pyfisch <pyfisch(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Pep257
......................................................................
Pep257
Change-Id: Iea114b85f8623451a551409f485ba7346536ebd0
---
M scripts/watchlist.py
1 file changed, 10 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index c3d685c..7560c22 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -2,8 +2,8 @@
"""
Allows access to the bot account's watchlist.
-The function refresh() downloads the current watchlist and saves it to disk. It
-is run automatically when a bot first tries to save a page retrieved. The
+The function refresh() downloads the current watchlist and saves it to disk.
+It is run automatically when a bot first tries to save a page retrieved. The
watchlist can be updated manually by running this script. The list will also
be reloaded automatically once a month.
@@ -36,6 +36,7 @@
def get(site=None):
+ """Load the watchlist, fetching it if necessary."""
if site is None:
site = pywikibot.Site()
if site in cache:
@@ -65,12 +66,13 @@
def isWatched(pageName, site=None):
+ """Check whether a page is being watched."""
watchlist = get(site)
return pageName in watchlist
def refresh(site, sysop=False):
- # get watchlist special page's URL
+ """Fetch the watchlist."""
if not site.logged_in(sysop=sysop):
site.forceLogin(sysop=sysop)
@@ -105,16 +107,18 @@
# The file is stored in the watchlists subdir. Create if necessary.
f = open(config.datafilepath('watchlists',
'watchlist-%s-%s%s.dat'
- % (site.family.name, lang, '-sysop' if sysop else '')),
+ % (site.family.name, lang,
+ '-sysop' if sysop else '')),
'w')
pickle.dump(watchlist, f)
f.close()
def refresh_all(new=False, sysop=False):
+ """Fetch and locally cache several watchlists."""
if new:
pywikibot.output(
- 'Downloading All watchlists for your accounts in user-config.py')
+ 'Downloading all watchlists for your accounts in user-config.py')
for family in config.usernames:
for lang in config.usernames[family]:
refresh(pywikibot.Site(lang, family), sysop=sysop)
@@ -137,6 +141,7 @@
def main():
+ """ Script entry point. """
local_args = pywikibot.handleArgs()
all = False
new = False
--
To view, visit https://gerrit.wikimedia.org/r/151039
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iea114b85f8623451a551409f485ba7346536ebd0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Pyflakes fix: Changed WindowsError to OSError
......................................................................
Pyflakes fix: Changed WindowsError to OSError
Pyflakes fix: undefined name 'WindowsError'
On linux systems, WindowsError it is not necessarily defined.
Replaced with the parent class, as it is not used in sections
of code specific for Windows systems.
Change-Id: Ice9234fde21ff666e438cfc6047b0a8d1f2d23f8
---
M scripts/interwiki.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 3026840..c071d9d 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2593,7 +2593,7 @@
try:
os.remove(dumpFileName)
pywikibot.output(u'Dumpfile %s deleted' % dumpFileName.split('\\')[-1])
- except WindowsError:
+ except OSError:
pass
# ===========
--
To view, visit https://gerrit.wikimedia.org/r/151407
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ice9234fde21ff666e438cfc6047b0a8d1f2d23f8
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
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 <>