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
Xqt has submitted this change and it was merged.
Change subject: Updated pwb.py to better mirror direct script runs
......................................................................
Updated pwb.py to better mirror direct script runs
Before, execfile() ran the script in environment that pwb.py has, which
included os and path imports, and several other variables.
This commit uses run_python_file from Ned Batchelors' coverage.py [1],
available under the BSD license [2]. See also his blog posts on the
subject [3,4].
This commit also adds a test that shells out to compare the locals()
for runs through pwb.py as well as to a script directly.
After this change, the effects of changeset 76484 can be seen using pwb.py
[1] https://bitbucket.org/ned/coveragepy/src/b5abcee50dbe/coverage/execfile.py
[2] https://bitbucket.org/ned/coveragepy/src/2c5fb3a8b81cc56d8ad57dd1bd83ef7740…
[3] http://nedbatchelder.com/blog/200904/running_a_python_file_as_main.html
[4] http://nedbatchelder.com/blog/200905/running_a_python_file_as_main_take_2.h…
Change-Id: If9458fca50f07f08441dbb6e06f78bdbae2065de
---
M pwb.py
A tests/pwb/print_locals.py
A tests/pwb_tests.py
3 files changed, 89 insertions(+), 13 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index ae732ed..94fef0c 100644
--- a/pwb.py
+++ b/pwb.py
@@ -12,8 +12,50 @@
# Distributed under the terms of the MIT license.
#
-import sys
+
+# The following snippet was developed by Ned Batchelder (and others)
+# for coverage.py [1], and is available under the BSD license (see [2])
+# [1] https://bitbucket.org/ned/coveragepy/src/b5abcee50dbe/coverage/execfile.py
+# [2] https://bitbucket.org/ned/coveragepy/src/2c5fb3a8b81cc56d8ad57dd1bd83ef7740…
+
+import imp
import os
+import sys
+
+
+def run_python_file(filename, args):
+ """Run a python file as if it were the main program on the command line.
+
+ `filename` is the path to the file to execute, it need not be a .py file.
+ `args` is the argument array to present as sys.argv, including the first
+ element representing the file being executed.
+
+ """
+ # Create a module to serve as __main__
+ old_main_mod = sys.modules['__main__']
+ main_mod = imp.new_module('__main__')
+ sys.modules['__main__'] = main_mod
+ main_mod.__file__ = filename
+ main_mod.__builtins__ = sys.modules['__builtin__']
+
+ # Set sys.argv and the first path element properly.
+ old_argv = sys.argv
+ old_path0 = sys.path[0]
+ sys.argv = args
+ sys.path[0] = os.path.dirname(filename)
+
+ try:
+ source = open(filename).read()
+ exec compile(source, filename, "exec") in main_mod.__dict__
+ finally:
+ # Restore the old __main__
+ sys.modules['__main__'] = old_main_mod
+
+ # Restore the old argv and path
+ sys.argv = old_argv
+ sys.path[0] = old_path0
+
+#### end of snippet
if sys.version_info[0] != 2:
raise RuntimeError("ERROR: Pywikipediabot only runs under Python 2")
@@ -33,21 +75,20 @@
os.environ["PYWIKIBOT2_DIR"] = os.path.split(__file__)[0]
if not os.path.exists(os.path.join(os.environ["PYWIKIBOT2_DIR"], "user-config.py")):
- execfile('generate_user_files.py')
+ run_python_file('generate_user_files.py', ['generate_user_files.py'])
-sys.argv.pop(0)
-if len(sys.argv) > 0:
- if not os.path.exists(sys.argv[0]):
- testpath = os.path.join(os.path.split(__file__)[0], 'scripts', sys.argv[0])
+if len(sys.argv) > 1:
+ fn = sys.argv[1]
+ args = sys.argv[1:]
+
+ if not os.path.exists(fn):
+ testpath = os.path.join(os.path.split(__file__)[0], 'scripts', fn)
if os.path.exists(testpath):
- sys.argv[0] = testpath
+ fn = testpath
else:
testpath = testpath + '.py'
if os.path.exists(testpath):
- sys.argv[0] = testpath
+ fn = testpath
else:
- raise Exception("%s not found!" % sys.argv[0])
- sys.path.append(os.path.split(sys.argv[0])[0])
- execfile(sys.argv[0])
-else:
- sys.argv.append('')
+ raise Exception("%s not found!" % fn)
+ run_python_file(fn, args)
diff --git a/tests/pwb/print_locals.py b/tests/pwb/print_locals.py
new file mode 100644
index 0000000..1b84ac0
--- /dev/null
+++ b/tests/pwb/print_locals.py
@@ -0,0 +1,4 @@
+"""docstring"""
+
+for k,v in locals().copy().iteritems():
+ print repr(k), ":", repr(v)
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
new file mode 100644
index 0000000..4cb9759
--- /dev/null
+++ b/tests/pwb_tests.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+#
+# (C) Pywikipedia bot team, 2007
+#
+# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
+
+import os
+import sys
+import subprocess
+
+import unittest
+
+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):
+ def testScriptEnvironment(self):
+ """Make sure the environment is not contaminated, and is the same as
+ the environment we get when directly running a script."""
+ test = os.path.join(testbasepath, 'print_locals.py')
+
+ direct = subprocess.check_output([pypath, test])
+ vpwb = subprocess.check_output([pypath, pwbpath, test])
+ self.assertEqual(direct, vpwb)
+
+if __name__=="__main__":
+ unittest.main(verbosity=10)
--
To view, visit https://gerrit.wikimedia.org/r/76486
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If9458fca50f07f08441dbb6e06f78bdbae2065de
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change and it was merged.
Change subject: Set correct language as source
......................................................................
Set correct language as source
Patch is basically the same as d90be6a8765.
Bug: https://sourceforge.net/p/pywikipediabot/feature-requests/346/
Change-Id: Ic2a6010903a3586803687f350f95ce33fa6abbb2
---
M scripts/claimit.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 02bdf35..0f50db0 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -37,15 +37,15 @@
self.setSource(pywikibot.Site().language())
def setSource(self, lang):
- '''
+ """
Get the source
- '''
+ """
page = pywikibot.Page(self.repo, 'Wikidata:List of wikis/python')
source_values = json.loads(page.get())
source_values = source_values['wikipedia']
- for lang in source_values:
- source_values[lang] = pywikibot.ItemPage(self.repo,
- source_values[lang])
+ for source_lang in source_values:
+ source_values[source_lang] = pywikibot.ItemPage(self.repo,
+ source_values[source_lang])
if lang in source_values:
self.source = pywikibot.Claim(self.repo, 'p143')
--
To view, visit https://gerrit.wikimedia.org/r/82106
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic2a6010903a3586803687f350f95ce33fa6abbb2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(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