There should be a reusable and well maintained Python package for Wikibase data types, data streams, etc.
I expect most Wikibase Python users can agree on it needing to be a very modern and powerful Python toolkit - we dont (yet) have a lot of legacy applications.
We may have more difficulty agreeing on the scope of this new library.
@JeroenDeDauw has built https://pypi.python.org/pypi/WikibaseDataModel hosted at https://github.com/JeroenDeDauw/WikibaseDataModelPython , which looks a bit unmaintained, and needs to be converted to modern Python to be honest, but I think that it is a good 'scope' for this new library. I see he [[https://lists.wikimedia.org/pipermail/pywikibot/2013-September/008300.html| emailed pywikipedia-l]] asking for it to be adopted by someone. We need to do that. If we're going to get a lot of adoption of this library, I would like it to be hosted in a tool like Gerrit, so that the quality of code reviews is high. (This could be an opportunity to start the project using Diffusion ?)
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. We will need to identity which parts of Pywikibot need to be migrated to the new library.
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 - [[http://www.wikidata.org/entity/Q2|Q2 = Earth]] as a default only
https://github.com/DataValues/Time/blob/master/src/DataValues/TimeValue.php#L36 [[http://www.wikidata.org/entity/Q1985727|Gregorian]] vs [[http://www.wikidata.org/entity/Q1985786|Julian]] (used frequently)