doit自动化任务管理工具
doit来自于使用构建工具的强大功能来执行任何类型的任务。
下面是一个例子:
def task_imports(): """find imports from a python module""" for name, module in PKG_MODULES.by_name.items(): yield { 'name': name, 'file_dep': [module.path], 'actions': [(get_imports, (PKG_MODULES, module.path))], } def task_dot(): """generate a graphviz's dot graph from module imports""" return { 'targets': ['requests.dot'], 'actions': [module_to_dot], 'getargs': {'imports': ('imports', 'modules')}, 'clean': True, } def task_draw(): """generate image from a dot file""" return { 'file_dep': ['requests.dot'], 'targets': ['requests.png'], 'actions': ['dot -Tpng %(dependencies)s -o %(targets)s'], 'clean': True, }
$ doit list dot generate a graphviz's dot graph from module imports draw generate image from a dot file imports find imports from a python module $ doit . imports:requests.models . imports:requests.__init__ . imports:requests.help (...) . dot . draw
评论