Compare commits

..

No commits in common. "7af3086d730c2c5f0a305fc7be51c59d891a812a" and "d20ec477cd6f756e4a08eb687570454c2332e12d" have entirely different histories.

9 changed files with 117 additions and 339 deletions

View File

@ -1,59 +0,0 @@
#
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
#$cdb=$main::cdb;
#$adb=$main::adb;
#$ndb=$main::ndb;
#$hdb=$main::hdb;
#$ddb=$main::ddb;
use esmith::util;
use esmith::HostsDB;
use esmith::AccountsDB;
use esmith::NetworksDB;
use esmith::HostsDB;
use esmith::DomainsDB;
#The most common ones
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# Validation routines - parameters for each panel
sub validate_PARAMS {
$ret = 'ok';
return $ret;
}
sub validate_TABLE {
$ret = 'ok';
return $ret;
}
# Get control data for tables(s)
sub get_ibays {
my @res;
my @ibays = $adb->ibays();
foreach my $i (@ibays){
my %hash = ('Name'=> $i->prop('Name'),
'Description' => $i->prop('Description'),
'Flag' => 1,
'PARAMS' => 'Modify'
);
push(@res,\%hash);
}
return \@res
}
1;

View File

@ -13,38 +13,6 @@ package SrvMngr::Controller::Nfsshare;
# Documentation: https://wiki.contribs.org/{PackageName} # Documentation: https://wiki.contribs.org/{PackageName}
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#
# Scheme of things:
#
#main:
##
## Initial entry
##
#set initial panel
#for initial panel:
# load up _data hash with DB fields
# load up stash with pointer(s) to control fields hash(= get-))
#render initial panel
#
#do_display
##
## Return after submit pushed on panel
##
#load up all params into local hash
# by panel:
# by param:
# validate param (return ret = ok or error message) - call validate-
# break out on error
#if validation not ok
# render back to current panel with error message in stash
#otherwise
# By panel:
# Copy back to DB any that have changed (how to easily tell if it has changed?)
# do whatever is required (inc signal_event smeserver-<whatever>-update?)
# set success
# call main?
use strict; use strict;
use warnings; use warnings;
use Mojo::Base 'Mojolicious::Controller'; use Mojo::Base 'Mojolicious::Controller';
@ -73,8 +41,6 @@ our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
require '/usr/share/smanager/lib/SrvMngr/Controller/Nfsshare-Custom.pm'; #The code that is to be added by the developer
sub main { sub main {
my $c = shift; my $c = shift;
@ -84,15 +50,11 @@ sub main {
my $title = $c->l("nfs_NFS data share"); my $title = $c->l("nfs_NFS data share");
my $modul = ''; my $modul = '';
$nfs_data{'trt'} = 'TABLE'; $nfs_data{trt} = 'TABLE';
#Load any DB entries into the <prefix>_data area so as they are preset in the form #Load any DB entries into the <prefix>_data area so as they are preset in the form
# which DB # which DB
my $db = $cdb; #pickup local or global db or Default to config my $db = $cdb; #Default to config
# and table control fields
$c->stash(ibays=>get_ibays());
$c->stash( $c->stash(
@ -118,10 +80,8 @@ sub do_update {
#Params are available in the hash "params" #Params are available in the hash "params"
# you may use: # you may use:
my @result;
foreach my $key (keys %params) { foreach my $key (keys %params) {
my $value = $params{$key}; my $value = $params{$key};
push @result, { $key => $value };
$c->app->log->debug("$key: $value"); $c->app->log->debug("$key: $value");
} }
@ -129,36 +89,48 @@ sub do_update {
my $trt = $c->param('trt') || 'TABLE' ; #hidden control on every form. my $trt = $c->param('trt') || 'TABLE' ; #hidden control on every form.
my $ret = 'ok'; my $ret = 'ok';
#Validate the parameters accordingly #Validate the parameters accordingly
my $thispanel;
if ($trt eq 'PARAMS'){ if ($trt eq 'PARAMS'){
#Validate form parameters for panel PARAMS #Validate form parameters for panel PARAMS
$ret = validate_PARAMS(); # and set $ret = $c->l('Error message') if invalid'
$thispanel = 'PARAMS'; # otherwise set $ret to "ok"
if ($ret ne "ok"){
$c->stash(error => $c->l($ret))
} else {
#Do whatever is needed, including writing values to the DB
my $db = $cdb; #Default to config
} $c->stash( success => $c->l('ok message'))
} }
if ($trt eq 'TABLE'){ if ($trt eq 'TABLE'){
#Validate form parameters for panel TABLE #Validate form parameters for panel TABLE
$ret = validate_TABLE(); # and set $ret = $c->l('Error message') if invalid'
$thispanel = 'TABLE'; # otherwise set $ret to "ok"
if ($ret ne "ok"){
$c->stash(error => $c->l($ret))
} else {
#Do whatever is needed, including writing values to the DB
my $db = $cdb; #Default to config
} $c->stash( success => $c->l('ok message'))
} }
if ($ret eq "ok") { # set nfs_data{trt} = <route>;
#Do whatever is needed, including writing values to the DB
my $db = $cdb; #pickup local or global db or Default to config
# anything else here...
$c->stash( success => $c->l("$thispanel successfull message"));
$c->stash( $c->stash(
title => $title, title => $title,
nfs_data => \%nfs_data nfs_data => \%nfs_data
# Extra data in here - repeat for each stash data entry needed for panels # Extra data in here - repeat for each stash data entry needed for panels
); );
nfs_data{'trt'} = 'TABLE';
$c->render("Nfsshare"); $c->render("Nfsshare")
}
} }
# get routines for the stash contents here.
1; 1;

View File

@ -17,20 +17,20 @@
<table class="sme-border TableSort"> <table class="sme-border TableSort">
<thead> <thead>
<tr> <tr>
<th class='sme-border'>Name</th> <td>Name</td>
<th class='sme-border'>Description</th> <td>Description</td>
<th class='sme-border'>Nfs status</th> <td>Nfs status</td>
<th class='sme-border'>Action</th> <td>Action</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
% my $control_data = $self->stash('ibays'); % my $control_data = $self->stash('ibays');
% foreach my $row (@$control_data) { % foreach my $row (@$control_data) {
<tr> <tr>
<td class='sme-border'><%=$row->{Name}%></td> <td><%=$row->Name%></td>
<td class='sme-border'><%=$row->{Description}%></td> <td><%=$row->Description%></td>
<td class='sme-border'><%=$row->{flag}%></td> <td><%=$row->flag%></td>
<td class='sme-border'><%=$row->{PARAMS}%></td> <td><%=$row->PARAMS%></td>
</tr> </tr>
%} %}
</tbody> </tbody>

View File

@ -1,22 +1,23 @@
'nfs_These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files'
'nfs_For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).' => 'For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).'
'nfs_Share owner Group' => 'Share owner Group'
'nfs_Squash the power of users' => 'Squash the power of users'
'nfs_$thispanel successfull message' => '$thispanel successfull message'
'nfs Hello TABLE' => 'Hello TABLE'
'nfs_Set the UID.' => 'Set the UID.' 'nfs_Set the UID.' => 'Set the UID.'
'nfs_NFS Client(s) allowed' => 'NFS Client(s) allowed'
'nfs Hello PARAMS' => 'Hello PARAMS'
'nfs_Save' => 'Save'
'nfs_Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank' => 'Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank'
'nfs_EnableShare on local network' => 'EnableShare on local network'
'nfs_Set the GID.' => 'Set the GID.'
'nfs_APPLY' => 'APPLY'
'nfs_NFS data share' => 'NFS data share'
'nfs_File system permissions' => 'File system permissions'
'nfs_Requests on secure ports' => 'Requests on secure ports' 'nfs_Requests on secure ports' => 'Requests on secure ports'
'nfs_Write (a)synchronously' => 'Write (a)synchronously' 'nfs_These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files'
'nfs_Delays the disk writing' => 'Delays the disk writing' 'nfs_Delays the disk writing' => 'Delays the disk writing'
'nfs_Enable the NFS Share' => 'Enable the NFS Share'
'nfs_Browse the parent folders' => 'Browse the parent folders'
'nfs_Information Bay name' => 'Information Bay name' 'nfs_Information Bay name' => 'Information Bay name'
'nfs_EnableShare on local network' => 'EnableShare on local network'
'nfs_For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).' => 'For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).'
'nfs Hello TABLE' => 'Hello TABLE'
'nfs_NFS Client(s) allowed' => 'NFS Client(s) allowed'
'nfs_Error message' => 'Error message'
'nfs_Browse the parent folders' => 'Browse the parent folders'
'nfs_APPLY' => 'APPLY'
'nfs_Save' => 'Save'
'nfs_Share owner Group' => 'Share owner Group'
'nfs_File system permissions' => 'File system permissions'
'nfs_Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank' => 'Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank'
'nfs_Enable the NFS Share' => 'Enable the NFS Share'
'nfs_Write (a)synchronously' => 'Write (a)synchronously'
'nfs_ok message' => 'ok message'
'nfs Hello PARAMS' => 'Hello PARAMS'
'nfs_Set the GID.' => 'Set the GID.'
'nfs_Squash the power of users' => 'Squash the power of users'
'nfs_NFS data share' => 'NFS data share'

View File

@ -13,38 +13,6 @@ package SrvMngr::Controller::${PackageName};
# Documentation: https://wiki.contribs.org/{PackageName} # Documentation: https://wiki.contribs.org/{PackageName}
#---------------------------------------------------------------------- #----------------------------------------------------------------------
#
# Scheme of things:
#
#main:
##
## Initial entry
##
#set initial panel
#for initial panel:
# load up _data hash with DB fields
# load up stash with pointer(s) to control fields hash(= get-))
#render initial panel
#
#do_display
##
## Return after submit pushed on panel
##
#load up all params into local hash
# by panel:
# by param:
# validate param (return ret = ok or error message) - call validate-
# break out on error
#if validation not ok
# render back to current panel with error message in stash
#otherwise
# By panel:
# Copy back to DB any that have changed (how to easily tell if it has changed?)
# do whatever is required (inc signal_event smeserver-<whatever>-update?)
# set success
# call main?
use strict; use strict;
use warnings; use warnings;
use Mojo::Base 'Mojolicious::Controller'; use Mojo::Base 'Mojolicious::Controller';
@ -73,8 +41,6 @@ our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
require '/usr/share/smanager/lib/SrvMngr/Controller/${PackageName}-Custom.pm'; #The code that is to be added by the developer
sub main { sub main {
my $c = shift; my $c = shift;
@ -84,16 +50,13 @@ sub main {
my $title = $c->l("${prefix}_${MenuDescription}"); my $title = $c->l("${prefix}_${MenuDescription}");
my $modul = ''; my $modul = '';
$$${prefix}_data{'trt'} = '${firstPanel}'; $$${prefix}_data{trt} = '${firstPanel}';
#Load any DB entries into the <prefix>_data area so as they are preset in the form #Load any DB entries into the <prefix>_data area so as they are preset in the form
# which DB # which DB
my $db = $$${controldb | db | 'cdb'}; #pickup local or global db or Default to config my $db = $$${db | 'cdb'}; #Default to config
<tal:block tal:repeat="dbentry dbentries">$$${prefix}_data{${dbentry}} = $db->prop('${dbentry}') || ${dbdefault}; <tal:block tal:repeat="dbentry dbentries">
</tal:block> $$${prefix}_data{${dbentry}} = $db->prop('${dbentry}') || ${dbdefault}
# and table control fields
<tal:block tal:repeat="tablecontrol tablecontrols"> $c->stash(${tablecontrol}=>get_${tablecontrol}());
</tal:block> </tal:block>
$c->stash( $c->stash(
@ -119,10 +82,8 @@ sub do_update {
#Params are available in the hash "params" #Params are available in the hash "params"
# you may use: # you may use:
my @result;
foreach my $key (keys %params) { foreach my $key (keys %params) {
my $value = $params{$key}; my $value = $params{$key};
push @result, { $key => $value };
$c->app->log->debug("$key: $value"); $c->app->log->debug("$key: $value");
} }
@ -130,33 +91,37 @@ sub do_update {
my $trt = $c->param('trt') || '${firstPanel}' ; #hidden control on every form. my $trt = $c->param('trt') || '${firstPanel}' ; #hidden control on every form.
my $ret = 'ok'; my $ret = 'ok';
#Validate the parameters accordingly #Validate the parameters accordingly
my $thispanel; <tal:block tal:repeat="condition conditions">
<tal:block tal:repeat="panel panels"> if ($trt eq '${condition}'){
if ($trt eq '${panel}'){ #Validate form parameters for panel ${condition}
#Validate form parameters for panel ${panel} # and set $ret = $c->l('Error message') if invalid'
$ret = validate_${panel}(); # otherwise set $ret to "ok"
$thispanel = '${panel}'; if ($ret ne "ok"){
} $c->stash(error => $c->l($ret))
</tal:block> } else {
if ($ret eq "ok") {
#Do whatever is needed, including writing values to the DB #Do whatever is needed, including writing values to the DB
my $db = $$${controldb | db | 'cdb'}; #pickup local or global db or Default to config my $db = $$${db | 'cdb'}; #Default to config
<tal:block tal:repeat="dbentry dbentries"> <tal:block tal:repeat="dbentry dbentries">
$db->set_prop('${dbentry}'=> param{'${dbentry}'}; #Copy back into db $db->set_prop('${dbentry}'=> param{'${dbentry}'}; #Copy back into db
$$${prefix}_data{${dbentry}} = $db->prop('${dbentry}'); #Copy out into stash $$${prefix}_data{${dbentry}} = $db->prop('${dbentry}'); #Copy out into stash
</tal:block> </tal:block>
# anything else here...
$c->stash( success => $c->l("$thispanel successfull message")); } $c->stash( success => $c->l('ok message'))
}
</tal:block>
# set ${prefix}_data{trt} = <route>;
$c->stash( $c->stash(
title => $title, title => $title,
${prefix}_data => \%${prefix}_data ${prefix}_data => \%${prefix}_data
# Extra data in here - repeat for each stash data entry needed for panels # Extra data in here - repeat for each stash data entry needed for panels
); );
${prefix}_data{'trt'} = '${firstPanel}';
$c->render("${PackageName}"); $c->render("${PackageName}")
}
} }
# get routines for the stash contents here.
1; 1;

View File

@ -1,44 +0,0 @@
#
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
#$cdb=$main::cdb;
#$adb=$main::adb;
#$ndb=$main::ndb;
#$hdb=$main::hdb;
#$ddb=$main::ddb;
use esmith::util;
use esmith::HostsDB;
use esmith::AccountsDB;
use esmith::NetworksDB;
use esmith::HostsDB;
use esmith::DomainsDB;
#The most common ones
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# Validation routines - parameters for each panel
<tal:block tal:repeat="panel panels">
sub validate_${panel} {
$ret = 'ok';
return $ret;
}
</tal:block>
# Get control data for tables(s)
<tal:block tal:repeat="tablecontrol tablecontrols">
sub get_${tablecontrol} {
return []
}
</tal:block>
1;

View File

@ -101,14 +101,14 @@
<table class="sme-border TableSort"> <table class="sme-border TableSort">
<thead> <thead>
<tr><tal:block tal:repeat="ColHead TopHeadings"> <tr><tal:block tal:repeat="ColHead TopHeadings">
<th class='sme-border'>${ColHead}</th></tal:block> <td>${ColHead}</td></tal:block>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
% my $control_data = $self->stash('${TableControl}'); % my $control_data = $self->stash('${Control}');
% foreach my $row (@$control_data) { % foreach my $row (@$control_data) {
<tr><tal:block tal:repeat="ColContent Columns"> <tr><tal:block tal:repeat="ColContent Columns">
<td class='sme-border'><%=$row->{${ColContent}}%></td></tal:block> <td><%=$row->${ColContent}%></td></tal:block>
</tr> </tr>
%} %}
</tbody> </tbody>

View File

@ -136,7 +136,7 @@
SubHeader: 'Manage NFS Ibay settings:', SubHeader: 'Manage NFS Ibay settings:',
Table1: { Table1: {
Type:"Table", Type:"Table",
TableControl:"ibays", Control:"ibays",
TopHeadings: ['Name','Description','Nfs status', 'Action'], TopHeadings: ['Name','Description','Nfs status', 'Action'],
Columns: ['Name','Description','flag','PARAMS'] Columns: ['Name','Description','flag','PARAMS']
} }

View File

@ -6,10 +6,8 @@ from chameleon import PageTemplateFile,PageTemplate
import pkg_resources import pkg_resources
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import re import re
import os
version = 0.5
version = 0.6
json5_dict: dict = {} json5_dict: dict = {}
json5_html_list: list = [] json5_html_list: list = []
@ -74,32 +72,13 @@ def find_item(nested_dict, target_key):
if result is not None: if result is not None:
return result return result
def find_dicts_with_key(data, target_key): def find_dicts_with_key(nested_dict, target_key):
results = [] results = []
if isinstance(data, dict): for key, val in nested_dict.items():
if target_key in data: if isinstance(val, dict):
results.append(data) if target_key in val:
for val in data.values(): results.append(val)
if isinstance(val, (dict, list)):
results.extend(find_dicts_with_key(val, target_key)) results.extend(find_dicts_with_key(val, target_key))
elif isinstance(data, list):
for item in data:
if isinstance(item, (dict, list)):
results.extend(find_dicts_with_key(item, target_key))
return results
def find_values_with_key(data, target_key):
results = []
if isinstance(data, dict):
if target_key in data:
results.append(data[target_key])
for val in data.values():
if isinstance(val, (dict, list)):
results.extend(find_values_with_key(val, target_key))
elif isinstance(data, list):
for item in data:
if isinstance(item, (dict, list)):
results.extend(find_values_with_key(item, target_key))
return results return results
def lint_json5(filename): def lint_json5(filename):
@ -142,18 +121,6 @@ def lc_get_all_routes():
route_list = [html_block.get('route').lower() for html_block in json5_dict.get('html', [])] route_list = [html_block.get('route').lower() for html_block in json5_dict.get('html', [])]
return route_list return route_list
def has_file_been_modified(file_path):
# Get the file's creation time and last modification time in Unix timestamp
creation_time = os.path.getctime(file_path)
last_modification_time = os.path.getmtime(file_path)
# Compare the creation time and last modification time
if creation_time < last_modification_time:
return True # File has been modified after creation
else:
return False # File has not been modified after creation
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
def parse_xml_to_dict(xml_file): def parse_xml_to_dict(xml_file):
@ -183,11 +150,6 @@ def deduplicate_array(arr):
return deduplicated_list return deduplicated_list
def get_db_fields():
return []
def get_table_control_data():
return find_values_with_key(json5_html_list,'TableControl')
if __name__ == "__main__": if __name__ == "__main__":
filename = '/home/brianr/clients/SM2/SM2Gen/nfsshare.json5' filename = '/home/brianr/clients/SM2/SM2Gen/nfsshare.json5'
@ -220,30 +182,25 @@ if __name__ == "__main__":
# Routes for each panel # Routes for each panel
routes = get_all_routes(); routes = get_all_routes();
#print(routes)
lc_routes =lc_get_all_routes(); lc_routes =lc_get_all_routes();
#File names #File names
controller_file = 'Targets/'+hl('PackageName')+'.pm' controller_file = 'Targets/'+hl('PackageName')+'.pm'
custom_controller_file = 'Targets/'+hl('PackageName')+'-Custom.pm'
# see if it has been modified by developer
if has_file_been_modified(custom_controller_file):
custom_controller_file = custom_controller_file+'.new'
layout_file = 'Targets/'+hl('PackageName')+'.html.ep' layout_file = 'Targets/'+hl('PackageName')+'.html.ep'
partial_files = list() partial_files = list()
for panel in routes: for panel in routes:
partial_files.append('Targets/_'+hl('prefix')+"_"+panel+'.html.ep') partial_files.append('Targets/_'+hl('prefix')+"_"+panel+'.html.ep')
print(partial_files) print(partial_files)
lex_file = 'Targets/'+hl('PackageName').lower()+'_en.lex' lex_file = 'Targets/'+hl('PackageName').lower()+'_en.lex'
tablecontrols = get_table_control_data() #arrays of hashes used to drive rows in tables
#print(tablecontrols)
#quit()
#Generate controller file #Generate controller file
try: try:
controller_template = PageTemplateFile("Templates/controller.pm.tem") controller_template = PageTemplateFile("Templates/controller.pm.tem")
dbentries = get_db_fields() #Params which correspond to Db fields dbentries = []
try: try:
controller_perl = controller_template.render(tablecontrols=tablecontrols, dbentries=dbentries,**json5_dict,panels=routes,lcPackageName=json5_dict['PackageName'].lower()) controller_perl = controller_template.render(dbentries=dbentries,**json5_dict,conditions=routes,lcPackageName=json5_dict['PackageName'].lower())
#print() #print()
#print(controller_perl) #print(controller_perl)
# Map '$ 'to '$' to overcome problem with escaping $ signs # Map '$ 'to '$' to overcome problem with escaping $ signs
@ -256,20 +213,6 @@ if __name__ == "__main__":
except Exception as e: except Exception as e:
print(f"An chameleon controller template error occurred: {e}") print(f"An chameleon controller template error occurred: {e}")
#Generate Custom controller file
try:
custom_controller_template = PageTemplateFile("Templates/custom.pm.tem")
try:
custom_controller_perl = custom_controller_template.render(panels=routes,tablecontrols=tablecontrols)
# We must be careful to not overwrite the custom file if the developer has already written to it - TBD
with open(custom_controller_file, 'w') as file:
file.write(custom_controller_perl)
print(f"{custom_controller_file} custom controller generated ok")
except Exception as e:
print(f"An chameleon custom controller render error occurred: {e}")
except Exception as e:
print(f"An chameleon custom controller template error occurred: {e}")
#generate Layout file #generate Layout file
layout_template = PageTemplateFile("Templates/layout.html.ep.tem") layout_template = PageTemplateFile("Templates/layout.html.ep.tem")
try: try:
@ -380,7 +323,7 @@ if __name__ == "__main__":
# create a combined list of all the files # create a combined list of all the files
all_files = [controller_file,layout_file]+partial_files all_files = [controller_file,layout_file]+partial_files
#print(all_files) print(all_files)
all_strings = [] all_strings = []
for filename in all_files: for filename in all_files:
with open(filename, 'r') as file: with open(filename, 'r') as file:
@ -389,12 +332,12 @@ if __name__ == "__main__":
pattern = r"l[\s|(][\'|\"](.*)[\'|\"]\)" pattern = r"l[\s|(][\'|\"](.*)[\'|\"]\)"
# Use re.findall to extract all occurrences of the pattern from the file content # Use re.findall to extract all occurrences of the pattern from the file content
extracted_strings = re.findall(pattern, file_content) extracted_strings = re.findall(pattern, file_content)
#print(len(extracted_strings)) print(len(extracted_strings))
all_strings = all_strings + extracted_strings all_strings = all_strings + extracted_strings
#print(len(all_strings)) print(len(all_strings))
#Take out any duplicates #Take out any duplicates
all_strings = deduplicate_array(all_strings) all_strings = deduplicate_array(all_strings)
#print(len(all_strings)) print(len(all_strings))
# Now process them one by one into the lexical file # Now process them one by one into the lexical file
lex_all = ""; lex_all = "";
# '<prefix>_english-message' => 'English Message', # '<prefix>_english-message' => 'English Message',