How to use the temci.package.util.abspath function in temci

To help you get started, we’ve selected a few temci examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parttimenerd / temci / temci / package / action.py View on Github external
def actions_for_dir_path(path: str, path_acc: t.Set[str] = set()) -> t.List[Action]:
    """
    Returns a list of actions that is needed to create a folder and its parent folders.

    :param path:
    :param path_acc: paths already examined
    """
    path = abspath(path)
    typecheck_locals(path=FileName(allow_non_existent=False)|DirName(), create=Bool())
    assert os.path.exists(path)
    if path == "" or path == "~":
        return []
    path = normalize_path(path)
    parts = path.split("/")
    ret = []
    for i in range(2 if parts[0] == "~" else 1, len(parts) + 1 if os.path.isdir(abspath(path)) else len(parts)):
        subpath = "/".join(parts[:i])
        subpath_norm = normalize_path(subpath)
        if subpath_norm in path_acc:
            continue
        ret.append(CreateDir(subpath_norm))
        path_acc.add(subpath_norm)
    return ret
github parttimenerd / temci / temci / package / action.py View on Github external
def actions_for_dir_path(path: str, path_acc: t.Set[str] = set()) -> t.List[Action]:
    """
    Returns a list of actions that is needed to create a folder and its parent folders.

    :param path:
    :param path_acc: paths already examined
    """
    path = abspath(path)
    typecheck_locals(path=FileName(allow_non_existent=False)|DirName(), create=Bool())
    assert os.path.exists(path)
    if path == "" or path == "~":
        return []
    path = normalize_path(path)
    parts = path.split("/")
    ret = []
    for i in range(2 if parts[0] == "~" else 1, len(parts) + 1 if os.path.isdir(abspath(path)) else len(parts)):
        subpath = "/".join(parts[:i])
        subpath_norm = normalize_path(subpath)
        if subpath_norm in path_acc:
            continue
        ret.append(CreateDir(subpath_norm))
        path_acc.add(subpath_norm)
    return ret
github parttimenerd / temci / temci / package / action.py View on Github external
def _execute(self, db: Database):
         if os.path.exists(self.file):
            os.remove(abspath(self.file))
github parttimenerd / temci / temci / package / action.py View on Github external
def _dry_run_message(self) -> str:
        if not os.path.exists(abspath(self.directory)):
            return "Would create directory {!r}".format(self.directory)
        return "Wouldn't create directory {!r} as it already exists".format(self.directory)
github parttimenerd / temci / temci / package / action.py View on Github external
def reverse(self) -> t.List[Action]:
        if os.path.exists(abspath(self.dest)):
            return [CopyFile(self.dest)]
        return [RemoveFile(self.dest)]
github parttimenerd / temci / temci / package / action.py View on Github external
def reverse(self) -> t.List['RemoveDir']:
        if os.path.exists(abspath(self.directory)):
            return []
        return [RemoveDir(self.directory)]
github parttimenerd / temci / temci / package / action.py View on Github external
def _execute(self, db: Database):
        shutil.rmtree(abspath(self.directory))
github parttimenerd / temci / temci / package / action.py View on Github external
def _execute(self, db: Database):
        if not os.path.exists(abspath(self.directory)):
            os.mkdir(abspath(self.directory))
github parttimenerd / temci / temci / package / action.py View on Github external
def _execute(self, db: Database):
        if not os.path.exists(abspath(self.directory)):
            os.mkdir(abspath(self.directory))