本文整理汇总了Python中dpa.ptask.area.PTaskArea.config方法的典型用法代码示例。如果您正苦于以下问题:Python PTaskArea.config方法的具体用法?Python PTaskArea.config怎么用?Python PTaskArea.config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dpa.ptask.area.PTaskArea
的用法示例。
在下文中一共展示了PTaskArea.config方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_filter_rules
# 需要导入模块: from dpa.ptask.area import PTaskArea [as 别名]
# 或者: from dpa.ptask.area.PTaskArea import config [as 别名]
def _get_filter_rules(self, ptask):
ptask_area = PTaskArea(ptask.spec, validate=False)
filter_config = ptask_area.config(
FILTER_RULES_CONFIG_PATH,
composite_ancestors=True,
)
includes = []
excludes = []
if 'includes' in filter_config:
includes = filter_config.includes
if 'excludes' in filter_config:
excludes = filter_config.excludes
return (includes, excludes)
示例2: prompt
# 需要导入模块: from dpa.ptask.area import PTaskArea [as 别名]
# 或者: from dpa.ptask.area.PTaskArea import config [as 别名]
def prompt(self):
parent_spec = PTaskSpec.parent(self.spec)
template_options = []
if parent_spec:
par_ptask = PTask.get(parent_spec)
par_ptask_type = par_ptask.ptask_type
else:
par_ptask_type = 'none'
ptask_area = PTaskArea(parent_spec, validate=False)
master_config = ptask_area.config(
PROJECT_MASTER_CONFIG_PATH,
composite_ancestors=True,
)
if not master_config or not hasattr(master_config, 'hierarchy'):
raise ActionError("Unable to find project master config.")
if not self.ptask_type in master_config.hierarchy[par_ptask_type]:
raise ActionError(
"Cannot create '{t}' ptask inside '{p}' ptask".format(
t=self.ptask_type,
p=par_ptask_type,
)
)
# ---- prompt for missing fields
if not self.source and self.ptask_type in master_config.templates:
for template_spec in master_config.templates[self.ptask_type]:
trimmed_spec = re.sub(
"^templates?=",
"",
template_spec,
flags=re.IGNORECASE
)
template_options.append(
(
re.sub("[=_-]+", " ", trimmed_spec).title(),
template_spec
)
)
self._source = Output.prompt_menu(
"Select a template to source",
prompt_str="Selection",
options=template_options,
help_str="Please choose from the templates listed.",
none_option=True,
custom_prompt="Custom Source",
custom_blank=False
)
# see if the ptask already exists
if not self.ptask:
try:
self._ptask = PTask.get(self.spec)
except PTaskError:
pass
else:
if not self.force:
raise ActionAborted("PTask already exists.")
else:
if not self._description:
self._description = self.ptask.description
if not self._start_date:
self._start_date = self.ptask.start_date
if not self._due_date:
self._due_date = self.ptask.due_date
if (not self.description or
not self.start_date or
not self.due_date):
if self.force:
raise ActionError(
"Cannot force creation without required fields."
)
else:
print "\nPlease enter information about this new {b}{t}{r}:".\
format(
b=Style.bright,
t=self.ptask_type,
r=Style.reset,
)
ptask_display = " [{pt}] {b}{s}{r}".format(
pt=self.ptask_type,
b=Style.bright,
s=self.spec,
r=Style.reset,
)
if not self.description:
self._description = Output.prompt(
'{pd} description'.format(pd=ptask_display),
blank=False,
)
#.........这里部分代码省略.........