Bläddra i källkod

mypy: fix platform package

clean up imports, remove unused stuff
Thomas Waldmann 2 år sedan
förälder
incheckning
f71f26ddfd
2 ändrade filer med 40 tillägg och 32 borttagningar
  1. 40 20
      src/borg/platform/__init__.py
  2. 0 12
      src/borg/platform/base.py

+ 40 - 20
src/borg/platform/__init__.py

@@ -6,26 +6,9 @@ Public APIs are documented in platform.base.
 
 from ..platformflags import is_win32, is_linux, is_freebsd, is_darwin
 
-from .base import listxattr, getxattr, setxattr, ENOATTR
-from .base import acl_get, acl_set
-from .base import set_flags, get_flags
-from .base import SaveFile, SyncFile, sync_dir, fdatasync, safe_fadvise
-from .base import swidth, API_VERSION
-from .base import process_alive, get_process_id, local_pid_alive, fqdn, hostname, hostid
-
-OS_API_VERSION = API_VERSION
-
-if not is_win32:
-    from .posix import process_alive, local_pid_alive
-
-    # posix swidth implementation works for: linux, freebsd, darwin, openindiana, cygwin
-    from .posix import swidth
-    from .posix import get_errno
-    from .posix import uid2user, user2uid, gid2group, group2gid, getosusername
-
-else:
-    from .windows import process_alive, local_pid_alive
-    from .windows import uid2user, user2uid, gid2group, group2gid, getosusername
+from .base import ENOATTR, API_VERSION
+from .base import SaveFile, sync_dir, fdatasync, safe_fadvise
+from .base import get_process_id, fqdn, hostname, hostid
 
 if is_linux:  # pragma: linux only
     from .linux import API_VERSION as OS_API_VERSION
@@ -33,11 +16,48 @@ if is_linux:  # pragma: linux only
     from .linux import acl_get, acl_set
     from .linux import set_flags, get_flags
     from .linux import SyncFile
+    from .posix import process_alive, local_pid_alive
+    from .posix import swidth
+    from .posix import get_errno
+    from .posix import uid2user, user2uid, gid2group, group2gid, getosusername
 elif is_freebsd:  # pragma: freebsd only
     from .freebsd import API_VERSION as OS_API_VERSION
     from .freebsd import listxattr, getxattr, setxattr
     from .freebsd import acl_get, acl_set
+    from .base import set_flags, get_flags
+    from .base import SyncFile
+    from .posix import process_alive, local_pid_alive
+    from .posix import swidth
+    from .posix import get_errno
+    from .posix import uid2user, user2uid, gid2group, group2gid, getosusername
 elif is_darwin:  # pragma: darwin only
     from .darwin import API_VERSION as OS_API_VERSION
     from .darwin import listxattr, getxattr, setxattr
     from .darwin import acl_get, acl_set
+    from .base import set_flags, get_flags
+    from .base import SyncFile
+    from .posix import process_alive, local_pid_alive
+    from .posix import swidth
+    from .posix import get_errno
+    from .posix import uid2user, user2uid, gid2group, group2gid, getosusername
+elif not is_win32:  # pragma: posix only
+    # generic stuff for all other posix OSes
+    OS_API_VERSION = API_VERSION
+    from .base import listxattr, getxattr, setxattr
+    from .base import acl_get, acl_set
+    from .base import set_flags, get_flags
+    from .base import SyncFile
+    from .posix import process_alive, local_pid_alive
+    from .posix import swidth
+    from .posix import get_errno
+    from .posix import uid2user, user2uid, gid2group, group2gid, getosusername
+else:  # pragma: win32 only
+    # win32 specific stuff
+    OS_API_VERSION = API_VERSION
+    from .base import listxattr, getxattr, setxattr
+    from .base import acl_get, acl_set
+    from .base import set_flags, get_flags
+    from .base import SyncFile
+    from .windows import process_alive, local_pid_alive
+    from .base import swidth
+    from .windows import uid2user, user2uid, gid2group, group2gid, getosusername

+ 0 - 12
src/borg/platform/base.py

@@ -323,15 +323,3 @@ def get_process_id():
     thread_id = 0
     pid = os.getpid()
     return hostid, pid, thread_id
-
-
-def process_alive(host, pid, thread):
-    """
-    Check if the (host, pid, thread_id) combination corresponds to a potentially alive process.
-    """
-    raise NotImplementedError
-
-
-def local_pid_alive(pid):
-    """Return whether *pid* is alive."""
-    raise NotImplementedError