jenkins-bot has submitted this change and it was merged.
Change subject: Do not require login for pure logging purposes
......................................................................
Do not require login for pure logging purposes
If the user is not logged in, then don't display their talk page status, as
this would require a log-in. This is annoying if one just needs read-only
access, or needs to read a wiki that has a broken login (e.g. toolserver)
Change-Id: Ia46d1938221ef70aaf2a752f1b9a4cc5493d34dc
---
M pywikibot/bot.py
1 file changed, 8 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 13aaf41..2d478c5 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -272,7 +272,14 @@
log(u' %s' % ver)
# messages on bot discussion page?
- log(u'MESSAGES: %s' % ('unanswered' if site.messages() else 'none'))
+ if site.logged_in():
+ if site.messages():
+ messagestate = 'unanswered'
+ else:
+ messagestate = 'none'
+ else:
+ messagestate = 'unknown (not logged in)'
+ log(u'MESSAGES: %s' % messagestate)
log(u'=== ' * 14)
--
To view, visit https://gerrit.wikimedia.org/r/104962
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia46d1938221ef70aaf2a752f1b9a4cc5493d34dc
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Weblib: add docs, replace string concat with urlencode
......................................................................
Weblib: add docs, replace string concat with urlencode
Change-Id: I18c8b7b4c47aba68cffd3435be7fdf4056e3620d
---
M pywikibot/weblib.py
1 file changed, 39 insertions(+), 19 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/weblib.py b/pywikibot/weblib.py
index d068925..c2ad86e 100644
--- a/pywikibot/weblib.py
+++ b/pywikibot/weblib.py
@@ -11,21 +11,31 @@
#
__version__ = '$Id$'
-import pywikibot
+import urllib
from pywikibot.comms import http
def getInternetArchiveURL(url, timestamp=None):
- """Return archived URL by Internet Archive."""
- # See [[:mw:Archived Pages]] and http://archive.org/help/wayback_api.php
+ """Return archived URL by Internet Archive.
+
+ Parameters:
+ url - url to search an archived version for
+ timestamp - requested archive date. The version closest to that moment
+ is returned. Format: YYYYMMDDhhmmss or part thereof.
+
+ See [[:mw:Archived Pages]] and http://archive.org/help/wayback_api.php
+ for more details.
+ """
import json
- query = u'http://archive.org/wayback/available?'
- query += u'url='
- query += url
- if not timestamp is None:
- query += u'×tamp='
- query += timestamp
- jsontext = http.request(uri=query, site=None)
+ uri = u'http://archive.org/wayback/available?'
+
+ query = {'url': url}
+
+ if timestamp is not None:
+ query['timestamp'] = timestamp
+
+ uri = uri + urllib.urlencode(query)
+ jsontext = http.request(uri=uri, site=None)
if "closest" in jsontext:
data = json.loads(jsontext)
return data['archived_snapshots']['closest']['url']
@@ -34,17 +44,27 @@
def getWebCitationURL(url, timestamp=None):
- """Return archived URL by Web Citation."""
- # See http://www.webcitation.org/doc/WebCiteBestPracticesGuide.pdf
+ """Return archived URL by Web Citation.
+
+ Parameters:
+ url - url to search an archived version for
+ timestamp - requested archive date. The version closest to that moment
+ is returned. Format: YYYYMMDDhhmmss or part thereof.
+
+ See http://www.webcitation.org/doc/WebCiteBestPracticesGuide.pdf
+ for more details
+ """
import xml.etree.ElementTree as ET
- query = u'http://www.webcitation.org/query?'
- query += u'returnxml=true'
- query += u'&url='
- query += url
+ uri = u'http://www.webcitation.org/query?'
+
+ query = {'returnxml': 'true',
+ 'url': url}
+
if not timestamp is None:
- query += u'&date='
- query += timestamp
- xmltext = http.request(uri=query, site=None)
+ query['date'] = timestamp
+
+ uri = uri + urllib.urlencode(query)
+ xmltext = http.request(uri=uri, site=None)
if "success" in xmltext:
data = ET.fromstring(xmltext)
return data.find('.//webcite_url').text
--
To view, visit https://gerrit.wikimedia.org/r/104804
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I18c8b7b4c47aba68cffd3435be7fdf4056e3620d
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Prevent Page.change_category from readding newCat.
......................................................................
Prevent Page.change_category from readding newCat.
Currently change_category also adds newCat if it
is already present at the target page. This
behavior had to be fixed manually by calling
functions like category.py and causes extra code
and complexity.
Change-Id: I95ba291e78c2f187f4d4a881b39fa44096cca9b6
---
M pywikibot/page.py
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index f0150cd..2cda41e 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1479,6 +1479,10 @@
% (self.title(asLink=True), oldCat.title()))
return
+ # This prevents the bot from adding newCat if it is already present.
+ if newCat in cats:
+ newCat = None
+
if inPlace or self.namespace() == 10:
oldtext = self.get(get_redirect=True)
newtext = pywikibot.replaceCategoryInPlace(oldtext, oldCat, newCat)
--
To view, visit https://gerrit.wikimedia.org/r/104812
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I95ba291e78c2f187f4d4a881b39fa44096cca9b6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Pyfisch <pyfisch(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot