Alex S.H. Lin has submitted this change and it was merged.
Change subject: [BUGFIX] Fix for ProcessTitle() and ReplaceLink()
......................................................................
[BUGFIX] Fix for ProcessTitle() and ReplaceLink()
- mightBeLoc must be migtBeLcl in ProcessTitle()
- fix for list comprehensive variable d --> s
Change-Id: I98f0bcbaff8c48854379a672a7ddc752b133dad0
---
M casechecker.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Alex S.H. Lin: Verified; Looks good to me, approved
diff --git a/casechecker.py b/casechecker.py
index 100d33c..773f090 100644
--- a/casechecker.py
+++ b/casechecker.py
@@ -566,7 +566,7 @@
if badWord in self.alwaysInLocal:
mightBeLat = False
elif badWord in self.alwaysInLatin:
- mightBeLoc = False
+ mightBeLcl = False
if mightBeLcl:
mapLcl[badWord] = badWord.translate(self.latToLclDict)
@@ -819,7 +819,7 @@
def ReplaceLink(self, text, oldtxt, newtxt):
frmParts = [s.strip(self.stripChars)
- for d in self.wordBreaker.split(oldtxt)]
+ for s in self.wordBreaker.split(oldtxt)]
toParts = [s.strip(self.stripChars)
for s in self.wordBreaker.split(newtxt)]
--
To view, visit https://gerrit.wikimedia.org/r/109623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I98f0bcbaff8c48854379a672a7ddc752b133dad0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Alex S.H. Lin <alexsh(a)mail2000.com.tw>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Siebrand <siebrand(a)wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Site.mediawiki_messages() returns all messages as well
......................................................................
Site.mediawiki_messages() returns all messages as well
Change-Id: I82e93a31346ebf780c8e5a120ef5d6156ee0a044
---
M pywikibot/site.py
M tests/site_tests.py
2 files changed, 29 insertions(+), 11 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index a232365..5195652 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -998,9 +998,10 @@
return 'hasmsg' in self._userinfo
def mediawiki_messages(self, keys):
- """Return the MediaWiki message text for each 'key' in keys
- in a dict:
+ """Return the MediaWiki message text for each 'key' in keys in a dict:
-. dict['key'] = text message
+
+ keys='*' or ['*'] will return all messages
"""
@@ -1010,14 +1011,23 @@
meta="allmessages",
ammessages='|'.join(keys),
)
- for _key in keys:
+
+ # Return all messages
+ if keys == u'*' or keys == [u'*']:
for msg in msg_query:
- if msg['name'] == _key and not 'missing' in msg:
- self._msgcache[_key] = msg['*']
- break
- else:
- raise KeyError("Site %(self)s has no message '%(_key)s'"
- % locals())
+ if not 'missing' in msg:
+ self._msgcache[msg['name']] = msg['*']
+ return self._msgcache
+ # Return only given keys
+ else:
+ for _key in keys:
+ for msg in msg_query:
+ if msg['name'] == _key and not 'missing' in msg:
+ self._msgcache[_key] = msg['*']
+ break
+ else:
+ raise KeyError("Site %(self)s has no message '%(_key)s'"
+ % locals())
return dict((_key, self._msgcache[_key]) for _key in keys)
@@ -1030,7 +1040,10 @@
return self.has_all_mediawiki_messages([key])
def has_all_mediawiki_messages(self, keys):
- """Return True if this site defines MediaWiki messages for all 'keys'; False otherwise."""
+ """Return True if this site defines MediaWiki messages for all 'keys';
+ False otherwise.
+
+ """
try:
v = self.mediawiki_messages(keys)
return True
diff --git a/tests/site_tests.py b/tests/site_tests.py
index ee86e70..3a01c9e 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -156,10 +156,15 @@
self.assertType(mysite.mediawiki_messages(msg), dict)
self.assertTrue(mysite.mediawiki_messages(msg))
- msg = ("1movedto2", "about", "aboutpage", "nosuchmessage")
+ msg = ("nosuchmessage1", "about", "aboutpage", "nosuchmessage")
self.assertFalse(mysite.has_all_mediawiki_messages(msg))
self.assertRaises(KeyError, mysite.mediawiki_messages, msg)
+ # Load all messages and check that '*' is not a valid key.
+ self.assertType(mysite.mediawiki_messages('*'), dict)
+ self.assertTrue(len(mysite.mediawiki_messages(['*'])) > 10)
+ self.assertFalse('*' in mysite.mediawiki_messages(['*']))
+
self.assertType(mysite.getcurrenttimestamp(), basestring)
self.assertType(mysite.siteinfo, dict)
self.assertType(mysite.case(), basestring)
--
To view, visit https://gerrit.wikimedia.org/r/107727
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I82e93a31346ebf780c8e5a120ef5d6156ee0a044
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix delete and switch to using must_be
......................................................................
Fix delete and switch to using must_be
This patch follows Merlijn van Deen's suggestion to use must_be
instead of calling APISite.login directly. It also fixes Page.delete
to support switching between bot and sysop account and consequently
partially fixes bug 60278.
Change-Id: Ibc94da881fce312f42ce58fd9a440d1fb5e06109
---
M pywikibot/page.py
M pywikibot/site.py
2 files changed, 3 insertions(+), 15 deletions(-)
Approvals:
Pyfisch: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 2949fa2..91d2038 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1294,7 +1294,7 @@
pywikibot.output(u'Deleting %s.' % (self.title(asLink=True)))
reason = pywikibot.input(u'Please enter a reason for the deletion:')
- if self.site.logged_in(sysop=True): # If user is a sysop, delete the page
+ if self.site.username(sysop=True): # If user is a sysop, delete the page
answer = u'y'
if prompt and not hasattr(self.site, '_noDeletePrompt'):
answer = pywikibot.inputChoice(
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 3048834..a4e8d19 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3026,6 +3026,7 @@
"cantdelete": "Could not delete [[%(title)s]]. Maybe it was deleted already.",
} # other errors shouldn't occur because of pre-submission checks
+ @must_be(group='sysop')
def deletepage(self, page, summary):
"""Delete page from the wiki. Requires appropriate privilege level.
@@ -3033,13 +3034,6 @@
@param summary: Edit summary (required!).
"""
- try:
- self.login(sysop=True)
- except pywikibot.NoUsername as e:
- raise NoUsername("delete: Unable to login as sysop (%s)"
- % e.__class__.__name__)
- if not self.logged_in(sysop=True):
- raise NoUsername("delete: Unable to login as sysop")
token = self.token(page, "delete")
self.lock_page(page)
req = api.Request(site=self, action="delete", token=token,
@@ -3070,6 +3064,7 @@
"protect-invalidlevel": "Invalid protection level"
}
+ @must_be(group='sysop')
def protect(self, page, edit, move, summary):
"""(Un)protect a wiki page. Requires administrator status.
@@ -3084,13 +3079,6 @@
@param prompt: If true, ask user for confirmation.
"""
- try:
- self.login(sysop=True)
- except pywikibot.NoUsername as e:
- raise NoUsername("protect: Unable to login as sysop (%s)"
- % e.__class__.__name__)
- if not self.logged_in(sysop=True):
- raise NoUsername("protect: Unable to login as sysop")
token = self.token(page, "protect")
self.lock_page(page)
req = api.Request(site=self, action="protect", token=token,
--
To view, visit https://gerrit.wikimedia.org/r/109339
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibc94da881fce312f42ce58fd9a440d1fb5e06109
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Nullzero <nullzero.free(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: Pyfisch <pyfisch(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>