Exemple #1
0
    def __init__(self, ast: lark.tree.Tree) -> None:
        self.number = int(ast.children[0].value)

        format = next(ast.find_data("partition_format"), None)
        if format is not None:
            self.format = format.children[0].value.lower()
            if self.format not in self.__supported_formats():
                raise RuntimeError(
                    f"Unsupported partition format '{self.format}'")
        else:
            self.format = None

        mount = next(ast.find_data("partition_mount"), None)
        if mount is not None:
            self.mount = mount.children[0].value
        else:
            self.mount = None

        size = next(ast.find_data("partition_size"), None)
        if size is not None:
            self.units = size.children[1].value.upper()
            self.size = int(size.children[0].value)
        else:
            self.units = None
            self.size = None

        flags = next(ast.find_data("partition_flags"), None)
        if flags is not None:
            self.flags = [child.value.lower() for child in flags.children]
        else:
            self.flags = None
Exemple #2
0
 def __init__(self, ast: lark.tree.Tree) -> None:
     self.source = [
         node.children[0].value for node in ast.find_data("add_source")
     ]
     self.destination = next(
         ast.find_data("add_destination")).children[0].value