Mercurial > hg > config
annotate python/actions.py @ 388:3678770e8c52
changes
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 27 Jul 2013 18:45:43 -0700 |
parents | f4594857d606 |
children |
rev | line source |
---|---|
254
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 class Actions(object): |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 def __init__(self): |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 self.functions = {} |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 |
257 | 8 def __call__(self, function, dependencies): |
256 | 9 import pdb; pdb.set_trace() |
255 | 10 self.functions[function.func_name] = function |
254
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 return function |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 |
256 | 13 def do(self, func_name): |
14 self.functions[func_name]() | |
255 | 15 |
254
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 action = Actions() |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 @action |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 def foo(): |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 print "hello" |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 |
256 | 22 @action('foo') |
254
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 def bar(): |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 print "goodbye" |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 if __name__ == '__main__': |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
27 pass |
256 | 28 |
29 action.do('bar') |