jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/584131 )
Change subject: [bugfix] Restore initialization of Claim.on_item ......................................................................
[bugfix] Restore initialization of Claim.on_item
It was accidentally dropped in Icbcc728c7. This patch is just a duct tape. Eventually, this should be subject to another refactoring.
Bug: T248746 Change-Id: I29ed37b23f3883f48ab0abd510faa47bb3e3cb91 --- M pywikibot/page/__init__.py 1 file changed, 30 insertions(+), 1 deletion(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 4704b67..f2f6db8 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -3862,6 +3862,12 @@
return claims
+ def set_on_item(self, item): + """Set Claim.on_item attribute for all claims in this collection.""" + for claims in self.values(): + for claim in claims: + claim.on_item = item +
class SiteLinkCollection(MutableMapping): """A structure holding SiteLinks for a Wikibase item.""" @@ -4439,6 +4445,10 @@ if 'pageid' in self._content: self._pageid = self._content['pageid']
+ # xxx: this is ugly + if 'claims' in data: + self.claims.set_on_item(self) + return data
@property @@ -5241,7 +5251,23 @@ self.qualifiers = OrderedDict() self.target = None self.snaktype = 'value' - self.on_item = None # The item it's on + self._on_item = None # The item it's on + + @property + def on_item(self): + """Return item this claim is attached to.""" + return self._on_item + + @on_item.setter + def on_item(self, item): + self._on_item = item + for values in self.qualifiers.values(): + for qualifier in values: + qualifier.on_item = item + for source in self.sources: + for values in source.values(): + for source in values: + source.on_item = item
def __repr__(self): """Return the representation string.""" @@ -5577,6 +5603,7 @@ self.on_item.latest_revision_id = data['pageinfo']['lastrevid'] for claim in claims: claim.hash = data['reference']['hash'] + claim.on_item = self.on_item source = defaultdict(list) for claim in claims: claim.isReference = True @@ -5618,6 +5645,7 @@ if self.on_item is not None: data = self.repo.editQualifier(self, qualifier, **kwargs) self.on_item.latest_revision_id = data['pageinfo']['lastrevid'] + qualifier.on_item = self.on_item qualifier.isQualifier = True if qualifier.getID() in self.qualifiers: self.qualifiers[qualifier.getID()].append(qualifier) @@ -5644,6 +5672,7 @@ self.on_item.latest_revision_id = data['pageinfo']['lastrevid'] for qualifier in qualifiers: self.qualifiers[qualifier.getID()].remove(qualifier) + qualifier.on_item = None
def target_equals(self, value): """
pywikibot-commits@lists.wikimedia.org