view actions.py @ 19:74ada5cb1cb8 default tip

more tools
author Jeff Hammel <k0scist@gmail.com>
date Fri, 04 Dec 2015 12:55:31 -0800
parents 734d26329c82
children
line wrap: on
line source

#!/usr/bin/env python

# STUB: from
# http://k0s.org/hg/config/file/c328382f68ff/python/actions.py

class Actions(object):

    def __init__(self):
        self.functions = {}

    def __call__(self, function, dependencies):
        import pdb; pdb.set_trace()
        self.functions[function.func_name] = function
        return function

    def do(self, func_name):
        self.functions[func_name]()

action = Actions()

@action
def foo():
    print "hello"

@action('foo')
def bar():
    print "goodbye"

if __name__ == '__main__':
    pass

action.do('bar')