Mercurial > hg > config
annotate python/actions.py @ 255:1f7325245dc8
more stubbing
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 16 Dec 2012 22:27:28 -0800 |
parents | 56537ed6ebc6 |
children | f40a172512c6 |
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 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 def __call__(self, function): |
255 | 9 self.functions[function.func_name] = function |
254
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 return function |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 |
255 | 12 def do(self, func_name, *args, **kwargs): |
13 pass | |
14 | |
254
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 action = Actions() |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 @action |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 def foo(): |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 print "hello" |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 @action |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 def bar(): |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 print "goodbye" |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 if __name__ == '__main__': |
56537ed6ebc6
sample actions file with dependencies (stub)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 pass |