Coverage for linuxpy/codegen/magic.py: 0%
16 statements
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
1#
2# This file is part of the linuxpy project
3#
4# Copyright (c) 2023 Tiago Coutinho
5# Distributed under the GPLv3 license. See LICENSE for more info.
7import pathlib
9from .base import CEnum, run
11HEADERS = [
12 "/usr/include/linux/magic.h",
13]
16TEMPLATE = """\
17#
18# This file is part of the linuxpy project
19#
20# Copyright (c) 2023 Tiago Coutinho
21# Distributed under the GPLv3 license. See LICENSE for more info.
23# This file has been generated by {name}
24# Date: {date}
25# System: {system}
26# Release: {release}
27# Version: {version}
29import enum
32{enums_body}"""
35this_dir = pathlib.Path(__file__).parent
38class MagicEnum(CEnum):
39 def __init__(self):
40 super().__init__("Magic", "", filter=lambda name, _: "MAGIC_STRING" not in name)
42 def add_item(self, name, value):
43 name = name.replace("_MAGIC", "")
44 return super().add_item(name, value)
47# macros from #define statements
48MACRO_ENUMS = [MagicEnum()]
51def main(output=this_dir.parent / "magic.py"):
52 run(__name__, HEADERS, TEMPLATE, MACRO_ENUMS, output=output)
55if __name__ == "__main__":
56 main()