All panels and lex files updating now

This commit is contained in:
Brian Read 2025-07-08 09:49:14 +01:00
parent 2eb8c32e30
commit a54c9f1c12

View File

@ -69,6 +69,26 @@ def extract_title_prefix(controller_path):
sys.exit(1)
return prefix
def find_matching_files_variable_part(input_string, directory):
# Extract the first alphanumeric part from the input string
match = re.match(r"([A-Za-z0-9]+)", input_string)
if not match:
return []
variable_part = match.group(1)
# Try matching the full variable_part, then progressively remove last characters
for length in range(len(variable_part), 1, -1):
sub_part = variable_part[:length]
matching_files = []
for fname in os.listdir(directory):
name, ext = os.path.splitext(fname)
if name.startswith(sub_part): # match with extra characters allowed
matching_files.append(os.path.join(directory, fname))
if matching_files:
return matching_files
return []
def scan_application_files(system, panel, prefix, scan_general=False):
extracted_strings = {}
@ -84,11 +104,19 @@ def scan_application_files(system, panel, prefix, scan_general=False):
logger.info(f"Scanning Custom controller file: {controller_custom_path}")
scan_file_for_lexical_strings(controller_custom_path, prefix, extracted_strings, scan_general)
# Template files
themes = ["default", "AdminLTE"]
for theme in themes:
template_base_path = os.path.join(full_base_path, "themes", theme, "templates")
if panel in ['Backup','Yum','Bugreport']:
#find the extra layout type files that these use (they do not have partials)
template_files = find_matching_files_variable_part(panel.lower(),template_base_path)
# print(f"Matching template files: {panel.lower()!r} -> Matches: {[os.path.basename(m) for m in template_files]}")
for file_path in template_files:
panel_template_path = os.path.join(template_base_path, f"{file_path}")
logger.warning(f"Scanning panel template file: {panel_template_path}")
scan_file_for_lexical_strings(panel_template_path, prefix, extracted_strings, scan_general)
else:
panel_template_path = os.path.join(template_base_path, f"{panel.lower()}.html.ep")
logger.info(f"Scanning panel template file: {panel_template_path}")
scan_file_for_lexical_strings(panel_template_path, prefix, extracted_strings, scan_general)