@@ -72,31 +72,28 @@ def generate_entity_subclass_files(
72
72
dest_filename = str (template_filename ).replace ("class_name" , entity .snake_name )
73
73
print (f"writing { dest_filename } " , end = "" )
74
74
75
+ entity_template = template
75
76
if f"{ dest_filename } .j2" in environment .list_templates ():
76
- override_template = environment .get_template (f"{ dest_filename } .j2" )
77
- content = override_template .render (
78
- cls = entity ,
79
- view = view ,
80
- )
81
- else :
82
- content = template .render (
83
- cls = entity ,
84
- view = view ,
85
- )
77
+ entity_template = environment .get_template (f"{ dest_filename } .j2" )
78
+ content = entity_template .render (
79
+ cls = entity ,
80
+ view = view ,
81
+ )
86
82
with open (os .path .join (output_prefix , dest_filename ), mode = "w" , encoding = "utf-8" ) as outfile :
87
- outfile .write (prepend_warning (dest_filename , template , content ))
83
+ outfile .write (prepend_warning (dest_filename , entity_template , content ))
88
84
print ("... done" )
89
85
90
86
91
87
def prepend_warning (dest_filename : str , template : Template , content : str ) -> str :
88
+ formatted_filename = template .filename
89
+ if "platformics/codegen" in formatted_filename :
90
+ formatted_filename = formatted_filename [formatted_filename .find ("platformics/codegen" ) :]
92
91
if dest_filename .endswith (".yaml" ):
93
- formatted_filename = template .filename [template .filename .find ("platformics/codegen" ) :]
94
92
content = (
95
93
"# Auto-generated by running `make codegen`. Do not edit!\n "
96
94
f"# Make changes to the template { formatted_filename } instead.\n "
97
95
) + str (content )
98
96
if dest_filename .endswith (".py" ):
99
- formatted_filename = template .filename [template .filename .find ("platformics/codegen" ) :]
100
97
lines = content .splitlines ()
101
98
opens_with_comment = False
102
99
if lines [0 ] == '"""' :
0 commit comments