diff options
author | Helmut Grohne <helmut@subdivi.de> | 2024-03-03 20:35:12 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2024-03-03 20:35:12 +0100 |
commit | 64a660360e1cc20c5c5c14fcb4cdaa9b12c562f6 (patch) | |
tree | d6d8e717550a5536479c9046f50fc230a23ba429 | |
parent | fb1ab1fabb0f9f7f470620cb30700c795a7bbd1c (diff) | |
download | python-linuxnamespaces-64a660360e1cc20c5c5c14fcb4cdaa9b12c562f6.tar.gz |
implement repr for AtLocation
-rw-r--r-- | linuxnamespaces/atlocation.py | 15 |
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] |