File: compile.py

package info (click to toggle)
python-fingerprints 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 920 kB
  • sloc: python: 1,290; makefile: 17
file content (20 lines) | stat: -rw-r--r-- 599 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import yaml

from fingerprints.types.common import TypesList, TYPES_PATH

CODE_DIR = os.path.dirname(__file__)


def write_python() -> None:
    with open(TYPES_PATH, "r", encoding="utf-8") as fh:
        data: TypesList = yaml.safe_load(fh)
    python_file = os.path.join(CODE_DIR, "data.py")
    with open(python_file, "w", encoding="utf-8") as pyfh:
        pyfh.write("# generated file, do not edit.\n")
        pyfh.write("from fingerprints.types.common import TypesList\n\n")
        pyfh.write("TYPES: TypesList = %s\n" % repr(data))


if __name__ == "__main__":
    write_python()