本文整理汇总了Python中doit.doit_cmd.DoitMain类的典型用法代码示例。如果您正苦于以下问题:Python DoitMain类的具体用法?Python DoitMain怎么用?Python DoitMain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DoitMain类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
def start(self):
"""Begin executing tasks."""
if self.log_filename:
print('Output will be logged to `%s`.' % self.log_filename)
start_time = time.strftime(self.timestamp_fmt)
print('Started %s' % start_time)
if self.log_filename:
orig_stdout = sys.stdout
orig_stderr = sys.stderr
sys.stdout = self.log_file
sys.stderr = self.log_file
print('Started %s' % start_time)
doit_main = DoitMain(self)
doit_main.run(['run'])
stop_time = time.strftime(self.timestamp_fmt)
if self.log_filename:
print('Stopped %s' % stop_time)
print()
sys.stdout = orig_stdout
sys.stderr = orig_stderr
self.log_file.close()
print('Stopped %s' % stop_time)
示例2: doit
def doit(line):
"""
Run *doit* with `task_creators` from all interactive variables
(IPython's global namespace).
Examples:
>>> %doit --help ## Show help for options and arguments.
>>> def task_foo():
return {'actions': ['echo hi IPython'],
'verbosity': 2}
>>> %doit list ## List any tasks discovered.
foo
>>> %doit ## Run any tasks.
. foo
hi IPython
"""
ip = get_ipython()
# Override db-files location inside ipython-profile dir,
# which is certainly writable.
prof_dir = ip.profile_dir.location
opt_vals = {'dep_file': os.path.join(prof_dir, 'db', '.doit.db')}
commander = DoitMain(ModuleTaskLoader(ip.user_module),
extra_config={'GLOBAL': opt_vals})
commander.run(line.split())
示例3: main
def main():
configure_test()
load_exps()
doit_main = DoitMain(CustomTaskLoader())
return doit_main.run(['run'])
示例4: test_help_plugin_name
def test_help_plugin_name(self, capsys):
plugin = {'XXX': 'tests.sample_plugin:MyCmd'}
main = DoitMain(extra_config={'COMMAND':plugin})
main.BIN_NAME = 'doit'
returned = main.run(["help"])
assert returned == 0
out, err = capsys.readouterr()
assert "doit XXX " in out
assert "test extending doit commands" in out, out
示例5: main
def main(argv=None):
myname = path.basename(sys.argv[0]) # @UnusedVariable
mydir = path.dirname(__file__) # @UnusedVariable
if argv is None:
argv = sys.argv[1:]
opt_vals = {} # 'dep_file': path.abspath(path.join(mydir, '.doit.db'))}
commander = DoitMain(ModuleTaskLoader(pndlcmd),
extra_config={'GLOBAL': opt_vals})
commander.run(argv)
示例6: get_commands
def get_commands(self):
# core doit commands
cmds = DoitMain.get_commands(self)
# load nikola commands
for name, cmd in self.nikola.commands.items():
cmds[name] = cmd
return cmds
示例7: get_commands
def get_commands(self):
# core doit commands
cmds = DoitMain.get_commands(self)
# load nikola commands
for name, cmd in self.nikola.commands.items():
cmds[name] = cmd
# Hide run because Nikola uses build
cmds.pop('run')
return cmds
示例8: cmd_main
def cmd_main(args, extra_config=None, bin_name='doit'):
if extra_config:
extra_config = {'GLOBAL': extra_config}
main = DoitMain(extra_config=extra_config)
main.BIN_NAME = bin_name
return main.run(args)
示例9: get_commands
def get_commands(self):
cmds = DoitMain.get_commands(self)
my_cmd = MyCmd()
cmds[my_cmd.name] = my_cmd
return cmds
示例10: doit_app
def doit_app(request):
app = DoitMain()
app.sub_cmds['tabcompletion'] = TabCompletion()
app.sub_cmds['help'] = Help()
return app