LeMyst / WikibaseIntegrator

A Python module to manipulate data on a Wikibase instance (like Wikidata) through the MediaWiki Wikibase API and the Wikibase SPARQL endpoint.
MIT License
67 stars 14 forks source link

Add ActionIfExists.MERGE_REFS_OR_APPEND #619

Closed LeMyst closed 9 months ago

LeMyst commented 1 year ago

Close #607

LeMyst commented 1 year ago

DRAFT...

I'm trying to improve the ActionIfExists enum by using Enum.Flag

Like, you want REPLACE if exist or APPEND otherwise: action_if_exists= ActionIfExists.REPLACE | ActionIfExists.APPEND

You want to just APPEND new claim to existing property: action_if_exists= ActionIfExists.APPEND

Same if you just want to REPLACE existing value without doing nothing more: action_if_exists= ActionIfExists.REPLACE

If you use the word ActionIfExists.KEEP, this do nothing if the property already have claim.

If you want to merge references, you can use the ActionIfExists.MERGE_REFS, in addition with the APPEND and REPLACE action_if_exists= ActionIfExists.APPEND | ActionIfExists.MERGE_REFS

dpriskorn commented 9 months ago

Very nice work. I just tested it, see https://github.com/dpriskorn/WikidataEurLexScraper/issues/2, and I'm happy :) LGTM

dpriskorn commented 1 week ago

Hooray!