summaryrefslogtreecommitdiffstats
path: root/examples/simple.py
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-01-25 13:26:42 -0800
committerbnewbold <bnewbold@robocracy.org>2016-01-25 13:26:42 -0800
commit69b26a25282454695c87844ad9a868bf6dbf2c0a (patch)
treeaafcab24a860052dec3adf8de7e1766177f9d312 /examples/simple.py
parent3b5cd220c997db5dec98120eccd963f868d0ecad (diff)
downloadbasebasebase-69b26a25282454695c87844ad9a868bf6dbf2c0a.tar.gz
basebasebase-69b26a25282454695c87844ad9a868bf6dbf2c0a.zip
add a simple example script
Diffstat (limited to 'examples/simple.py')
-rw-r--r--examples/simple.py47
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])