jenkins-bot has submitted this change and it was merged.
Change subject: Inline function exclude
......................................................................
Inline function exclude
exclude(page, real_exclude=False) is a no-op that is invoked many times.
Change-Id: Ib830906570609b3456bd7d93a9e432edcfedcb05
---
M scripts/makecat.py
1 file changed, 1 insertion(+), 10 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/makecat.py b/scripts/makecat.py
index e523cff..4728d52 100644
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -104,11 +104,6 @@
checked[refPage] = refPage
-def exclude(pl, real_exclude=True):
- if real_exclude:
- excludefile.write('%s\n' % pl.title())
-
-
def asktoadd(pl):
if pl.site != mysite:
return
@@ -141,10 +136,9 @@
include(pl)
break
elif answer == 'n':
- exclude(pl)
+ excludefile.write('%s\n' % pl.title())
break
elif answer == 'i':
- exclude(pl, real_exclude=False)
break
elif answer == 'o':
pywikibot.output(u"t: Give the beginning of the text of the page")
@@ -170,7 +164,6 @@
include(pl, checklinks=False)
else:
pywikibot.output(u"Page does not exist; not added.")
- exclude(pl, real_exclude=False)
break
elif answer == 'l':
pywikibot.output(u"Number of pages still to check: %s"
@@ -234,7 +227,6 @@
line = line[:-1]
except IndexError:
pass
- exclude(line, real_exclude=False)
pl = pywikibot.Page(mysite, line)
checked[pl] = pl
f.close()
@@ -253,7 +245,6 @@
for cat in subcatlist:
artlist = list(cat.articles())
for page in artlist:
- exclude(page.title(), real_exclude=False)
checked[page] = page
list = [x for x in workingcat.articles()]
if list:
--
To view, visit https://gerrit.wikimedia.org/r/169523
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib830906570609b3456bd7d93a9e432edcfedcb05
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: Make edit summary of archivebot more locolized for non latin digits
......................................................................
Make edit summary of archivebot more locolized for non latin digits
Change-Id: I1c9fc18688ca02a410e74b46231f64adc0068a50
---
M scripts/archivebot.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index d1ef865..d57e2fc 100644
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -142,9 +142,9 @@
template = site.mediawiki_message('Hours')
if template:
exp = i18n.translate(site.code, template, int(string[:-1]))
- return exp.replace('$1', string[:-1])
+ return to_local_digits(exp.replace('$1', string[:-1]), site.code)
else:
- return string
+ return to_local_digits(string, site.code)
def str2time(string):
--
To view, visit https://gerrit.wikimedia.org/r/169010
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1c9fc18688ca02a410e74b46231f64adc0068a50
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(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: Log requests served from the API cache
......................................................................
Log requests served from the API cache
There is no logging of requests successfully served from the API cache.
Typically threadedhttp logs the request, and api logs the response.
This change logs when CachedRequest does not need to submit the request,
logging the request parameters and the filename containing the cached data.
Change-Id: Ib4aea6b5d401121fedb2ae91b8869b1872d1b4db
---
M pywikibot/data/api.py
1 file changed, 5 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 bb5c1cb..3ad6e8d 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -483,12 +483,16 @@
def _load_cache(self):
""" Return whether the cache can be used """
try:
- with open(self._cachefile_path(), 'rb') as f:
+ filename = self._cachefile_path()
+ with open(filename, 'rb') as f:
uniquedescr, self._data, self._cachetime = pickle.load(f)
assert(uniquedescr == str(self._uniquedescriptionstr()))
if self._expired(self._cachetime):
self._data = None
return False
+ pywikibot.debug(u"%s: cache hit (%s) for API request: %s"
+ % (self.__class__.__name__, filename, uniquedescr),
+ _logger)
return True
except IOError as e:
# file not found
--
To view, visit https://gerrit.wikimedia.org/r/146045
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4aea6b5d401121fedb2ae91b8869b1872d1b4db
Gerrit-PatchSet: 3
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: Remove wrong comment and unused code
......................................................................
Remove wrong comment and unused code
Because we switch to the tokens property, the comment that latestRevision
will be updated is no longer true. We also can't check edit conflict from
this. This patch therefore removes the comment and the code
Change-Id: I288c9badb7824dc2bc8db300e7fa6c322b338640
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 10 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 4efece2..9cadefe 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3728,24 +3728,16 @@
if not recreate:
raise
token = self.tokens['edit']
- # getting token also updates the 'lastrevid' value, which allows us to
- # detect if page has been changed since last time text was retrieved.
-
- # note that the server can still return an 'editconflict' error
- # if the page is updated after the token is retrieved but
- # before the page is saved.
self.lock_page(page)
- if lastrev is not None and page.latestRevision() != lastrev:
- raise EditConflict(page)
params = dict(action="edit",
title=page.title(withSection=False),
text=text, token=token, summary=summary)
if bot:
- params["bot"] = ""
+ params['bot'] = ""
if lastrev is not None:
if lastrev not in page._revisions:
self.loadrevisions(page)
- params["basetimestamp"] = page._revisions[lastrev].timestamp
+ params['basetimestamp'] = page._revisions[lastrev].timestamp
if minor:
params['minor'] = ""
elif notminor:
--
To view, visit https://gerrit.wikimedia.org/r/169311
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I288c9badb7824dc2bc8db300e7fa6c322b338640
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Nullzero <nullzero.free(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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: textlib.py: categories with no indexing in categoryFormat
......................................................................
textlib.py: categories with no indexing in categoryFormat
Avoid the need for 'categories' to support indexing.
In this way, any iterable can be provided as parameter.
Change-Id: I1d1b83fd09f4c1f87bd2756b640aa4df34dc34d5
---
M pywikibot/textlib.py
M tests/textlib_tests.py
2 files changed, 21 insertions(+), 11 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/pywikibot/textlib.py b/pywikibot/textlib.py
index 4c74cef..d21ddf1 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -854,24 +854,34 @@
def categoryFormat(categories, insite=None):
"""Return a string containing links to all categories in a list.
- 'categories' should be a list of Category objects or strings
- which can be either the raw name or [[Category:..]].
+ 'categories' should be a list of Category or Page objects or strings
+ which can be either the raw name, [[Category:..]] or [[cat_localised_ns:...]].
The string is formatted for inclusion in insite.
+ Category namespace is converted to localised namespace.
"""
if not categories:
return ''
if insite is None:
insite = pywikibot.Site()
- if isinstance(categories[0], basestring):
- if categories[0][0] == '[':
- catLinks = categories
- else:
- catLinks = ['[[Category:%s]]' % category for category in categories]
- else:
- catLinks = [pywikibot.Category(category).aslink()
- for category in categories]
+ catLinks = []
+ for category in categories:
+ if isinstance(category, basestring):
+ category, separator, sortKey = category.strip('[]').partition('|')
+ sortKey = sortKey if separator else None
+ prefix = category.split(":", 1)[0] # whole word if no ":" is present
+ if prefix not in insite.namespaces()[14]:
+ category = u'{0}:{1}'.format(insite.namespace(14), category)
+ category = pywikibot.Category(pywikibot.Link(category,
+ insite,
+ defaultNamespace=14),
+ sortKey=sortKey)
+ # Make sure a category is casted from Page to Category.
+ elif not isinstance(category, pywikibot.Category):
+ category = pywikibot.Category(category)
+ link = category.aslink()
+ catLinks.append(link)
if insite.category_on_one_line():
sep = ' '
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index cafa378..bc28612 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -172,7 +172,7 @@
sep = config.LS
config.line_separator = '' # use an empty separator temporarily
new = textlib.replaceCategoryLinks(old, cats, site=self.site)
- # restore the default separator
+ # Restore the default separator.
config.line_separator = sep
self.assertEqual(old, new)
--
To view, visit https://gerrit.wikimedia.org/r/165109
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1d1b83fd09f4c1f87bd2756b640aa4df34dc34d5
Gerrit-PatchSet: 9
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: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>