当前位置: 首页>>代码示例>>Python>>正文


Python PTaskArea.config方法代码示例

本文整理汇总了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)
开发者ID:DarkRoseAM,项目名称:dpa-pipe,代码行数:20,代码来源:sync.py

示例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,
            )

#.........这里部分代码省略.........
开发者ID:chippey,项目名称:dpa-pipe,代码行数:103,代码来源:create.py


注:本文中的dpa.ptask.area.PTaskArea.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。