[MediaWiki-commits] [Gerrit] pywikibot/core[2.0]: Allow non-urlencoded permalink

2016-10-09 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Allow non-urlencoded permalink
..


Allow non-urlencoded permalink

With browsers increasing their support for non-ascii urls the need
for the urlencode of the title is not always guaranteed. Adding an
optional parameter to permalink ensures this option becomes
available.

Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
(cherry picked from commit 7f12117a61ab3df5c1ee7f6deb718e66fde1a200)
---
M pywikibot/page.py
1 file changed, 6 insertions(+), 2 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/page.py b/pywikibot/page.py
index a78ed9a..6f72ded 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -418,16 +418,20 @@
 # TODO: what about redirects, errors?
 return self._revisions[oldid].text
 
-def permalink(self, oldid=None):
+def permalink(self, oldid=None, percent_encoded=True):
 """Return the permalink URL of an old revision of this page.
 
 @param oldid: The revid of the revision desired.
 
 """
+if percent_encoded:
+title = self.title(asUrl=True)
+else:
+title = self.title(asUrl=False).replace(' ', '_')
 return "//%s%s/index.php?title=%s&oldid=%s" \
% (self.site.hostname(),
   self.site.scriptpath(),
-  self.title(asUrl=True),
+  title,
   (oldid if oldid is not None else self.latest_revision_id))
 
 @property

-- 
To view, visit https://gerrit.wikimedia.org/r/313759
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Lokal Profil 
Gerrit-Reviewer: John Vandenberg 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Lokal Profil 
Gerrit-Reviewer: Xqt 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] pywikibot/core[2.0]: Allow non-urlencoded permalink

2016-10-02 Thread Lokal Profil (Code Review)
Lokal Profil has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/313759

Change subject: Allow non-urlencoded permalink
..

Allow non-urlencoded permalink

With browsers increasing their support for non-ascii urls the need
for the urlencode of the title is not always guaranteed. Adding an
optional parameter to permalink ensures this option becomes
available.

Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
(cherry picked from commit 7f12117a61ab3df5c1ee7f6deb718e66fde1a200)
---
M pywikibot/page.py
1 file changed, 6 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/59/313759/1

diff --git a/pywikibot/page.py b/pywikibot/page.py
index a78ed9a..6f72ded 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -418,16 +418,20 @@
 # TODO: what about redirects, errors?
 return self._revisions[oldid].text
 
-def permalink(self, oldid=None):
+def permalink(self, oldid=None, percent_encoded=True):
 """Return the permalink URL of an old revision of this page.
 
 @param oldid: The revid of the revision desired.
 
 """
+if percent_encoded:
+title = self.title(asUrl=True)
+else:
+title = self.title(asUrl=False).replace(' ', '_')
 return "//%s%s/index.php?title=%s&oldid=%s" \
% (self.site.hostname(),
   self.site.scriptpath(),
-  self.title(asUrl=True),
+  title,
   (oldid if oldid is not None else self.latest_revision_id))
 
 @property

-- 
To view, visit https://gerrit.wikimedia.org/r/313759
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Lokal Profil 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits