There should be a reusable, modern and well maintained Python package for Wikibase data types, data streams, etc.
@JeroenDeDauw has built https://pypi.python.org/pypi/WikibaseDataModel hosted at https://github.com/JeroenDeDauw/WikibaseDataModelPython , which is a good starting point, but needs active maintainers to bring it up to date and ensure it stays in sync with Wikibase capabilities.
Various code style and structure discussions are needed to gain consensus from potential stakeholders in this new Python library.
The new library will need to encompass the existing functionality available in other python Wikibase components, or at least provide clean classes and APIs that other Python Wikibase components can re-use effectively.
Pywikibot has its own classes for the Wikibase data types. e.g. https://github.com/wikimedia/pywikibot-core/blob/master/pywikibot/__init__.py#L199 for WbCoordinate and WbTime is below it. There are other feature requests in Pywikibot-Wikidata
Some other python Wikibase components:
here is another one:
https://github.com/asdil12/pywikibase/blob/master/things.py
Some custom property detection
https://github.com/frimelle/wikibase-stuff/blob/master/obsolete-property.py
datatype detection here:
https://github.com/mkroetzsch/wda/blob/1e5b1582344a5405609177a3965ca04e9707488b/includes/epTurtleFileWriter.py#L79
Some good stuff in here:
https://github.com/asciimoo/searx/blob/aac8d3a7bfdd77a5369e52a4ece99b20669a4625/searx/engines/wikidata.py
nasty parsing here:
https://github.com/gnowledge/gstudio/blob/mongokit/gnowsys-ndf/gnowsys_ndf/ndf/management/commands/iterative_script.py#L359
more
https://github.com/WikidataQuality/WikidataQuality/blob/master/external%20validation/wikidata/datatypes.py
https://github.com/Wikidata-lib/PropertySuggester-Python/blob/master/propertysuggester/parser/JsonReader.py
https://github.com/hay/chantek/blob/master/commands/wikidata/entity.py
In addition to the classes, Wikibase datatypes need to have data.
For example pywikibot includes the following in the wikidata family file:
def globes(self, code): """Supported globes for Coordinate datatype.""" return { 'ariel': 'http://www.wikidata.org/entity/Q3343', 'callisto': 'http://www.wikidata.org/entity/Q3134', 'ceres': 'http://www.wikidata.org/entity/Q596', 'deimos': 'http://www.wikidata.org/entity/Q7548', 'dione': 'http://www.wikidata.org/entity/Q15040', 'earth': 'http://www.wikidata.org/entity/Q2', 'enceladus': 'http://www.wikidata.org/entity/Q3303', 'europa': 'http://www.wikidata.org/entity/Q3143', 'ganymede': 'http://www.wikidata.org/entity/Q3169', 'hyperion': 'http://www.wikidata.org/entity/Q15037', 'iapetus': 'http://www.wikidata.org/entity/Q17958', 'io': 'http://www.wikidata.org/entity/Q3123', 'jupiter': 'http://www.wikidata.org/entity/Q319', 'mars': 'http://www.wikidata.org/entity/Q111', 'mercury': 'http://www.wikidata.org/entity/Q308', 'mimas': 'http://www.wikidata.org/entity/Q15034', 'miranda': 'http://www.wikidata.org/entity/Q3352', 'moon': 'http://www.wikidata.org/entity/Q405', 'oberon': 'http://www.wikidata.org/entity/Q3332', 'phobos': 'http://www.wikidata.org/entity/Q7547', 'phoebe': 'http://www.wikidata.org/entity/Q17975', 'pluto': 'http://www.wikidata.org/entity/Q339', 'rhea': 'http://www.wikidata.org/entity/Q108419', 'tethys': 'http://www.wikidata.org/entity/Q15047', 'titan': 'http://www.wikidata.org/entity/Q2565', 'titania': 'http://www.wikidata.org/entity/Q3322', 'triton': 'http://www.wikidata.org/entity/Q3359', 'umbriel': 'http://www.wikidata.org/entity/Q3338', 'venus': 'http://www.wikidata.org/entity/Q313', 'vesta': 'http://www.wikidata.org/entity/Q3030', }
Note that these are http , not https. I cant find any task about Wikidata converting to using HTTPS for these URIs, and I dont expect would or should. At least Q2 is baked into the underlying component, so we can rely on it.
https://github.com/DataValues/Geo/blob/master/src/Values/GlobeCoordinateValue.php#L37 - Q2 = Earth as a default only
https://github.com/DataValues/Time/blob/master/src/DataValues/TimeValue.php#L36 Gregorian vs Julian (used frequently)