Add empty relevant css classes to css file
This commit is contained in:
33
sm2gen.py
33
sm2gen.py
@@ -562,10 +562,6 @@ if __name__ == "__main__":
|
||||
except Exception as e:
|
||||
print(f"A Chameleon template layout file error occurred: {e}")
|
||||
|
||||
# Create the css file (empty for now, except the header)
|
||||
# maybe it should have empty expamples of all the relevant classes?
|
||||
with open(css_file, "w") as file:
|
||||
file.write(f"/*\n Generated by SM2Gen version: {strVersion}\n*/\n")
|
||||
|
||||
# Generate a partial file for each of the entries in the html list
|
||||
# Pull in the template code for each of the input types
|
||||
@@ -595,32 +591,48 @@ if __name__ == "__main__":
|
||||
# Now generate the controls from the rest of the entries in the dict.
|
||||
all_controls_html = ""
|
||||
prefix_is = hl("prefix")
|
||||
acc_css_entries = ""; #One entry for each class created for html entries
|
||||
for html_control in html:
|
||||
inner_html = html[html_control]
|
||||
if isinstance(inner_html, dict):
|
||||
# input or table
|
||||
html_Type = inner_html['Type']
|
||||
type_serial = "".join(char for char in html_control if char.isdigit())
|
||||
class_name = html_Type.lower()[:4]+type_serial
|
||||
acc_css_entries += f".{class_name} {{}}\n"
|
||||
if html_Type == "Table":
|
||||
acc_css_entries += f"thead .{class_name} {{}}\n"
|
||||
acc_css_entries += f"tboay .{class_name} {{}}\n"
|
||||
try:
|
||||
control_template = PageTemplate(html_controls[inner_html["Type"]])
|
||||
try:
|
||||
control_html = control_template.render(
|
||||
version=strVersion, **inner_html, prefix=prefix_is
|
||||
version=strVersion, **inner_html, prefix=prefix_is,
|
||||
classname=class_name
|
||||
)
|
||||
all_controls_html = all_controls_html + control_html
|
||||
except Exception as e:
|
||||
print(
|
||||
f"A Chameleon render on partial file control {inner_html['Name']} error occurred: {e}"
|
||||
f"A Chameleon render on partial file control {html_control} error occurred: {e}"
|
||||
)
|
||||
except Exception as e:
|
||||
print(
|
||||
f"A Chameleon render on partial file control {inner_html['Name']} error occurred: {e}"
|
||||
f"A Chameleon render on partial file control {html_control} error occurred: {e}"
|
||||
)
|
||||
else:
|
||||
# just a simple entry - name less numerics is type
|
||||
html_Type = "".join(char for char in html_control if not char.isdigit())
|
||||
type_serial = "".join(char for char in html_control if char.isdigit())
|
||||
class_name = html_Type.lower()[:4]+type_serial
|
||||
acc_css_entries += f".{class_name} {{}}\n"
|
||||
if not type_serial == "":
|
||||
print(html_control,html_Type,type_serial)
|
||||
try:
|
||||
simple_control_template = PageTemplate(html_controls[html_Type])
|
||||
try:
|
||||
simple_control_html = simple_control_template.render(
|
||||
version=strVersion, Value=inner_html, prefix=prefix_is
|
||||
version=strVersion, Value=inner_html, prefix=prefix_is,
|
||||
type_serial=type_serial
|
||||
)
|
||||
all_controls_html = all_controls_html + simple_control_html
|
||||
except Exception as e:
|
||||
@@ -650,6 +662,11 @@ if __name__ == "__main__":
|
||||
print(f"Content modified and saved to {partial_files[i]}")
|
||||
i += 1
|
||||
|
||||
# Create the css file (the header, followed by a dumy entry for each class created/used above)
|
||||
with open(css_file, "w") as file:
|
||||
file.write(f"/*\n Generated by SM2Gen version: {strVersion}\n*/\n")
|
||||
file.write(acc_css_entries);
|
||||
|
||||
# Now generate the <name>.en file
|
||||
# Look through the generated files for the /l[\s|(]['|"](.*)['|"]\)/ strings.
|
||||
|
||||
|
Reference in New Issue
Block a user