From bc7af7204eae2a026a67d2ab9b3cc4e36f23382b Mon Sep 17 00:00:00 2001 From: blob8108 Date: Thu, 19 Dec 2013 19:13:00 +0000 Subject: Initial --- example.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 example.py 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. -- cgit v1.3.1