jenkins-bot has submitted this change and it was merged.
Change subject: Assume utf-8 encoding for password file
......................................................................
Assume utf-8 encoding for password file
Change-Id: I7fe9fe9842cdb61b8ecb373a2c071b2def54bff2
---
M pywikibot/login.py
1 file changed, 8 insertions(+), 4 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index e5b9f97..49cebaa 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -126,22 +126,26 @@
DO NOT FORGET TO REMOVE READ ACCESS FOR OTHER USERS!!!
Use chmod 600 password-file.
+
All lines below should be valid Python tuples in the form
(code, family, username, password) or (username, password)
to set a default password for an username. Default usernames
should occur above specific usernames.
+ If the username or password contain non-ascii characters, they
+ should be stored using the utf-8 encoding.
+
Example:
- ("my_username", "my_default_password")
- ("my_sysop_user", "my_sysop_password")
- ("en", "wikipedia", "my_en_user", "my_en_pass")
+ (u"my_username", u"my_default_password")
+ (u"my_sysop_user", u"my_sysop_password")
+ (u"en", u"wikipedia", u"my_en_user", u"my_en_pass")
"""
password_f = open(config.password_file)
for line in password_f:
if not line.strip():
continue
- entry = eval(line)
+ entry = eval(line.decode('utf-8'))
if len(entry) == 2: # for default userinfo
if entry[0] == self.username:
self.password = entry[1]
--
To view, visit https://gerrit.wikimedia.org/r/81520
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7fe9fe9842cdb61b8ecb373a2c071b2def54bff2
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Toto Azéro <totoazero(a)yahoo.fr>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
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: Toto Azéro <totoazero(a)yahoo.fr>
Gerrit-Reviewer: jenkins-bot
Legoktm has submitted this change and it was merged.
Change subject: Support to add a reference with multiple claims.
......................................................................
Support to add a reference with multiple claims.
site.editSource() accepts now either a single claim
(=backward-compatible) for a single claim reference
or a list of claims for a multi claim reference
page.addSources() is new and takes a list of claims
in contrast to page.addSource()
Claim.sources is a list of dicts now. Thus, it is possible
to check if a property is contained.
Change-Id: Iac583043531ba3f30985244ffad2aef2ad549f51
---
M pywikibot/page.py
M pywikibot/site.py
2 files changed, 65 insertions(+), 34 deletions(-)
Approvals:
Legoktm: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 8816da2..bb87d46 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -87,8 +87,8 @@
self._revisions = {}
else:
raise pywikibot.Error(
- "Invalid argument type '%s' in Page constructor: %s"
- % (type(source), source))
+ "Invalid argument type '%s' in Page constructor: %s"
+ % (type(source), source))
@property
def site(self):
@@ -2741,9 +2741,15 @@
bit differently, and require some
more handling.
"""
- mainsnak = data['snaks'].values()[0][0]
- wrap = {'mainsnak': mainsnak, 'hash': data['hash']}
- return Claim.fromJSON(site, wrap)
+ source = {}
+ for prop in data['snaks'].values():
+ for claimsnak in prop:
+ claim = Claim.fromJSON(site, {'mainsnak': claimsnak, 'hash': data['hash']})
+ if claim.getID() in source:
+ source[claim.getID()].append(claim)
+ else:
+ source[claim.getID()] = [claim]
+ return source
@staticmethod
def qualifierFromJSON(site, data):
@@ -2754,7 +2760,6 @@
"""
wrap = {'mainsnak': data}
return Claim.fromJSON(site, wrap)
-
def setTarget(self, value):
"""
@@ -2815,18 +2820,33 @@
def getSources(self):
"""
- Returns a list of Claims
+ Returns a list of sources. Each source is a list of Claims.
"""
return self.sources
- def addSource(self, source, **kwargs):
+ def addSource(self, claim, **kwargs):
"""
- source is a Claim.
- adds it as a reference.
+ Adds the claim as a source.
+ @param claim: the claim to add
+ @type claim: pywikibot.Claim
"""
- data = self.repo.editSource(self, source, new=True, **kwargs)
- source.hash = data['reference']['hash']
- self.on_item.lastrevid = data['pageinfo']['lastrevid']
+ self.addSources([claim], **kwargs)
+
+ def addSources(self, claims, **kwargs):
+ """
+ Adds the claims as one source.
+ @param claims: the claims to add
+ @type claims: list of pywikibot.Claim
+ """
+ data = self.repo.editSource(self, claims, new=True, **kwargs)
+ source = {}
+ for claim in claims:
+ claim.hash = data['reference']['hash']
+ self.on_item.lastrevid = data['pageinfo']['lastrevid']
+ if claim.getID() in source:
+ source[claim.getID()].append(claim)
+ else:
+ source[claim.getID()] = [claim]
self.sources.append(source)
def _formatDataValue(self):
@@ -2845,8 +2865,6 @@
else:
raise NotImplementedError('%s datatype is not supported yet.' % self.getType())
return value
-
-
class Revision(object):
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 4e5dfaf..2d8142e 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3385,7 +3385,7 @@
"""get the data for multiple Wikibase items"""
if type(source) == int or \
isinstance(source, basestring) and source.isdigit():
- ids = 'q'+str(source)
+ ids = 'q' + str(source)
wbrequest = api.Request(site=self, action="wbgetentities", ids=ids,
**params)
wbdata = wbrequest.submit()
@@ -3435,7 +3435,7 @@
#Store it for 100 years
req = api.CachedRequest(expiry, site=self, **params)
data = req.submit()
- dtype = data['entities'][prop.getID()]['datatype']
+ dtype = data['entities'][prop.getID()]['datatype']
if dtype == 'globe-coordinate':
dtype = 'globecoordinate'
#TODO Fix this
@@ -3535,25 +3535,38 @@
if bot:
params['bot'] = 1
params['token'] = self.token(claim, 'edit')
- if not new and hasattr(source, 'hash'):
- params['reference'] = source.hash
#build up the snak
- if source.getType() == 'wikibase-item':
- datavalue = {'type': 'wikibase-entityid',
- 'value': source._formatDataValue(),
- }
- elif source.getType() == 'string':
- datavalue = {'type': 'string',
- 'value': source._formatDataValue(),
- }
+ if isinstance(source, list):
+ sources = source
else:
- raise NotImplementedError('%s datatype is not supported yet.' % claim.getType())
- snak = {source.getID(): [{'snaktype': 'value',
- 'property': source.getID(),
- 'datavalue': datavalue,
- },
- ],
- }
+ sources = [source]
+
+ snak = {}
+ for sourceclaim in sources:
+ if sourceclaim.getType() == 'wikibase-item':
+ datavalue = {'type': 'wikibase-entityid',
+ 'value': sourceclaim._formatDataValue(),
+ }
+ elif sourceclaim.getType() == 'string':
+ datavalue = {'type': 'string',
+ 'value': sourceclaim._formatDataValue(),
+ }
+ else:
+ raise NotImplementedError('%s datatype is not supported yet.' % sourceclaim.getType())
+ valuesnaks = []
+ if sourceclaim.getID() in snak:
+ valuesnaks = snak[sourceclaim.getID()]
+ valuesnaks.append({'snaktype': 'value',
+ 'property': sourceclaim.getID(),
+ 'datavalue': datavalue,
+ },
+ )
+
+ snak[sourceclaim.getID()] = valuesnaks
+ # set the hash if the source should be changed. if present, all claims of one source have the same hash
+ if not new and hasattr(sourceclaim, 'hash'):
+ params['reference'] = sourceclaim.hash
+
params['snaks'] = json.dumps(snak)
for arg in kwargs:
if arg in ['bot', 'lastrevid']:
--
To view, visit https://gerrit.wikimedia.org/r/81219
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iac583043531ba3f30985244ffad2aef2ad549f51
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: FelixReimann <felix(a)fex-it.de>
Gerrit-Reviewer: FelixReimann <felix(a)fex-it.de>
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: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: pwb_tests: set PYWIKIBOT2_DIR from base_dir
......................................................................
pwb_tests: set PYWIKIBOT2_DIR from base_dir
If the tests are run from setup.py test without PYWIKIBOT2_DIR set,
it will use base_dir='~/.pywikibot'. This is OK for all tests, except
when calling pwb.py -- which will assume base_dir is the checkout dir
instead, and thus ask for information to create a new user-config.py.
This commit makes sure PYWIKIBOT2_DIR is set to base_dir (='~/.pywikibot')
before calling pwb.py, which will make pwb.py check that directory instead.
Change-Id: I0a277425b4f9df5b64c325b7d2712f4ba007a260
Fixes-Change-Id: Ic8522e1f08c359fff4085c172e696e62ca969a70
Fixes-Change-Id: Iaeaaf1b34d3e2bcacf8308d2c3b74bd8f711ec6a
Fixes-Change-Id: If9458fca50f07f08441dbb6e06f78bdbae2065de
---
M tests/pwb_tests.py
1 file changed, 10 insertions(+), 4 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index 5a97483..506b02f 100644
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -12,17 +12,23 @@
import unittest
+import pywikibot
+
pypath = sys.executable
basepath = os.path.split(os.path.split(__file__)[0])[0]
pwbpath = os.path.join(basepath, 'pwb.py')
testbasepath = os.path.join(basepath, 'tests', 'pwb')
class TestPwb(unittest.TestCase):
- @unittest.skip("""Skipping test due to broken Travis run.
+ def setUp(self):
+ self.oldenviron = os.environ.copy()
+ os.environ['PYWIKIBOT2_DIR'] = pywikibot.config.base_dir
-Probably the shelling out causes an issue, but we have to investigate this.
-See https://gerrit.wikimedia.org/r/#/c/76486/ and
- https://gerrit.wikimedia.org/r/#/c/82370/ for details. """)
+ def tearDown(self):
+ del os.environ['PYWIKIBOT2_DIR']
+ if 'PYWIKIBOT2_DIR' in self.oldenviron:
+ os.environ['PYWIKIBOT2_DIR'] = self.oldenviron['PYWIKIBOT2_DIR']
+
def testScriptEnvironment(self):
"""Make sure the environment is not contaminated, and is the same as
the environment we get when directly running a script."""
--
To view, visit https://gerrit.wikimedia.org/r/82425
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0a277425b4f9df5b64c325b7d2712f4ba007a260
Gerrit-PatchSet: 1
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: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Fix 'Disable pwb_tests to prevent Travis build failures'
......................................................................
Fix 'Disable pwb_tests to prevent Travis build failures'
Now with actual closing bracket.
Change-Id: Ic8522e1f08c359fff4085c172e696e62ca969a70
Fixes-Change-Id: Iaeaaf1b34d3e2bcacf8308d2c3b74bd8f711ec6a
---
M tests/pwb_tests.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index af44203..5a97483 100644
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -22,7 +22,7 @@
Probably the shelling out causes an issue, but we have to investigate this.
See https://gerrit.wikimedia.org/r/#/c/76486/ and
- https://gerrit.wikimedia.org/r/#/c/82370/ for details. """
+ https://gerrit.wikimedia.org/r/#/c/82370/ for details. """)
def testScriptEnvironment(self):
"""Make sure the environment is not contaminated, and is the same as
the environment we get when directly running a script."""
--
To view, visit https://gerrit.wikimedia.org/r/82422
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic8522e1f08c359fff4085c172e696e62ca969a70
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(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: Disable pwb_tests to prevent Travis build failures
......................................................................
Disable pwb_tests to prevent Travis build failures
I'm fairly certain this is a testing issue related to shelling
out, or possibly to environment variables. However, the test
passes for me, so I think the most reasonable option for now
is to disable the test and then to see why Travis fails.
Change-Id: Iaeaaf1b34d3e2bcacf8308d2c3b74bd8f711ec6a
---
M tests/pwb_tests.py
1 file changed, 5 insertions(+), 0 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index 4cb9759..af44203 100644
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -18,6 +18,11 @@
testbasepath = os.path.join(basepath, 'tests', 'pwb')
class TestPwb(unittest.TestCase):
+ @unittest.skip("""Skipping test due to broken Travis run.
+
+Probably the shelling out causes an issue, but we have to investigate this.
+See https://gerrit.wikimedia.org/r/#/c/76486/ and
+ https://gerrit.wikimedia.org/r/#/c/82370/ for details. """
def testScriptEnvironment(self):
"""Make sure the environment is not contaminated, and is the same as
the environment we get when directly running a script."""
--
To view, visit https://gerrit.wikimedia.org/r/82370
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaeaaf1b34d3e2bcacf8308d2c3b74bd8f711ec6a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(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: Fix and document parameters that Site.newpages was passing to Site.recentchanges
......................................................................
Fix and document parameters that Site.newpages was passing to Site.recentchanges
Also added type hinting to the various parameters.
Change-Id: Icbc9f988a6c533788f1d1d9867411eda901017c2
---
M pywikibot/site.py
1 file changed, 22 insertions(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 1b1f1d6..1c0b144 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2242,29 +2242,43 @@
namespaces=None, pagelist=None, changetype=None,
showMinor=None, showBot=None, showAnon=None,
showRedirects=None, showPatrolled=None, topOnly=False,
- step=None, total=None):
+ step=None, total=None, user=None, excludeuser=None):
"""Iterate recent changes.
@param start: Timestamp to start listing from
+ @type start: pywikibot.Timestamp
@param end: Timestamp to end listing at
+ @type end: pywikibot.Timestamp
@param reverse: if True, start with oldest changes (default: newest)
+ @type reverse: bool
@param pagelist: iterate changes to pages in this list only
@param pagelist: list of Pages
@param changetype: only iterate changes of this type ("edit" for
edits to existing pages, "new" for new pages, "log" for log
entries)
+ @type changetype: basestring
@param showMinor: if True, only list minor edits; if False (and not
None), only list non-minor edits
+ @type showMinor: bool
@param showBot: if True, only list bot edits; if False (and not
None), only list non-bot edits
+ @type showBot: bool
@param showAnon: if True, only list anon edits; if False (and not
None), only list non-anon edits
+ @type showAnon: bool
@param showRedirects: if True, only list edits to redirect pages; if
False (and not None), only list edits to non-redirect pages
+ @type showRedirects: bool
@param showPatrolled: if True, only list patrolled edits; if False
(and not None), only list non-patrolled edits
+ @type showPatrolled: bool
@param topOnly: if True, only list changes that are the latest revision
(default False)
+ @type topOnly: bool
+ @param user: if not None, only list edits by this user or users
+ @type user: basestring|list
+ @param excludeuser: if not None, exclude edits by this user or users
+ @type excludeuser: basestring|list
"""
if start and end:
@@ -2312,6 +2326,13 @@
rcshow.append(filters[item] and item or ("!" + item))
if rcshow:
rcgen.request["rcshow"] = "|".join(rcshow)
+
+ if user:
+ rcgen.request['rcuser'] = user
+
+ if excludeuser:
+ rcgen.request['rcexcludeuser'] = excludeuser
+
return rcgen
@deprecate_arg("number", "limit")
--
To view, visit https://gerrit.wikimedia.org/r/82220
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icbc9f988a6c533788f1d1d9867411eda901017c2
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(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: jenkins-bot