summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-03-11 21:47:51 +0100
committerHelmut Grohne <helmut@subdivi.de>2024-03-11 21:47:51 +0100
commitf9b0cf016effb397e32c413c9b0384eb6ee3b4a9 (patch)
tree325a9d0cca8e8a56552ee03ab27c5fd849213a55
parent97be9fda277e739c92ec18ce02f760dc6cd908cc (diff)
downloadpython-linuxnamespaces-f9b0cf016effb397e32c413c9b0384eb6ee3b4a9.tar.gz
add method AtLocation.is_absolute
This is similar to pathlib.Path.is_absolute.
-rw-r--r--linuxnamespaces/atlocation.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index eecfed1..2bd3f51 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -217,6 +217,13 @@ class AtLocation:
follow_symlinks=follow_symlinks,
)
+ def is_absolute(self) -> bool:
+ """Report whether the location is absolute or not. Not that any
+ location with an a valid filedescriptor is considered absolute as it is
+ not dependent on the working directory.
+ """
+ return self.fd >= 0 or pathlib.Path(self.location).is_absolute()
+
def link(self, dst: "AtLocationLike") -> None:
"""Wrapper for os.link supplying src_dir_fd, dst_dir_fd and
follow_symlinks.