diff options
author | Helmut Grohne <helmut@subdivi.de> | 2025-06-03 07:37:14 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2025-06-03 07:37:14 +0200 |
commit | cd000bef2c476342d74fc2a042dacfb3c2945b21 (patch) | |
tree | 4f79c4ad79c24232546c3f3dd8833bd6c9c2d6fe /linuxnamespaces | |
parent | 561ba14cddd2cd0b162016bb0136c6c5eae600cb (diff) | |
download | python-linuxnamespaces-cd000bef2c476342d74fc2a042dacfb3c2945b21.tar.gz |
add method MountFlags.tonames
It provides part of the functionality of MountFlags.tostr.
Diffstat (limited to 'linuxnamespaces')
-rw-r--r-- | linuxnamespaces/syscalls.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/linuxnamespaces/syscalls.py b/linuxnamespaces/syscalls.py index c4edad2..7f17c9f 100644 --- a/linuxnamespaces/syscalls.py +++ b/linuxnamespaces/syscalls.py @@ -256,22 +256,25 @@ class MountFlags(enum.IntFlag): reverse=True, ) - def tostr(self) -> str: - """Attempt to represent the flags in a comma-separated, textual way.""" + def tonames(self) -> list[str]: + """Represent the flags as a sequence of list of flag names.""" if (self & MountFlags.PROPAGATION_FLAGS).bit_count() > 1: raise ValueError("cannot represent conflicting propagation flags") parts: list[str] = [] remain = self for val, text in MountFlags.__flagvals: - # Older mypy think MountFlags.__flagvals and thus text was of type - # MountFlags. + # Older mypy wrongly deduces the type of MountFlags.__flagvals. assert isinstance(text, str) if remain & val == val: parts.insert(0, text) remain &= ~val if remain: raise ValueError("cannot represent flags {remain}") - return ",".join(parts) + return parts + + def tostr(self) -> str: + """Represent the flags in a comma-separated, textual way.""" + return ",".join(self.tonames()) class MountSetattrFlags(enum.IntFlag): |