loop: add autoclear propert to LoopInfo

Small convenience property to check if the autoclear flag is set
in the `lo_flags` member of the `LoopInfo`.
Also add a corresponding test for it.
This commit is contained in:
Christian Kellner 2021-08-08 09:11:40 +00:00 committed by Tom Gundersen
parent 62082733e9
commit 61d5f15420
2 changed files with 13 additions and 1 deletions

View file

@ -38,6 +38,11 @@ class LoopInfo(ctypes.Structure):
('lo_init', ctypes.c_uint64 * 2)
]
@property
def autoclear(self) -> bool:
"""Return if `LO_FLAGS_AUTOCLEAR` is set in `lo_flags`"""
return bool(self.lo_flags & Loop.LO_FLAGS_AUTOCLEAR)
class Loop:
"""Loopback device