Skip to content

Set rank of claim as preferred and other claims to normal #562

Description

@lubianat

Hi! I am trying to add some new population statements for Brazilian municipalities.

I am planning to adapt some pywikibot code I used for death counts:

	        item = pywikibot.ItemPage(repo, row["item"])
        item.get()  # Fetch all page data, and cache it.

        # Change rank of current deaths to normal
        # (code based on https://gist.github.com/urbanecm/f0b2bb95514f322207d04908cc4d8143)
        itemData = item.get()
        death_claims = itemData["claims"].get("P1120", [])
        for claim in death_claims:
            if claim.rank != "preferred":
                continue
            claim.setRank("normal")
            item.editEntity(
                {"claims": [claim.toJSON()]}, summary="Change P1120 rank to normal"
            )

        # Add number of deaths

        ## Value --> death count

        deaths_claim = pywikibot.Claim(
            repo, u"P1120"
        )  # Adding number of deaths (P1120)
        deaths_claim.setTarget(
            pywikibot.WbQuantity(row["deaths"])
        )  # Set the target value in the local object.
        deaths_claim.setRank("preferred")
        item.addClaim(deaths_claim, summary=u"Adding death count from template")

I am trying to figure out if there is a way to do it using WikibaseIntegrator. Can anyone show me some pointers? Thanks! (@LeMyst or @dpriskorn )

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions