summaryrefslogtreecommitdiff
path: root/linuxnamespaces
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-10-26 20:22:36 +0200
committerHelmut Grohne <helmut@subdivi.de>2024-10-26 20:22:36 +0200
commit64b2dab795e171e2ea0345732e96048cfb605466 (patch)
tree820dfeb1137afe09a445ad84867789c2015d7543 /linuxnamespaces
parentf46f905dedd975a6d8c1e580adaa6ce79e2d55a1 (diff)
downloadpython-linuxnamespaces-64b2dab795e171e2ea0345732e96048cfb605466.tar.gz
add a method IDMapping.identity for convenience
Diffstat (limited to 'linuxnamespaces')
-rw-r--r--linuxnamespaces/__init__.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py
index 8c1def3..a2c7985 100644
--- a/linuxnamespaces/__init__.py
+++ b/linuxnamespaces/__init__.py
@@ -59,6 +59,11 @@ class IDMapping:
if self.innerstart + self.count >= 1 << 64:
raise ValueError("innerstart + count exceed 64bits")
+ @classmethod
+ def identity(cls, idn: int, count: int = 1) -> typing.Self:
+ """Construct an identity mapping for the given identifier."""
+ return cls(idn, idn, count)
+
class IDAllocation:
"""This represents a subset of IDs (user or group). It can be used to