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


Python PTaskArea.set方法代码示例

本文整理汇总了Python中dpa.ptask.area.PTaskArea.set方法的典型用法代码示例。如果您正苦于以下问题:Python PTaskArea.set方法的具体用法?Python PTaskArea.set怎么用?Python PTaskArea.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dpa.ptask.area.PTaskArea的用法示例。


在下文中一共展示了PTaskArea.set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _print_ptask_env

# 需要导入模块: from dpa.ptask.area import PTaskArea [as 别名]
# 或者: from dpa.ptask.area.PTaskArea import set [as 别名]
    def _print_ptask_env(self):

        # remove any whitespace on the head/tail of the spec
        spec = self.spec.strip()
        ptask_area = None

        if self.version:
            spec = PTaskSpec.VERSION.join([spec, str(self.version)])
            

        replace_match = re.match("\.?/([=\w]+)/([=\w]+)/", spec)

        # handle 'none' as a valid spec - unset current ptask (set it to root)
        if spec.lower() == 'none':
            spec = ""
            full_spec = PTaskSpec.get(spec)
            try:
                ptask_area = PTaskArea(full_spec)
            except:
                pass

        # special character '-' indicates use the last set ptask spec
        elif spec == "-":
            ptask_area = PTaskArea.previous()

        # set to a similar ptask with text replacement
        elif replace_match:

            cur_area_spec = PTaskArea.current().spec
            repl_spec = cur_area_spec.replace(
                replace_match.group(1), replace_match.group(2))
            try:
                ptask_area = PTaskArea(repl_spec)
            except:
                pass
            
        # use the supplied spec relative to the current ptask
        else:

            relative_to = PTaskArea.current().spec

            while ptask_area is None:

                try:
                    full_spec = PTaskSpec.get(spec, relative_to=relative_to)
                except PTaskSpecError as e:
                    raise ActionError(str(e))

                try:
                    # if this is successful, we'll break out of the while
                    ptask_area = PTaskArea(full_spec)
                except PTaskAreaError as e: 
                    # no match, check the parent relative spec
                    relative_to = PTaskSpec.parent(relative_to)
                    # there is no parent, break out of the while
                    if relative_to is None:
                        break

        # dump out commands used for setting the environment for the supplied
        # spec.

        if not ptask_area:
            raise ActionError(
                "Could not determine ptask area from: " + str(spec), 
            )

        ptask = None

        # delay the db query to this point to prevent multiple, unnecessary db
        # queries. if we're at this point, we know there's at least a
        # corresponding directory on disk. 
        if ptask_area.base_spec:
            try:
                ptask = PTask.get(ptask_area.base_spec)
            except PTaskError as e:
                pass

        if not ptask and ptask_area.spec != "":
            raise ActionError("Could not determine ptask from: " + str(spec))
        
        ptask_area.set(shell=self.shell, ptask=ptask)
开发者ID:chippey,项目名称:dpa-pipe,代码行数:83,代码来源:env.py


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