Created
July 20, 2012 12:32
-
-
Save naquad/3150493 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _command(self, parser = default_parser, name = None): | |
def wrap(func): | |
if not inspect.isfunction(func): | |
raise RuntimeError, "Only functions allowed to be decorated as command!" | |
if not name: | |
name = func.__name__ | |
if not hasattr(func, '__doc__') or not func.__doc__: | |
raise RuntimeError, "%s must have documentation!" % (name,) | |
if parser not in self.commands: | |
self.commands[parser] = {} | |
self.commands[parser][name] = func | |
return func | |
return wrap | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment