From c7c3e266024f62cfb276d6fe7cafb3b11c05ace7 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Thu, 2 Jul 2026 10:15:20 +0300 Subject: [PATCH] fix: RemoteOperations is refactored (no os.path, public uses private) New private methods: - _is_abs_path - _get_dirname - _get_basename Updated methods: - copytree (_is_abs_path) - write (_get_dirname) - get_tempdir (_get_dirname) - get_dirname (_get_dirname) - is_abs_path (_is_abs_path) - get_basename (_get_basename) --- src/remote_ops.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/remote_ops.py b/src/remote_ops.py index bdfc8c9..66fa2ba 100644 --- a/src/remote_ops.py +++ b/src/remote_ops.py @@ -547,7 +547,7 @@ def mkstemp(self, prefix=None): return temp_file def copytree(self, src, dst): - if not os.path.isabs(dst): + if __class__._is_abs_path(dst): dst = __class__._build_path('~', dst) if self.isdir(dst): raise FileExistsError("Directory {} already exists.".format(dst)) @@ -593,7 +593,7 @@ def write( redirect_op = ">" if truncate else ">>" # Extract the path to the parent directory - remote_directory = os.path.dirname(filename) + remote_directory = __class__._get_dirname(filename) remote_cmd = [ "mkdir", @@ -976,21 +976,21 @@ def get_tempdir(self) -> str: temp_subdir = exec_output.strip() assert type(temp_subdir) is str - temp_dir = os.path.dirname(temp_subdir) + temp_dir = __class__._get_dirname(temp_subdir) assert type(temp_dir) is str return temp_dir def get_dirname(self, path: str) -> str: assert type(path) is str - return posixpath.dirname(path) + return __class__._get_dirname(path) def is_abs_path(self, path: str) -> bool: assert type(path) is str - return posixpath.isabs(path) + return __class__._is_abs_path(path) def get_basename(self, path: str) -> str: assert type(path) is str - return posixpath.basename(path) + return __class__._get_basename(path) @staticmethod def _build_cmdline( @@ -1089,6 +1089,21 @@ def _build_path(a: str, *parts: str) -> str: assert type(parts) is tuple return posixpath.join(a, *parts) + @staticmethod + def _get_dirname(path: str) -> str: + assert type(path) is str + return posixpath.dirname(path) + + @staticmethod + def _is_abs_path(path: str) -> bool: + assert type(path) is str + return posixpath.isabs(path) + + @staticmethod + def _get_basename(path: str) -> str: + assert type(path) is str + return posixpath.basename(path) + def normalize_error(error): if isinstance(error, bytes):