diff options
| author | blob8108 <blob8108@gmail.com> | 2014-01-11 12:28:33 +0000 |
|---|---|---|
| committer | blob8108 <blob8108@gmail.com> | 2014-01-11 12:28:33 +0000 |
| commit | c0f175accef3dacfd50bb873f957aeb0bb414e69 (patch) | |
| tree | 74bc8109c7e255d9560cea2d309465f798f75fc6 | |
| parent | e324d03e6d929c8adaba0f74f2d80b4052a86fa4 (diff) | |
| download | blockext-c0f175accef3dacfd50bb873f957aeb0bb414e69.tar.gz blockext-c0f175accef3dacfd50bb873f957aeb0bb414e69.zip | |
Don't show `problem`, `is working` and `reset` blocks in Snap!.
Closes #11.
| -rw-r--r-- | blockext/__init__.py | 23 | ||||
| -rw-r--r-- | blockext/scratch.py | 12 | ||||
| -rw-r--r-- | blockext/snap.py | 5 |
3 files changed, 7 insertions, 33 deletions
diff --git a/blockext/__init__.py b/blockext/__init__.py index 0581cd3..adff2b1 100644 --- a/blockext/__init__.py +++ b/blockext/__init__.py @@ -349,7 +349,7 @@ predicate = _shape("predicate") # Decorators (for special-in-Scratch features) def problem(func): - """Decorator for a built-in problem report block. + """Decorator for the problem report tooltip in Scratch 2.0. The function should return a string describing the problem with the extension, if any. The problem report should help users troubleshoot. @@ -363,15 +363,7 @@ def problem(func): """ - @predicate("{name} is working?", help_text=func.__doc__) - def _no_problem(): - """Reports `true` if the extension is working without any problems.""" - if func: - return not func() - else: - return True - - @reporter("problem with {name}", help_text=func.__doc__) + @reporter("problem with {name}", hidden=True) def _problem(): """Reports a short description of the problem to help troubleshooting. @@ -380,16 +372,11 @@ def problem(func): """ return func() - if not func: - del Blockext.blocks["_problem"] - return _problem -problem(None) - def reset(func): - @command("reset {name}", help_text=func.__doc__) - def _reset(): + @command("reset {name}", hidden=True) + def reset_all(): """Resets the extension to its initial state. Triggered by clicking the red stop button in Scratch 2.0. @@ -397,7 +384,7 @@ def reset(func): """ func() - return _reset + return reset_all def run(name="", filename="extension", port=8080): diff --git a/blockext/scratch.py b/blockext/scratch.py index 34d4d81..b4440ec 100644 --- a/blockext/scratch.py +++ b/blockext/scratch.py @@ -17,6 +17,7 @@ CROSSDOMAIN_XML = """ def crossdomain(is_browser=False): return ("application/xml", CROSSDOMAIN_XML) + BLOCK_SHAPES = { "command": " ", "reporter": "r", @@ -33,7 +34,6 @@ def generate_s2e(is_browser=False): } for name, block in Blockext.blocks.items(): if block.is_hidden: continue - if name in ("_problem", "_no_problem", "_reset"): continue shape = BLOCK_SHAPES[block.shape] if block.shape == "command" and block.is_blocking: shape = "w" @@ -69,16 +69,8 @@ def poll(is_browser=False): ) return ("text/plain", lines) + @reporter("_busy", hidden=True) def _busy(): return " ".join(map(str, Blockext.requests)) - -# The actual command is called _reset so it sorts to the top along with the -# other built-in commands. - -@command("reset_all", hidden=True) -def reset_all(): - block = Blockext.blocks.get("_reset") - if block: block() - diff --git a/blockext/snap.py b/blockext/snap.py index 75c86d9..d176524 100644 --- a/blockext/snap.py +++ b/blockext/snap.py @@ -15,11 +15,6 @@ INPUT_SELECTORS = { "d": "n", } -def pretty(stuff): - import xml.dom.minidom - xml = xml.dom.minidom.parseString(ElementTree.tostring(stuff)) - return xml.toprettyxml() - @handler("snap_{filename}.xml", display="Download Snap! blocks") def generate_xml(is_browser=False): root = Element("blocks", { |
