1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-26 05:32:45 +00:00

Add more types as suggested.

This commit is contained in:
Felix Fontein 2025-11-27 22:38:20 +01:00
parent dc43e5992f
commit c3bd136c6b
2 changed files with 37 additions and 18 deletions

View file

@ -50,11 +50,11 @@ class BtrfsCommands:
current["devices"].append(self.__parse_filesystem_device(line))
return filesystems
def __parse_filesystem(self, line):
def __parse_filesystem(self, line) -> dict[str, t.Any]:
label = re.sub(r"\s*uuid:.*$", "", re.sub(r"^Label:\s*", "", line))
id = re.sub(r"^.*uuid:\s*", "", line)
filesystem = {}
filesystem: dict[str, t.Any] = {}
filesystem["label"] = label.strip("'") if label != "none" else None
filesystem["uuid"] = id
filesystem["devices"] = []
@ -63,10 +63,10 @@ class BtrfsCommands:
filesystem["default_subvolid"] = None
return filesystem
def __parse_filesystem_device(self, line):
def __parse_filesystem_device(self, line: str) -> str:
return re.sub(r"^.*path\s", "", line)
def subvolumes_list(self, filesystem_path):
def subvolumes_list(self, filesystem_path: str) -> list[dict[str, t.Any]]:
command = f"{self.__btrfs} subvolume list -tap {filesystem_path}"
result = self.__module.run_command(command, check_rc=True)
stdout = [x.split("\t") for x in result[1].splitlines()]