Mercurial > hg > IntentMadeManifest
comparison actions.py @ 17:734d26329c82
from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Mon, 29 Jul 2013 22:14:44 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 16:4353d36a2f80 | 17:734d26329c82 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 # STUB: from | |
| 4 # http://k0s.org/hg/config/file/c328382f68ff/python/actions.py | |
| 5 | |
| 6 class Actions(object): | |
| 7 | |
| 8 def __init__(self): | |
| 9 self.functions = {} | |
| 10 | |
| 11 def __call__(self, function, dependencies): | |
| 12 import pdb; pdb.set_trace() | |
| 13 self.functions[function.func_name] = function | |
| 14 return function | |
| 15 | |
| 16 def do(self, func_name): | |
| 17 self.functions[func_name]() | |
| 18 | |
| 19 action = Actions() | |
| 20 | |
| 21 @action | |
| 22 def foo(): | |
| 23 print "hello" | |
| 24 | |
| 25 @action('foo') | |
| 26 def bar(): | |
| 27 print "goodbye" | |
| 28 | |
| 29 if __name__ == '__main__': | |
| 30 pass | |
| 31 | |
| 32 action.do('bar') |
