Skip to content

Commit

Permalink
Move header into template
Browse files Browse the repository at this point in the history
  • Loading branch information
ruscoder committed Sep 6, 2024
1 parent 10a3ae8 commit 97d115d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fhir_py_types/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

dir_path = os.path.dirname(os.path.realpath(__file__))


def main() -> None:
argparser = argparse.ArgumentParser(
Expand Down Expand Up @@ -39,14 +41,13 @@ def main() -> None:
)
)

with open(os.path.join(dir_path, "header.py.tpl")) as header_file:
header_lines = header_file.readlines()

with open(os.path.abspath(args.outfile), "w") as resource_file:
resource_file.writelines(
[
"from typing import List as List_, Optional as Optional_, Literal as Literal_, Annotated as Annotated_\n",
"from {} import {} as BaseModel\n".format(
*args.base_model.rsplit(".", 1)
),
"from pydantic import Field, Extra\n",
*header_lines,
"\n\n",
"\n\n\n".join(
ast.unparse(ast.fix_missing_locations(tree)) for tree in ast_
Expand Down
3 changes: 3 additions & 0 deletions fhir_py_types/header.py.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import List as List_, Optional as Optional_, Literal as Literal_, Annotated as Annotated_
from pydantic import BaseModel, Field, Extra

0 comments on commit 97d115d

Please sign in to comment.