Sort out selection options

This commit is contained in:
2024-10-19 18:58:55 +01:00
parent 964771d876
commit 0f5c4f948c
14 changed files with 681 additions and 37 deletions

View File

@@ -28,6 +28,24 @@ json5_html_list: list = []
ini_file_path = os.path.expanduser("~/.smegit/conf")
OPENAI_API_KEY = ""
def example_function(**kwargs):
print(kwargs)
def python_to_perl_structure(data):
#print(data)
if data:
if isinstance(data, list):
# Convert each dictionary in the list to Perl format: ['text' => 'value']
elements = [
f"['{item['Text']}' => '{item['Value']}']"
for item in data
]
return '[' + ', '.join(elements) + ']'
else:
raise TypeError("Expected a list of dictionaries")
return ""
def assemble_version_string():
try:
chameleon_version = pkg_resources.get_distribution("Chameleon").version
@@ -600,6 +618,10 @@ if __name__ == "__main__":
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"
OptionsInPerl = python_to_perl_structure(inner_html.get("Options", ""))
#if html_Type == "Select":
# example_function(**inner_html)
# quit(1)
if html_Type == "Table":
acc_css_entries += f"thead .{class_name} {{}}\n"
acc_css_entries += f"tbody .{class_name} {{}}\n"
@@ -609,7 +631,8 @@ if __name__ == "__main__":
control_html = control_template.render(
version=strVersion, **inner_html, prefix=prefix_is,
classname=class_name,
type_serial=type_serial
type_serial=type_serial,
OptionsInPerl=OptionsInPerl
)
all_controls_html = all_controls_html + control_html
except Exception as e: