jenkins-bot has submitted this change and it was merged.
Change subject: Mark page.undelete as not implemented.
......................................................................
Mark page.undelete as not implemented.
Bug: 72733
Change-Id: I9d03dd3fe23dfd6bc8487072690b0854ab9a78cd
---
M pywikibot/page.py
1 file changed, 4 insertions(+), 6 deletions(-)
Approvals:
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index c7ac243..961fe6f 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1560,6 +1560,8 @@
def undelete(self, comment=None):
"""Undelete revisions based on the markers set by previous calls.
+ NOT IMPLEMENTED.
+
If no calls have been made since loadDeletedRevisions(), everything
will be restored.
@@ -1579,12 +1581,8 @@
@param comment: The undeletion edit summary.
@type comment: basestring
"""
- if comment is None:
- pywikibot.output(u'Preparing to undelete %s.'
- % (self.title(asLink=True)))
- comment = pywikibot.input(
- u'Please enter a reason for the undeletion:')
- return self.site.undelete(self, comment)
+ # FIXME: Site.undelete needs to be implemented.
+ raise NotImplementedError('Page.undelete is not implemented.')
@deprecate_arg("throttle", None)
def protect(self, edit=False, move=False, create=None, upload=None,
--
To view, visit https://gerrit.wikimedia.org/r/172116
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9d03dd3fe23dfd6bc8487072690b0854ab9a78cd
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: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Log the site data has been retrieved from
......................................................................
Log the site data has been retrieved from
In a multi-threaded script, the response may not immediately follow
the request. The site identifier is needed in the debug log messages
about the response.
Change-Id: Icf08e6465330ee6219a3b8a3894ac8f8f86e680a
---
M pywikibot/data/api.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index a685848..83ef419 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -601,7 +601,8 @@
continue
if not isinstance(rawdata, unicode):
rawdata = rawdata.decode(self.site.encoding())
- pywikibot.debug(u"API response received:\n" + rawdata, _logger)
+ pywikibot.debug((u"API response received from %s:\n" % self.site) +
+ rawdata, _logger)
if rawdata.startswith(u"unknown_action"):
raise APIError(rawdata[:14], rawdata[16:])
try:
--
To view, visit https://gerrit.wikimedia.org/r/172035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf08e6465330ee6219a3b8a3894ac8f8f86e680a
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: Nullzero <nullzero.free(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: Replacing Request by CachedRequest
......................................................................
Replacing Request by CachedRequest
Change-Id: Iaabd6705ad771eb8873fa8f11e5b3131eece5f33
---
M scripts/watchlist.py
1 file changed, 33 insertions(+), 56 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index 140b858..d16b73c 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -7,7 +7,7 @@
watchlist can be updated manually by running this script. The list will also
be reloaded automatically once a month.
-Syntax: python watchlist [-all]
+Syntax: python watchlist [-all | -new]
Command line options:
-all - Reloads watchlists for all wikis where a watchlist is already
@@ -24,13 +24,11 @@
__version__ = '$Id$'
#
-import re
-import pickle
-import os.path
-import time
-
+import os
import pywikibot
from pywikibot import config
+from pywikibot.data.api import CachedRequest
+from scripts.maintenance.cache import CacheEntry
cache = {}
@@ -43,23 +41,8 @@
# Use cached copy if it exists.
watchlist = cache[site]
else:
- fn = config.datafilepath('watchlists',
- 'watchlist-%s-%s.dat'
- % (site.family.name, site.code))
- try:
- # find out how old our saved dump is (in seconds)
- file_age = time.time() - os.path.getmtime(fn)
- # if it's older than 1 month, reload it
- if file_age > 30 * 24 * 60 * 60:
- pywikibot.output(
- u'Copy of watchlist is one month old, reloading')
- refresh(site)
- except OSError:
- # no saved watchlist exists yet, retrieve one
- refresh(site)
- with open(fn, 'rb') as f:
- watchlist = pickle.load(f)
# create cached copy
+ watchlist = refresh(site)
cache[site] = watchlist
return watchlist
@@ -86,7 +69,7 @@
# pywikibot.put_throttle() # It actually is a get, but a heavy one.
watchlist = []
while True:
- req = pywikibot.data.api.Request(**params)
+ req = CachedRequest(config.API_config_expiry, **params)
data = req.submit()
if 'error' in data:
raise RuntimeError('ERROR: %s' % data)
@@ -96,41 +79,35 @@
params.update(data['query-continue']['watchlistraw'])
else:
break
-
- # Save the watchlist to disk
- # The file is stored in the watchlists subdir. Create if necessary.
- with open(config.datafilepath('watchlists',
- 'watchlist-%s-%s%s.dat'
- % (site.family.name, site.code,
- '-sysop' if sysop else '')),
- 'wb') as f:
- pickle.dump(watchlist, f, protocol=config.pickle_protocol)
+ return watchlist
-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')
- for family in config.usernames:
- for lang in config.usernames[family]:
- refresh(pywikibot.Site(lang, family), sysop=sysop)
- for family in config.sysopnames:
- for lang in config.sysopnames[family]:
- refresh(pywikibot.Site(lang, family), sysop=sysop)
+def refresh_all(sysop=False):
+ """Reload watchlists for all wikis where a watchlist is already present."""
+ cache_path = CachedRequest._get_cache_dir()
+ files = os.listdir(cache_path)
+ seen = []
+ for filename in files:
+ entry = CacheEntry(cache_path, filename)
+ entry._load_cache()
+ entry.parse_key()
+ entry._rebuild()
+ if entry.site not in seen:
+ if entry._data['watchlistraw']:
+ refresh(entry.site)
+ seen.append(entry.site)
- else:
- import dircache
- filenames = dircache.listdir(
- config.datafilepath('watchlists'))
- watchlist_filenameR = re.compile('watchlist-([a-z\-:]+).dat')
- for filename in filenames:
- match = watchlist_filenameR.match(filename)
- if match:
- arr = match.group(1).split('-')
- family = arr[0]
- lang = '-'.join(arr[1:])
- refresh(pywikibot.Site(lang, family))
+
+def refresh_new(sysop=False):
+ """Load watchlists of all wikis for accounts set in user-config.py."""
+ pywikibot.output(
+ '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)
+ for family in config.sysopnames:
+ for lang in config.sysopnames[family]:
+ refresh(pywikibot.Site(lang, family), sysop=sysop)
def main():
@@ -149,7 +126,7 @@
if all:
refresh_all(sysop=sysop)
elif new:
- refresh_all(new, sysop=sysop)
+ refresh_new(sysop=sysop)
else:
site = pywikibot.Site()
refresh(site, sysop=sysop)
--
To view, visit https://gerrit.wikimedia.org/r/166948
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaabd6705ad771eb8873fa8f11e5b3131eece5f33
Gerrit-PatchSet: 13
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Maverick <manpreetkaur9411(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Maverick <manpreetkaur9411(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: Bug 72680 - 'user-config.py' not found if runs with cron
......................................................................
Bug 72680 - 'user-config.py' not found if runs with cron
Changed search order for user-config.py.
See also bug 72918.
New order:
1. -dir: argument
2. PYWIKIBOT2_DIR
3. .
4. pwb.py directory
5. 'pywikibot' folder under:
'Application Data' or 'AppData\Roaming' (Windows) or
'.pywikibot' directory (Unix and similar) under the user's home
Also code improvements:
- in search logic
- removed TODO: Raise exception on not handled windows version
Bug: 72680
Change-Id: Id23afcdd2fa1a17710ca786e69c6ea985b86e870
---
M pwb.py
M pywikibot/config2.py
2 files changed, 22 insertions(+), 10 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
Objections:
Steinsplitter: There's a problem with this change, please improve
diff --git a/pwb.py b/pwb.py
index 3a53ef2..29ddc24 100644
--- a/pwb.py
+++ b/pwb.py
@@ -151,7 +151,10 @@
# Search for user-config.py before creating one.
try:
- # user-config.py already exists
+ # If successful, user-config.py already exists in one of the candidate
+ # directories. See config2.py for details on search order.
+ # Use env var to communicate to config2.py pwb.py location (bug 72918).
+ os.environ['PYWIKIBOT2_DIR_PWB'] = os.path.split(__file__)[0]
import pywikibot # noqa
except RuntimeError as err:
# user-config.py to be created
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 4d74265..e24ebca 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -138,11 +138,13 @@
This is determined in the following order:
1. If the script was called with a -dir: argument, use the directory
- provided in this argument
+ provided in this argument.
2. If the user has a PYWIKIBOT2_DIR environment variable, use the value
- of it
- 3. If user-config presents in current directory, use the current directory
- 4. Use (and if necessary create) a 'pywikibot' folder under
+ of it.
+ 3. If user-config is present in current directory, use the current
+ directory.
+ 4. If user-config is present in pwb.py directory, use that directory
+ 5. Use (and if necessary create) a 'pywikibot' folder under
'Application Data' or 'AppData\Roaming' (Windows) or
'.pywikibot' directory (Unix and similar) under the user's home
directory.
@@ -176,10 +178,14 @@
base_dir = os.path.expanduser(base_dir)
break
else:
- if 'PYWIKIBOT2_DIR' in os.environ:
- base_dir = os.environ['PYWIKIBOT2_DIR']
+ if ('PYWIKIBOT2_DIR' in os.environ and
+ exists(os.path.abspath(os.environ['PYWIKIBOT2_DIR']))):
+ base_dir = os.path.abspath(os.environ['PYWIKIBOT2_DIR'])
elif exists('.'):
- return os.path.abspath('.')
+ base_dir = os.path.abspath('.')
+ elif ('PYWIKIBOT2_DIR_PWB' in os.environ and
+ exists(os.path.abspath(os.environ['PYWIKIBOT2_DIR_PWB']))):
+ base_dir = os.path.abspath(os.environ['PYWIKIBOT2_DIR_PWB'])
else:
base_dir_cand = []
home = os.path.expanduser("~")
@@ -190,10 +196,11 @@
sub_dir = ["Application Data"]
elif win_version == 6:
sub_dir = ["AppData", "Roaming"]
+ else:
+ raise WindowsError(u'Windows version %s not supported yet.'
+ % win_version)
base_dir_cand.extend([[home] + sub_dir + [DIRNAME_WIN],
[home] + sub_dir + [DIRNAME_WIN_FBCK]])
- #TODO: Throw exception otherwise to notify the user that the
- # version of Windows is not (yet) supported
else:
base_dir_cand.append([home, DIRNAME_UNIX])
@@ -203,12 +210,14 @@
os.makedirs(dir, mode=0o700)
if exists(dir):
base_dir = dir
+ break
if not os.path.isabs(base_dir):
base_dir = os.path.normpath(os.path.join(os.getcwd(), base_dir))
# make sure this path is valid and that it contains user-config file
if not os.path.isdir(base_dir):
raise RuntimeError("Directory '%s' does not exist." % base_dir)
+ # check if user-config.py is in base_dir
if not exists(base_dir):
exc_text = "No user-config.py found in directory '%s'.\n" % base_dir
if os.environ.get('PYWIKIBOT2_NO_USER_CONFIG', '0') == '1':
--
To view, visit https://gerrit.wikimedia.org/r/172096
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id23afcdd2fa1a17710ca786e69c6ea985b86e870
Gerrit-PatchSet: 1
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Steinsplitter <steinsplitter(a)wikipedia.de>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add Namespace.__int__ to cast to integer
......................................................................
Add Namespace.__int__ to cast to integer
Format strings use %d and %i for page.namespace(), which is now
a Namespace. Allow the Namespace to be cast as an int.
Change-Id: Ice3d1fca94f431023f10d2e1999b0b49e0b2cd02
---
M pywikibot/site.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 75bbbd1..ba1b00c 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -296,6 +296,9 @@
"""Return the custom name with required colons."""
return Namespace._colons(self.id, self.custom_name)
+ def __int__(self):
+ return self.id
+
def __index__(self):
return self.id
--
To view, visit https://gerrit.wikimedia.org/r/172108
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ice3d1fca94f431023f10d2e1999b0b49e0b2cd02
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: 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: jenkins-bot <>