diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/simple.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/simple.py b/examples/simple.py new file mode 100644 index 0000000..6158f98 --- /dev/null +++ b/examples/simple.py @@ -0,0 +1,47 @@ + +from bbb import * + +wikidata = WikibaseServer(api_url="https://test.wikidata.org/w/api.php", + lang="en") + +# This will check that the site and auth stuff works +wikidata.check() + +earth = wikidata.get_item("Earth") +print(earth) +print(wikidata.get_item("Q10")) + +# http://wikidata.wiki.local.wmftest.net:8080/wiki/Special:ListProperties +mass = wikidata.get_property("P2") +print(mass) + +print(wikidata.search_items("love", limit=5)) +print(wikidata.search_items("robot", limit=5)) +print(wikidata.search_properties("mass", limit=5)) + +print(wikidata.search_items("coffee", limit=5, fetch=True)) + +# TODO: is this possible? +#print(wikidata.search_statements(earth)) +#print(wikidata.search_statements(mass)) + +devsrv = WikibaseServer( + api_url="http://wikidata.wiki.local.wmftest.net:8080/w/api.php") +devsrv.login("TestBaseBot", "TestBaseBot123", force_http=True) +print(devsrv) + +thing = WikibaseItem("QWERTY Layout") +print(thing) +devsrv.create(thing) +print(thing) + +thing.add(WikibaseStatement( + "Inventor of", "Christopher Latham Sholes", + qualifiers={'Year of Invention': 1860}, + refs=['http://www.smithsonianmag.com/arts-culture/fact-of-fiction-the-legend-of-the-qwerty-keyboard-49863249/'])) + +devsrv.save(thing) +print(thing) + +thing.statements[0].deprecate() +devsrv.save(thing.statements[0]) |