Update custom generation for select, checkbox, textare, and expand Xml templates for other input types

This commit is contained in:
2024-11-05 18:31:24 +00:00
parent 7d7e4f1c5c
commit 6870aff511
7 changed files with 87 additions and 46 deletions

View File

@@ -31,7 +31,6 @@ def example_function(**kwargs):
print(kwargs)
def spell_check_and_correct(text):
try:
# Initialize the spell checker
spell = SpellChecker()
@@ -441,34 +440,35 @@ def capitalize_words_if_all_caps(s):
return s
def extract_input_fields(json_data, value_type):
result = {}
result = {}
# Pattern to identify and strip the specified value type and surrounding brackets
pattern = re.compile(rf"{value_type}\((.*?)\)")
# Pattern to identify and strip the specified value type and surrounding brackets
pattern = re.compile(rf"{value_type}\((.*?)\)")
# Iterate over each panel in the 'html' array
for panel in json_data['html']:
panel_name = panel['route']
# Initialize an empty list for each panel
result[panel_name] = []
# Iterate over each panel in the 'html' array
for panel in json_data['html']:
panel_name = panel['route']
# Initialize an empty list for each panel
result[panel_name] = []
# Iterate over each item in the panel
for key, value in panel.items():
if key.startswith('Input') and isinstance(value, dict):
if value.get('Type').lower() in ['readonlytext', 'text']:
input_value = value.get('Value', '')
# Match and extract the value without the value_type and parentheses
match = pattern.search(input_value)
if match:
# Extract the inner content of the matching pattern
clean_value = match.group(1)
# Take out any double quotes
clean_value = clean_value.replace('"','')
# Add the clean value to the list for the current panel
result[panel_name].append(clean_value)
# Note: Empty lists are not removed, so all panels will be present in the result
return result
# Iterate over each item in the panel
for key, value in panel.items():
if key.startswith('Input') and isinstance(value, dict):
if value.get('Type').lower() in ['readonlytext', 'text', 'select','checkbox','textarea']:
# input_value = value.get('Value', '')
input_name = value.get('Name', '')
print(input_name)
# # Match and extract the value without the value_type and parentheses
# match = pattern.search(input_value)
# if match:
# # Extract the inner content of the matching pattern
# clean_value = match.group(1)
# # Take out any double quotes
# clean_value = clean_value.replace('"','')
# # Add the clean value to the list for the current panel
# result[panel_name].append(clean_value)
result[panel_name].append(input_name)
# Note: Empty lists are not removed, so all panels will be present in the result
return result
if __name__ == "__main__":