jenkins-bot has submitted this change and it was merged.
Change subject: Use new Property.type getter ......................................................................
Use new Property.type getter
- claimit.py: type getter returns 'globe-coordinate' instead of 'globecoordinate' returned by now deprecated .getType()
Change-Id: Ie0add58d3a5d795a0258b2d1a06ea6216d50b8e1 --- M pywikibot/data/wikidataquery.py M pywikibot/site.py M scripts/claimit.py M scripts/harvest_template.py M scripts/illustrate_wikidata.py 5 files changed, 18 insertions(+), 17 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/wikidataquery.py b/pywikibot/data/wikidataquery.py index c606a18..239dbbb 100644 --- a/pywikibot/data/wikidataquery.py +++ b/pywikibot/data/wikidataquery.py @@ -385,13 +385,13 @@ if not isinstance(claim, Claim): raise(TypeError, "claim must be a page.Claim")
- if claim.getType() == 'wikibase-item': + if claim.type == 'wikibase-item': return HasClaim(claim.getID(numeric=True), claim.getTarget().getID(numeric=True)) - if claim.getType() == 'string': + if claim.type == 'string': return StringClaim(claim.getID(numeric=True), claim.getTarget()) else: raise(TypeError, "Cannot construct a query from a claim of type %s" - % claim.getType()) + % claim.type)
class WikidataQuery(): diff --git a/pywikibot/site.py b/pywikibot/site.py index ef57dc1..34f7124 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -3835,21 +3835,21 @@
snak = {} for sourceclaim in sources: - if sourceclaim.getType() == 'wikibase-item': + if sourceclaim.type == 'wikibase-item': datavalue = {'type': 'wikibase-entityid', 'value': sourceclaim._formatDataValue(), } - elif sourceclaim.getType() in ['string', 'url']: + elif sourceclaim.type in ['string', 'url']: datavalue = {'type': 'string', 'value': sourceclaim._formatDataValue(), } - elif sourceclaim.getType() == 'time': + elif sourceclaim.type == 'time': datavalue = {'type': 'time', 'value': sourceclaim._formatDataValue(), } else: raise NotImplementedError('%s datatype is not supported yet.' - % sourceclaim.getType()) + % sourceclaim.type) valuesnaks = [] if sourceclaim.getID() in snak: valuesnaks = snak[sourceclaim.getID()] diff --git a/scripts/claimit.py b/scripts/claimit.py index bf01b55..af74030 100755 --- a/scripts/claimit.py +++ b/scripts/claimit.py @@ -170,11 +170,11 @@ repo = pywikibot.Site().data_repository() for i in range(0, len(commandline_claims), 2): claim = pywikibot.Claim(repo, commandline_claims[i]) - if claim.getType() == 'wikibase-item': + if claim.type == 'wikibase-item': target = pywikibot.ItemPage(repo, commandline_claims[i + 1]) - elif claim.getType() == 'string': + elif claim.type == 'string': target = commandline_claims[i + 1] - elif claim.getType() == 'globecoordinate': + elif claim.type == 'globe-coordinate': coord_args = map(float, commandline_claims[i + 1].split(',')) if len(coord_args) >= 3: precision = coord_args[2] @@ -184,7 +184,7 @@ else: raise NotImplementedError( "%s datatype is not yet supported by claimit.py" - % claim.getType()) + % claim.type) claim.setTarget(target) claims.append(claim)
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py index c70c9f2..263b838 100755 --- a/scripts/harvest_template.py +++ b/scripts/harvest_template.py @@ -153,7 +153,7 @@ # harvested values with existing claims esp. # without overwriting humans unintentionally. else: - if claim.getType() == 'wikibase-item': + if claim.type == 'wikibase-item': # Try to extract a valid page match = re.search(pywikibot.link_regex, value) if not match: @@ -166,9 +166,9 @@ continue
claim.setTarget(linked_item) - elif claim.getType() == 'string': + elif claim.type == 'string': claim.setTarget(value.strip()) - elif claim.getType() == 'commonsMedia': + elif claim.type == 'commonsMedia': commonssite = pywikibot.Site("commons", "commons") imagelink = pywikibot.Link(value, source=commonssite, defaultNamespace=6) image = pywikibot.ImagePage(imagelink) @@ -179,7 +179,7 @@ continue claim.setTarget(image) else: - pywikibot.output("%s is not a supported datatype." % claim.getType()) + pywikibot.output("%s is not a supported datatype." % claim.type) continue
pywikibot.output('Adding %s --> %s' % (claim.getID(), claim.getTarget())) diff --git a/scripts/illustrate_wikidata.py b/scripts/illustrate_wikidata.py index 7fde432..5a845ff 100644 --- a/scripts/illustrate_wikidata.py +++ b/scripts/illustrate_wikidata.py @@ -44,8 +44,9 @@ self.cacheSources()
claim = pywikibot.Claim(self.repo, self.wdproperty) - if not claim.getType() == 'commonsMedia': - raise ValueError(u'%s is of type %s, should be commonsMedia' % (self.wdproperty, claim.getType())) + if claim.type != 'commonsMedia': + raise ValueError(u'%s is of type %s, should be commonsMedia' + % (self.wdproperty, claim.type))
def run(self): """
pywikibot-commits@lists.wikimedia.org