コード例 #1
0
def _extract_absolute_path(input_path, context_path):
    if input_path is None:
        absolute_path = context_path
    else:
        input_path = Path(input_path)
        absolute_path = input_path if input_path.is_absolute(
        ) else _make_full_path(context_path, input_path)

    return absolute_path
コード例 #2
0
    def _do_ls_absolute_path(self, absolute_path:Path):

        if absolute_path.is_root():
            filename_list = self._do_ls_root()
        elif absolute_path.only_user():
            filename_list = self._do_ls_user_level(absolute_path)
        else:
            filename_list = self._do_ls_fullpath(absolute_path)

        return filename_list
コード例 #3
0
    def _execute(self, arg):
        repository_path = Path(arg["<repo_full_path>"])
        if not repository_path.is_absolute() or repository_path.depth() < 2:
            get_logger().error(
                "Repo path must be of the form '/<username>/<repo_name>'")
            return

        input_username = repository_path.user_name
        input_repository_name = repository_path.repository_name
        if input_username == self.context.user_name:
            self._do_rmdir_from_repository_name_with_context(
                input_repository_name)
        else:
            self._do_rmdir_from_repository_name_no_context(
                input_repository_name, input_username)
コード例 #4
0
    def __init__(self):
        self.curpath = Path("/")
        self.user_name_path = None
        self.repo_name_path = None

        self.token = None
        self.user_name = None
コード例 #5
0
def _make_full_path(context, path):
    if path.is_absolute():
        actual_path = path
    else:
        separator = "/" if not context.is_root() else ""
        actual_path = Path(str(context) + separator + str(path))

    return actual_path
コード例 #6
0
    def _do_cd_fullpath(self, absolute_path: Path):
        try:
            file_info = svn.remote.RemoteClient(
                absolute_path.to_remote_address()).info()
            if not file_info["entry_kind"] == "dir":
                raise NotADirectoryError(absolute_path)

        except Exception as e:
            raise NoSuchFileOrDirectoryError(absolute_path)

        return absolute_path
コード例 #7
0
    def _execute(self, arg):
        remote_path = Path(arg["<remote_path>"])
        local_path = OSPath(arg["<local_path>"]).absolute()

        cwd = os.getcwd()
        shutil.rmtree("/tmp/github-cli-tmp", ignore_errors=True)
        os.mkdir("/tmp/github-cli-tmp")
        os.chdir("/tmp/github-cli-tmp")

        context_path = self.context.curpath
        absolute_path = _extract_absolute_path(remote_path.full_path_str,
                                               context_path)

        remote_client = svn.remote.RemoteClient(
            absolute_path.to_remote_address())
        remote_client.checkout(absolute_path.to_remote_address())

        shutil.move(absolute_path.parts[-1], str(local_path))

        os.chdir(cwd)
コード例 #8
0
 def _do_ls_user_level(self, path:Path):
     if path.only_user():
         return self._do_ls_only_user(path)
     else:
         return self._do_ls_fullpath(path)
コード例 #9
0
 def _do_ls_fullpath(self, path:Path):
     r = svn.remote.RemoteClient(path.to_remote_address())
     for obj in r.list():
         yield obj