More fixes to lexical scan

This commit is contained in:
Brian Read 2024-05-06 10:05:43 +01:00
parent 228a42ed60
commit a5f8e153a2
12 changed files with 152 additions and 105 deletions

View File

@ -2,7 +2,7 @@
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-04-27 10:35
# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 08:40
#
use esmith::util;
@ -23,14 +23,16 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# Validation routines - parameters for each panel
sub validate_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub validate_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
@ -39,7 +41,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
sub get_ibays {
my $c = shift;
my @res;
my @ret = {};
my @ibays = $adb->ibays();
foreach my $i (@ibays){
# Taken pretty well verbatim from /usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/nfsshare.pm
@ -59,7 +61,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $actionModify = ' ';
if ($modifiable eq 'yes'){
$actionModify .= "<a href='nfsshareu?trt=PARAMS&Selected=$ibayname'><button class='sme-modify-button' title=".$c->l("MODIFY").">".$c->l("MODIFY")."</button></a>"."&nbsp"
$actionModify .= "<a href='nfsshared?trt=PARAMS&Selected=$ibayname'><button class='sme-modify-button' title=".$c->l("MODIFY").">".$c->l("MODIFY")."</button></a>"."&nbsp"
}
my %hash = ('Name'=> $ibayname,
@ -67,22 +69,27 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
'Flag' => $ibaynfs,
'Modify' => $actionModify
);
push(@res,\%hash);
push(@ret,\%hash);
}
return \@res
return \@ret
}
# Return hash with values from row in which link clicked on table
sub validate_get_selected_PARAMS {
$selected = shift; #Parameter is name of selected row.
%ret = {};
sub get_selected_PARAMS {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
}
sub validate_get_selected_TABLE {
$selected = shift; #Parameter is name of selected row.
%ret = {};
sub get_selected_TABLE {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
}
@ -90,18 +97,27 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
sub perform_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub perform_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub create_link{
# WIP
my ($c,$route, $panel, $index) = shift;
my $link = "$route?trt=$panel&Selected=$index";
return $link;
}
1;

View File

@ -2,7 +2,7 @@
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
#
use esmith::util;
@ -23,14 +23,16 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# Validation routines - parameters for each panel
sub validate_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub validate_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
@ -39,22 +41,26 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
sub get_ibays {
my $c = shift;
@ret = {}
my @ret = {};
return \@ret
}
# Return hash with values from row in which link clicked on table
sub validate_get_selected_PARAMS {
$selected = shift; #Parameter is name of selected row.
%ret = {};
sub get_selected_PARAMS {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
}
sub validate_get_selected_TABLE {
$selected = shift; #Parameter is name of selected row.
%ret = {};
sub get_selected_TABLE {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
}
@ -62,14 +68,16 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
sub perform_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub perform_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}

View File

@ -1,6 +1,6 @@
% layout 'default', title => "Sme server 2 - NFS data share", share_dir => './';
%#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
%# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
%#
% content_for 'module' => begin
<div id="module" class="module Nfsshare-panel">

View File

@ -1,6 +1,6 @@
package SrvMngr::Controller::Nfsshare;
#
# Generated by version:SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
# Generated by version:SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
#
#----------------------------------------------------------------------
# heading : Network
@ -10,6 +10,7 @@ package SrvMngr::Controller::Nfsshare;
# name : nfsshare, method : get, url : /nfsshare, ctlact : nfsshare#main
# name : nfsshareu, method : post, url : /nfsshareu, ctlact : nfsshare#do_update
# name : nfsshared, method : get, url : /nfsshared, ctlact : nfsshare#do_display
# name : nfssharee, method : post, url : /nfsshared, ctlact : nfsshare#do_display
#
# routes : end
#
@ -67,7 +68,7 @@ sub main {
$c->app->log->info( $c->log_req );
my %nfs_data = ();
my $title = $c->l("nfs_NFS_data_share");
my $title = $c->l('nfs_NFS_data_share');
my $modul = '';
$nfs_data{'trt'} = 'TABLE';
@ -89,7 +90,7 @@ sub main {
$c->render( template => "Nfsshare" );
}
# Post request with params - submit from a form
# Post request with params - submit from the form
sub do_update {
#
# Return after submit pushed on panel (this is a post) - route is "/<whatever>u"
@ -119,7 +120,7 @@ sub do_update {
$c->app->log->info($c->log_req);
my %nfs_data = ();
my $title = $c->l("nfs_NFS_data_share");
my $title = $c->l('nfs_NFS_data_share');
# Accessing all POST parameters
my %params = $c->req->params->to_hash;
@ -141,13 +142,13 @@ sub do_update {
if ($trt eq 'PARAMS'){
#Validate form parameters for panel PARAMS
$ret = validate_PARAMS(\%nfs_data);
$ret = validate_PARAMS($c,\%nfs_data);
$thispanel = 'PARAMS';
}
if ($trt eq 'TABLE'){
#Validate form parameters for panel TABLE
$ret = validate_TABLE(\%nfs_data);
$ret = validate_TABLE($c,\%nfs_data);
$thispanel = 'TABLE';
}
@ -161,25 +162,25 @@ sub do_update {
if ($trt eq 'PARAMS'){
#do whatever is required ...
$ret = perform_PARAMS(\%nfs_data);
$ret = perform_PARAMS($c,\%nfs_data);
if ($ret ne "ok") {
# return to the panel with error message
$c->stash(error => $c->l($ret));
$c->render("Nfsshare");
} else {
$c->stash( success => $c->l("nfs_PARAMS_panel_action_was_successfull")); #A bit bland - edit it in the lex file
$c->stash( success => $c->l('nfs_PARAMS_panel_action_was_successfull')); #A bit bland - edit it in the lex file
}
}
if ($trt eq 'TABLE'){
#do whatever is required ...
$ret = perform_TABLE(\%nfs_data);
$ret = perform_TABLE($c,\%nfs_data);
if ($ret ne "ok") {
# return to the panel with error message
$c->stash(error => $c->l($ret));
$c->render("Nfsshare");
} else {
$c->stash( success => $c->l("nfs_TABLE_panel_action_was_successfull")); #A bit bland - edit it in the lex file
$c->stash( success => $c->l('nfs_TABLE_panel_action_was_successfull')); #A bit bland - edit it in the lex file
}
}
@ -203,7 +204,9 @@ sub do_update {
sub do_display {
#
# Return after link clicked in table (this is a get) - route is "/<whatever>d"
# Expects ?trt=PANEL&selected="TableRownfs_Name" plus any other required
# Expects ?trt=PANEL&selected="TableRowName" plus any other required
#
# OR it maybe a post from the main panel to add a new record
#
#load up all supplied params into prefix_data hash
#call get-selected-PANEL() - returns hash of all relevent parameters
@ -214,14 +217,17 @@ sub do_display {
$c->app->log->info($c->log_req);
my %nfs_data = ();
my $title = $c->l("nfs_NFS_data_share");
my $title = $c->l('nfs_NFS_data_share');
# Accessing all POST parameters
# Accessing all parameters
my %params = $c->req->params->to_hash;
# Get number of POST parameters
# Get number of parameters
my $num_params = keys %params;
#Tag as Post or Get (ie. create new entry or edit existing one
my $is_new_record = ($c->req->method() eq 'POST');
#Params are available in the hash "params" - copy to the prefix_data hash
while (my ($key, $value) = each %{$c->req->params->to_hash}) {
$nfs_data{$key} = $value;
@ -231,16 +237,17 @@ sub do_display {
my $trt = $c->param('trt') || 'TABLE'; #Indicates where to go now
# Now add in the params from the selected row from the table
my %selectedrow;
if ($trt eq 'PARAMS'){
#Validate form parameters for panel PARAMS
%selectedrow = selected_PARAMS($nfs_data{'Selected'});
%selectedrow = get_selected_PARAMS($c,$nfs_data{'Selected'},$is_new_record);
}
if ($trt eq 'TABLE'){
#Validate form parameters for panel TABLE
%selectedrow = selected_TABLE($nfs_data{'Selected'});
%selectedrow = get_selected_TABLE($c,$nfs_data{'Selected'},$is_new_record);
}

View File

@ -1,5 +1,5 @@
%#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
%# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
%#
<div id="Nfsshare-PARAMS">
<script>
@ -8,7 +8,7 @@
};
</script>
<h2>
%= l("nfs_Hello_PARAMS");
%= l('nfs_Hello_PARAMS');
</h2>
% my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin
@ -26,7 +26,7 @@
<p><span class=label>
%=l('nfs_Information_Bay_name'), class => 'label'
</span><span class=data>
%= stash("Ibaynfs_Name"), class => 'data'
%= stash("IbayName"), class => 'data'
</span></p>
<p><span class=label>

View File

@ -1,5 +1,5 @@
%#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
%# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
%#
<div id="Nfsshare-TABLE">
<script>
@ -8,7 +8,7 @@
};
</script>
<h2>
%= l("nfs_Hello_TABLE");
%= l('nfs_Hello_TABLE');
</h2>
% my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin
@ -32,8 +32,8 @@
% my $control_data = $self->stash('ibays');
% foreach my $row (@$control_data) {
<tr>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{nfs_Name})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{nfs_Description})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{Name})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{Description})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{flag})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{Modify})%></td>
</tr>

View File

@ -1,28 +1,28 @@
'nfs_PARAMS_panel_action_was_successfull' => 'PARAMS panel action was successfull',
'nfs_Information_Bay_name' => 'Information Bay name',
'nfs_Name' => 'Name',
'nfs_For_writing_permissions,allowing_the_root' => '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_Manage_NFS_Ibay_settings:' => 'Manage NFS Ibay settings:',
'nfs_NFS_data_share' => 'NFS data share',
'nfs_NFS_Client(s)_allowed' => 'NFS Client(s) allowed',
'nfs_Hello_TABLE' => 'Hello TABLE',
'nfs_Set_the_uid_and_gid' => 'Set the uid and gid if you want all requests appear to be from one user or one group, Otherwise leave blank',
'nfs_Write_(a)synchronously' => 'Write (a)synchronously',
'nfs_These_parameters_will_be_effective' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files',
'nfs_Set_the_UID.' => 'Set the UID. ',
'nfs_File_system_permissions' => 'File system permissions',
'nfs_Delays_the_disk_writing' => 'Delays the disk writing',
'nfs_Squash_the_power_of_users' => 'Squash the power of users',
'nfs_Information_Bay_name' => 'Information Bay name',
'nfs_Share_owner_Group' => 'Share owner Group',
'nfs_Save' => 'Save',
'nfs_APPLY' => 'Apply',
'nfs_Description' => 'Description',
'nfs_Hello_PARAMS' => 'Hello PARAMS',
'nfs_TABLE_panel_action_was_successfull' => 'TABLE panel action was successfull',
'nfs_Enable_the_NFS_Share' => 'Enable the NFS Share',
'nfs_EnableShare_on_local_network' => 'Enableshare on local network',
'nfs_Share_owner_Group' => 'Share owner Group',
'nfs_Browse_the_parent_folders' => 'Browse the parent folders',
'nfs_Hello_PARAMS' => 'Hello PARAMS',
'nfs_Delays_the_disk_writing' => 'Delays the disk writing',
'nfs_These_parameters_will_be_effective' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files',
'nfs_Hello_TABLE' => 'Hello TABLE',
'nfs_NFS_Client(s)_allowed' => 'NFS Client(s) allowed',
'nfs_File_system_permissions' => 'File system permissions',
'nfs_Description' => 'Description',
'nfs_PARAMS_panel_action_was_successfull' => 'PARAMS panel action was successfull',
'nfs_Set_the_GID.' => 'Set the GID. ',
'nfs_Action' => 'Action',
'nfs_NFS_data_share' => 'NFS data share',
'nfs_Manage_NFS_Ibay_settings:' => 'Manage NFS Ibay settings:',
'nfs_For_writing_permissions,allowing_the_root' => '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_Browse_the_parent_folders' => 'Browse the parent folders',
'Nfs_status' => 'Status',
'nfs_Requests_on_secure_ports' => 'Requests on secure ports',
'nfs_TABLE_panel_action_was_successfull' => 'TABLE panel action was successfull',
'nfs_Set_the_uid_and_gid' => 'Set the uid and gid if you want all requests appear to be from one user or one group, Otherwise leave blank',
'nfs_APPLY' => 'Apply',
'nfs_Set_the_UID.' => 'Set the UID. ',
'nfs_Name' => 'Name',
'nfs_Set_the_GID.' => 'Set the GID. ',
'nfs_Save' => 'Save',
'nfs_Write_(a)synchronously' => 'Write (a)synchronously',

View File

@ -10,6 +10,7 @@ package SrvMngr::Controller::${PackageName};
# name : ${lcPackageName}, method : get, url : /${lcPackageName}, ctlact : ${lcPackageName}#main
# name : ${lcPackageName}u, method : post, url : /${lcPackageName}u, ctlact : ${lcPackageName}#do_update
# name : ${lcPackageName}d, method : get, url : /${lcPackageName}d, ctlact : ${lcPackageName}#do_display
# name : ${lcPackageName}e, method : post, url : /${lcPackageName}d, ctlact : ${lcPackageName}#do_display
#
# routes : end
#
@ -67,7 +68,7 @@ sub main {
$c->app->log->info( $c->log_req );
my %${prefix}_data = ();
my $title = $c->l("${prefix}_${MenuDescription}");
my $title = $c->l('${prefix}_${MenuDescription}');
my $modul = '';
$$${prefix}_data{'trt'} = '${firstPanel}';
@ -91,7 +92,7 @@ sub main {
$c->render( template => "${PackageName}" );
}
# Post request with params - submit from a form
# Post request with params - submit from the form
sub do_update {
#
# Return after submit pushed on panel (this is a post) - route is "/<whatever>u"
@ -121,7 +122,7 @@ sub do_update {
$c->app->log->info($c->log_req);
my %${prefix}_data = ();
my $title = $c->l("${prefix}_${MenuDescription}");
my $title = $c->l('${prefix}_${MenuDescription}');
# Accessing all POST parameters
my %params = $c->req->params->to_hash;
@ -143,7 +144,7 @@ sub do_update {
<tal:block tal:repeat="panel panels">
if ($trt eq '${panel}'){
#Validate form parameters for panel ${panel}
$ret = validate_${panel}(\%${prefix}_data);
$ret = validate_${panel}($c,\%${prefix}_data);
$thispanel = '${panel}';
}
</tal:block>
@ -157,13 +158,13 @@ sub do_update {
<tal:block tal:repeat="panel panels">
if ($trt eq '${panel}'){
#do whatever is required ...
$ret = perform_${panel}(\%${prefix}_data);
$ret = perform_${panel}($c,\%${prefix}_data);
if ($ret ne "ok") {
# return to the panel with error message
$c->stash(error => $c->l($ret));
$c->render("${PackageName}");
} else {
$c->stash( success => $c->l("${panel} panel action was successfull")); #A bit bland - edit it in the lex file
$c->stash( success => $c->l('${panel} panel action was successfull')); #A bit bland - edit it in the lex file
}
}
</tal:block>
@ -189,6 +190,8 @@ sub do_display {
# Return after link clicked in table (this is a get) - route is "/<whatever>d"
# Expects ?trt=PANEL&selected="TableRowName" plus any other required
#
# OR it maybe a post from the main panel to add a new record
#
#load up all supplied params into prefix_data hash
#call get-selected-PANEL() - returns hash of all relevent parameters
#load up returned hash into prefix_data
@ -198,14 +201,17 @@ sub do_display {
$c->app->log->info($c->log_req);
my %${prefix}_data = ();
my $title = $c->l("${prefix}_${MenuDescription}");
my $title = $c->l('${prefix}_${MenuDescription}');
# Accessing all POST parameters
# Accessing all parameters
my %params = $c->req->params->to_hash;
# Get number of POST parameters
# Get number of parameters
my $num_params = keys %params;
#Tag as Post or Get (ie. create new entry or edit existing one
my $is_new_record = ($c->req->method() eq 'POST');
#Params are available in the hash "params" - copy to the prefix_data hash
while (my ($key, $value) = each %{$c->req->params->to_hash}) {
$$${prefix}_data{$key} = $value;
@ -215,11 +221,12 @@ sub do_display {
my $trt = $c->param('trt') || '${firstPanel}'; #Indicates where to go now
# Now add in the params from the selected row from the table
my %selectedrow;
<tal:block tal:repeat="panel panels">
if ($trt eq '${panel}'){
#Validate form parameters for panel ${panel}
%selectedrow = selected_${panel}($$${prefix}_data{'Selected'});
%selectedrow = get_selected_${panel}($c,$$${prefix}_data{'Selected'},$is_new_record);
}
</tal:block>

View File

@ -23,8 +23,9 @@ 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} {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
</tal:block>
@ -33,16 +34,18 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
<tal:block tal:repeat="tablecontrol tablecontrols">
sub get_${tablecontrol} {
my $c = shift;
@ret = {}
my @ret = {};
return \@ret
}
</tal:block>
# Return hash with values from row in which link clicked on table
<tal:block tal:repeat="panel panels">
sub validate_get_selected_${panel} {
$selected = shift; #Parameter is name of selected row.
%ret = {};
sub get_selected_${panel} {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
}
</tal:block>
@ -50,8 +53,9 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
<tal:block tal:repeat="panel panels">
sub perform_${panel} {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
</tal:block>

View File

@ -8,7 +8,7 @@
};
</script>
<h2>
%= l("${prefix} Hello ${route}");
%= l('${prefix} Hello ${route}');
</h2>
% my $btn = l('APPLY');
%= form_for "${PackageName}d" => (method => 'POST') => begin

View File

@ -132,12 +132,12 @@
},
{
Name: 'select_ibay',
route:"TABLE",
route:'TABLE',
Header: 'NFS Share Contrib',
SubHeader: 'Manage NFS Ibay settings:',
Nextpanel: 'PARAMS',
Table1: {
Type:"Table",
Type:'Table',
TableControl:"ibays",
TopHeadings: ['Name','Description','Nfs status', 'Action'],
Columns: ['Name','Description','flag','Modify']

View File

@ -1,5 +1,4 @@
import json5
#import pandas as pd
import sys
import argparse
from chameleon import PageTemplateFile,PageTemplate
@ -11,6 +10,12 @@ import pkg_resources
from datetime import datetime
import xml.etree.ElementTree as ET
#
#To Do
# 1. Get routing working
# 2. Deal with ? and ! as sentence ends in text-format
# 3. Make lexical scan work with double or single quotes (if possible)
SME2Gen_version = '0.7'
json5_dict: dict = {}
json5_html_list: list = []
@ -440,13 +445,13 @@ if __name__ == "__main__":
left_str = hl('prefix')+"_"+lex_message
right_str = lex_message
right_str = right_str.replace("_"," ")
print(f"Right:{right_str}")
right_str = format_text(right_str)
left_str = left_str.replace(" ","_")
words = left_str.split('_')[:6]
left_str = "_".join(words)
next_lex_str = {"orig":original_str,"left":left_str,"right":right_str}
string_lib.append(next_lex_str)
#print(string_lib)
#And write it to lex file
# Now process them one by one into the lexical file
lex_all = "";
@ -466,7 +471,7 @@ if __name__ == "__main__":
left_str = item["left"]
right_str = item["right"]
# Replace all occurrences of original string with left string in 'contents'
file_content = file_content.replace(original_str, left_str)
file_content = file_content.replace("l('"+original_str+"')", "l('"+left_str+"')")
# and write it back
with open(filename, 'w') as file:
file.write(file_content)