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


Python Path.isabsolute方法代码示例

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


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

示例1: SymlinkItem

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import isabsolute [as 别名]
class SymlinkItem(BaseItem):
    src = None
    destination = None

    def __init__(self, src, destination):
        self.src = Path(src)
        self.destination = Path(destination)

    def run(self, context):
        if not self.src.isabsolute():
            self.src = Path(Path(context['target_dir']), self.src)

        if self.destination.isabsolute():
            destination = Path(context['package_root'], strip_root(self.destination))
        else:
            destination = Path(context['package_project_dir'], self.destination)

        parent_dir = destination.parent
        if not parent_dir.exists():
            parent_dir.mkdir(parents=True, mode=0777)

        command = 'ln -s %(src)s %(destination)s' % {
            'src': self.src,
            'destination': destination
        }
        fabric.api.local(command, capture=True)
开发者ID:phonkee,项目名称:easyfab,代码行数:28,代码来源:items.py

示例2: CopyItem

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import isabsolute [as 别名]
class CopyItem(BaseItem):
    src = None
    destination = None
    only_content = None
    recursive = None

    def __init__(self, src, destination, only_content=False, recursive=False, follow_symlinks=True):
        self.follow_symlinks = follow_symlinks
        self.src = Path(src)
        self.destination = Path(destination)
        self.only_content = only_content
        self.recursive = recursive

    def run(self, context):
        if not self.src.isabsolute():
            self.src = Path(Path(context['project_dir']), self.src)
        if not self.destination.isabsolute():
            self.destination = Path(Path(context['package_project_dir']), self.destination)

        switches = []

        if self.recursive:
            switches.append("-R")

        if self.follow_symlinks:
            switches.append("-L")

        command = 'cp %(switches)s %(src)s %(destination)s' % {
            'switches': ' '.join(switches),
            'src': self.src,
            'destination': self.destination,
        }

        fabric.api.local(command, capture=True)
开发者ID:phonkee,项目名称:easyfab,代码行数:36,代码来源:items.py

示例3: main

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import isabsolute [as 别名]
def main():
    """
    Controller.
    """
    args = sys.argv[1:]
    if len(args) == 0:
        print_usage()
        sys.exit(0)

    args = check_args(args)

    prg = args[0]  # script in venv
    args = args[1:]  # arguments of the script in venv

    p = Path(prg).absolute()
    venv_file = find_venv_file(p.parent)

    venv_dir = Path(venv_file.read_file().strip())
    # .venv can also contain a relative path
    if not venv_dir.isabsolute():
        venv_dir = Path(venv_file.parent, venv_dir).norm()

    if not venv_dir.isdir():
        print("Error: {vd} is not a directory.".format(vd=venv_dir), file=sys.stderr)
        sys.exit(1)
    #
    python_path = Path(venv_dir, "bin/python")
    if not python_path.isfile():
        print("Error: {pp} is missing.".format(pp=python_path), file=sys.stderr)
        sys.exit(1)

    if DEBUG:
        print("# venv dir:  {d}".format(d=venv_dir), file=sys.stderr)

    my_call(python_path, prg, args)
开发者ID:killerswan,项目名称:wpython,代码行数:37,代码来源:wpython.py

示例4: normalize_element

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import isabsolute [as 别名]
 def normalize_element(self, path_val):
     path = Path(path_val)
     # /foo
     if path.isabsolute():
         return path.expand()
     # foo
     else:
         return Path(self.root, path_val)
开发者ID:Krazylee,项目名称:travel,代码行数:10,代码来源:travel.py

示例5: CreateDirItem

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import isabsolute [as 别名]
class CreateDirItem(BaseItem):
    directory_name = None
    mode = None

    def __init__(self, directory_name, mode=0777):
        self.directory_name = Path(directory_name)
        self.mode = mode

    def run(self, context):
        if not self.directory_name.isabsolute():
            directory = Path(Path(context['package_project_dir']), self.directory_name)
        else:
            directory = Path(context['package_root'], Path(strip_root(self.directory_name)))

        directory.mkdir(parents=True, mode=self.mode)
开发者ID:phonkee,项目名称:easyfab,代码行数:17,代码来源:items.py


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