annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 # STUB: from
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 # http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 class Actions(object):
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 def __init__(self):
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 self.functions = {}
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 def __call__(self, function, dependencies):
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 import pdb; pdb.set_trace()
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 self.functions[function.func_name] = function
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 return function
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 def do(self, func_name):
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 self.functions[func_name]()
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 action = Actions()
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 @action
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 def foo():
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 print "hello"
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 @action('foo')
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 def bar():
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 print "goodbye"
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29 if __name__ == '__main__':
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 pass
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
31
734d26329c82 from http://k0s.org/hg/config/file/c328382f68ff/python/actions.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
32 action.do('bar')