summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-03-03 20:35:12 +0100
committerHelmut Grohne <helmut@subdivi.de>2024-03-03 20:35:12 +0100
commit64a660360e1cc20c5c5c14fcb4cdaa9b12c562f6 (patch)
treed6d8e717550a5536479c9046f50fc230a23ba429
parentfb1ab1fabb0f9f7f470620cb30700c795a7bbd1c (diff)
downloadpython-linuxnamespaces-64a660360e1cc20c5c5c14fcb4cdaa9b12c562f6.tar.gz
implement repr for AtLocation
-rw-r--r--linuxnamespaces/atlocation.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index 45d2d59..6f0b8d9 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -352,5 +352,20 @@ class AtLocation:
)
return os.fspath(self.location)
+ def __repr__(self) -> str:
+ """Return a textual representation of the AtLocation object."""
+ cn = self.__class__.__name__
+ if self.fd < 0:
+ if self.flags == AtFlags.NONE:
+ return f"{cn}({self.location!r})"
+ return f"{cn}({self.location!r}, flags={self.flags!r})"
+ if self.location:
+ if self.flags == AtFlags.NONE:
+ return f"{cn}({self.fd}, {self.location!r})"
+ return f"{cn}({self.fd}, {self.location!r}, {self.flags!r})"
+ if self.flags & ~AtFlags.AT_EMPTY_PATH == AtFlags.NONE:
+ return f"{cn}({self.fd})"
+ return f"{cn}({self.fd}, flags={self.flags!r})"
+
AtLocationLike = typing.Union[AtLocation, int, PathConvertible]