summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblob8108 <blob8108@gmail.com>2013-12-19 19:13:00 +0000
committerblob8108 <blob8108@gmail.com>2013-12-19 19:13:00 +0000
commitbc7af7204eae2a026a67d2ab9b3cc4e36f23382b (patch)
tree54546d3a7d0bbc221089d91f18184e0a5a256a6e
downloadblockext-bc7af7204eae2a026a67d2ab9b3cc4e36f23382b.tar.gz
blockext-bc7af7204eae2a026a67d2ab9b3cc4e36f23382b.zip
Initial
-rw-r--r--example.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/example.py b/example.py
new file mode 100644
index 0000000..c717ef2
--- /dev/null
+++ b/example.py
@@ -0,0 +1,43 @@
+"""
+blockext spec
+for tim
+because he's too good for a doc file
+
+Example code:
+"""
+
+import blockext
+
+blockext.PORT = 1234
+
+@blockext.predicate("/tf")
+def tf():
+ blockspec = "true or false"
+ return random.choice(True, False)
+
+
+@blockext.reporter("/weather", blocking=True)
+def weather(city):
+ blockspec = "current weather in %s"
+ return weatherIn(city)
+
+@blockext.reporter("/light")
+def light():
+ blockspec = "light sensor value"
+ return lightsensor.get()
+
+@blockext.stack("/move")
+def move(degrees):
+ blockspec = "move %n degrees"
+ move(degrees)
+
+blockext.generate_extension(blockext.SCRATCH, "extension.json")
+blockext.generate_extension(blockext.SNAP, "extension.xml")
+if __name__ == "__main__":
+ blockext.run()
+
+
+# I suppose a launcher could do that on demand
+
+# Or run() could do it for you. Really I wanted you to think about *why* you're
+# doing stuff.