本文整理汇总了Python中hqc_meas.tasks.api.RootTask.build_from_config方法的典型用法代码示例。如果您正苦于以下问题:Python RootTask.build_from_config方法的具体用法?Python RootTask.build_from_config怎么用?Python RootTask.build_from_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hqc_meas.tasks.api.RootTask
的用法示例。
在下文中一共展示了RootTask.build_from_config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_task_from_config
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import build_from_config [as 别名]
def build_task_from_config(config, dep_source, root=False):
""" Rebuild a task hierarchy from a Section.
Parameters
----------
config : Section
Section representing the task hierarchy.
dep_source :
Source of the build dependencies of the hierarchy. This can either
be the instance of the TaskManager of a dict of dependencies.
Returns
-------
task :
Newly built task.
"""
if not isinstance(dep_source, dict):
core = dep_source.workbench.get_plugin('enaml.workbench.core')
cmd = 'hqc_meas.dependencies.collect_build_dep_from_config'
dep_source = core.invoke_command(cmd, {'config': config})
if isinstance(dep_source, Exception):
return None
if root:
return RootTask.build_from_config(config, dep_source)
else:
task_class = dep_source['tasks'][config.pop('task_class')]
return task_class.build_from_config(config, dep_source)
示例2: test_build_from_config1
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import build_from_config [as 别名]
def test_build_from_config1(self):
# Test building a interfaceable task from a config.
aux = RootTask()
aux.children_task = [IMixin()]
bis = RootTask.build_from_config(aux.task_preferences,
{'tasks': {'IMixin': IMixin,
'RootTask': RootTask}})
assert_equal(type(bis.children_task[0]).__name__, 'IMixin')
示例3: build_root
# 需要导入模块: from hqc_meas.tasks.api import RootTask [as 别名]
# 或者: from hqc_meas.tasks.api.RootTask import build_from_config [as 别名]
def build_root(manager, mode, config=None, parent_ui=None, build_dep=None):
""" Create a new RootTask.
Parameters
----------
manager : TaskManagerPlugin
Instance of the current task manager plugin.
mode : {'from config', 'from template', 'from file'}
Whether to use the given config, or look for one in templates or a
file.
config : configobj.Section
Object holding the informations necessary to build the root task.
parent_ui : optional
Optional parent widget for the dialog.
build_dep : optional
Optionnal dict containing the build dependencies.
Returns:
-------
task : RootTask
"""
if mode == 'from config':
pass
elif mode == 'from file':
path = FileDialogEx.get_open_file_name(parent=parent_ui,
name_filters=['*.ini'])
config, _ = load_template(path)
elif mode == 'from template':
view = TemplateSelectorView(parent=parent_ui, manager=manager)
result = view.exec_()
if result:
path = view.path
config, _ = load_template(path)
if config:
if build_dep is None:
core = manager.workbench.get_plugin('enaml.workbench.core')
cmd = 'hqc_meas.dependencies.collect_build_dep_from_config'
build_dep = core.invoke_command(cmd, {'config': config})
if isinstance(build_dep, Exception):
return None
config.pop('task_class')
return RootTask.build_from_config(config, build_dep)