$pwd = `pwd`; $pwd =~ s/\/*\n*$//;
}
-my $cnf = new CNFParser('databaseProgresSQL.cnf');
+my $cnf = new CNFParser('old/databasePGSQL.cnf');
print "resw".$cnf->isReservedWord('TABLE');
print "resw:".$cnf->isReservedWord();
my ($u,$p) = split '/', $alin;
my $db = DBI->connect($DSN, $u, $p, {AutoCommit => 1, RaiseError => 1, PrintError => 0, show_trace=>1});
-$cnf->initiDatabase(\$db);
-foreach my $const(keys %{$cnf->constants()}){
- print $const, "\n";
+#$cnf->initiDatabase(\$db);
+foreach my $const(keys %$cnf){
+ print $const." =". $cnf->{$const}, "\n";
}
-our $APP_VER = $cnf->constant('$APP_VER'); $APP_VER++;
+our $APP_VER = $cnf->{'$APP_VER'}; $APP_VER++;
print $APP_VER, "\n";
our $APP_VER1 = $cnf->constant('$APP_VER');
print $APP_VER1, "\n";
#DEFAULT SETTINGS HERE!
#LanguageServer doesn't like -> $ENV{'PWD'} settings.json should not be set for it withn an pwd.
-#use lib "system/modules/";
use lib "system/modules";
require CNFParser;
binmode($OUT);
print $OUT $gd->png();
close $OUT;
-
-
-
-
$RELEASE_VER = 1.0`Current CNF version under test.
>>
-<<DBI_SOURCE<DBI:Pg:host=localhost;dbname=lifelog>>>
+<<DBI_SOURCE<DBI:Pg:host=localhost;dbname=lifelog;port=5433>>>
<<AUTO_LOGIN<lifelog/lifelog>>>
<<CNF_PROCESSING_DATE<DO>my $date = `date +%c`;>>
<<@<@DIM_SET_BITCOIN>1200,480>>
title = 'Current Bitcoin Price State $$$CNF_PROCESSING_DATE$$$'
x_label = 'Days'
y_label = 'Price'
-y_max_value = 67000
+y_max_value = 76000 #<- TODO algorithmically calculate.
y_tick_number = 10
x_all_ticks = 1
y_all_ticks = 1
Columns max,min,avg are the plot lines, dt is the x period line in last 30 days
<<SEL_BITCOIN_30_DAY_RANGE<SQL>
-SELECT
+SELECT
concat(date_part('day', dt), '/', date_part('month', dt)),
- max::numeric(10,2),
- min::numeric(10,2),
- avg::numeric(10,2)
-FROM public."DAILY_AVG_BITCOIN"
+ max::numeric(10,2),
+ min::numeric(10,2),
+ avg::numeric(10,2)
+FROM public."DAILY_AVG_BITCOIN"
WHERE dt >= (now() - '30 days'::interval)::date
ORDER BY dt DESC;
>>
<<SEL_BITCOIN_3_MONTH_RANGE<SQL>
-SELECT
+SELECT
concat(date_part('day', dt), '/', date_part('month', dt)),
- max::numeric(10,2),
- min::numeric(10,2),
- avg::numeric(10,2)
-FROM public."DAILY_AVG_BITCOIN"
- WHERE dt >= (now() - '3 month'::interval)::date
+ max::numeric(10,2),
+ min::numeric(10,2),
+ avg::numeric(10,2)
+FROM public."DAILY_AVG_BITCOIN"
+ WHERE dt >= (now() - '3 month'::interval)::date
ORDER BY dt;
>>
echo -e $(date +"%D %T") $(basename $0) "Started"
stor=$($HOME/uvar.sh -r BITCOIN_PRICE);
-grab=$(curl -s rate.sx./1btc | cut -d. -f1)
+grab=$(curl -s rate.sx./1btc | cut -d. -f1)
record=0
if [ -z $stor ] || [ $stor -ne $grab ]; then
$HOME/uvar.sh -n BITCOIN_PRICE -v $grab;
stor=$grab; record=1;
-fi
+fi
grab=$(printf "US $%'.2f", $grab)
/usr/bin/notify-send "BITCON PRICE" "$grab"
if [ $record == 1 ]; then
--- Prerequisite is that CNF_TEST_DB is created and assigned to user postgres or what ever stated bellow:
-<<DBI_SOURCE<DBI:Pg:host=localhost;dbname=lifelog>>>
+<<DBI_SOURCE<DBI:Pg:host=localhost;dbname=lifelog;port=5433>>>
<<!DBI_SOURCE2<DBI:SQLite:dbname=CNF_TEST_DB.db>>>
<<AUTO_LOGIN<postgres/postgres>>>
my $self = \%$attrs;
bless $self, $class;
}
+sub _isNode {
+ return ref(shift) eq 'CNFNode'
+}
+
use constant PRIVATE_FIELDS => qr/@\$|[@#_~^&]/o;
use constant EMPTY => new CNFNode;
# NOTICE - 20221222 Future versions might provide also for more complex path statements with regular expressions enabled.
###
sub find {
- my ($self, $path, $ret, $prev, $seekArray,$ref)=@_; my @arr;
+ my ($self, $path, $ret, $prev, $seekArray,$ref)=@_; my (@arr,$seekPName);
foreach my $name(split(/\//, $path)){
- if( $name eq "*" && @arr){
- return \@arr # The path instructs to return an array, which is set but return is set to single only found element.
+ if($name eq '*'){
+ #return \@arr if @arr; # The path instructs to return an array, which is set but return is set to single only found element.
+ # foreach my $itm(@arr){
+ # $self = $itm;
+ # }
+ $seekPName = $self->{'_'} if ref($self) eq 'CNFNode';
+ $seekArray = 1;
+ $ret = \@arr;
+ next;
}
elsif(ref($self) eq "ARRAY"){
if($name eq '#'){
if (!$seekArray){
# This will initiate further search in subproperties names.
$ret = $self->{'@$'};
- @arr = ();
+ @arr = ()
}
}
}
my $found = 0;
undef $prev;
foreach my $ele(@$ret){
+ my $r = ref($ele);
+ if($r eq 'ARRAY'){#TODO Is this to account here allso for rest of search path?
+ $ele = @{$ele}[0]
+ }
if($seekArray && exists $ele->{'@$'}){
foreach my$node(@{$ele->{'@$'}}){
if ($node->{'_'} eq $name){
$arr[@arr] = $ele = $node;
+ }elsif($node->{'_'} eq $seekPName){
+ my $seek = $node -> find("$seekPName/$name");
+ $ref = ref($seek);
+ if($ref eq 'ARRAY'){
+ @arr=();
+ foreach my$nd(@{$seek}){
+ my $child = $nd -> findChildrenByName($name);
+ $arr[@arr] = $child if $child
+ }
+ return \@arr if(@arr>1);
+ $ele = $arr[0];
+ @arr=();
+ }elsif($ref eq 'CNFNode'){
+ $ele = $seek;
+ }
}
}
if(@arr>1){
$ret = $ele->{$name};
$found = 1
}
+ }elsif($ele->{'_'} eq $name){
+ $ret = $ele
}
}
- if(!$found && $name ne '@$' && exists $self->{$name}){
+ if(!$found && $name ne '@$' && $ref ne 'ARRAY' && exists $self->{$name}){
$ret = $self->{$name}
}else{
undef $ret if !$found
}
return !$ret?\@arr:$ret;
}
+##
+# Convinence method to find lastChild or all chidren by a certain name.
+##
+sub findChildrenByName {
+ my ($self, $name, $ret,@arr)=@_;
+ if($self->{'_'} eq $name){
+ return $self;
+ }
+ foreach my $child(@{$self->{'@$'}}){
+ my $find = $child -> findChildrenByName($name);
+ $arr[@arr] = $find if $find
+ }
+ if(@arr>1){
+ return \@arr;
+ }
+ return $arr[0];
+}
+
###
# Similar to find, put simpler node by path routine.
# Returns first node found based on path.
}
return $ret
}
+
+
+
###
# Outreached subs list of collected node links found in a property.
my @linked_subs;
}
return 0;
}
-
+###
+# Obtaine the full path of this node.
+###
+sub toPath {
+ my($self, @arr)= @_;
+ if(exists $self -> {'@'}){
+ return ${$self -> {'@'}} -> toPath() . '/'. $self->{_}
+ }
+ return $self -> {'_'}
+}
+###
+# Convert this node to CNF Script.
+###
sub toScript {
my($self,$nested,$script)= @_;
my($isParent,$tag,$tab); $nested=1 if!$nested; $tab =3*$nested; $tab = ' 'x$tab;
$script .= "$tab <@@<$_>@@>\n"
}
}
-
my $nodes = $self->{'@$'};
if($nodes){
foreach my $nd (@$nodes) {
$script .= toScript($nd, $nested+1);
}elsif ($ref eq 'ARRAY'){
foreach my $itm (@$nd) {
- $script .= toScript($itm, $nested+1);
+ $ref = ref($itm);
+ if ($ref eq 'CNFNode'){
+ $script .= toScript($itm, $nested+1);
+ }else{
+ foreach my $itm2 (@$itm) {
+ $script .= toScript($itm2, $nested+1);
+ }
+ }
}
}
}
}
sub SQL {
+ my $self = shift;
if(!$SQL){##It is late compiled package on demand.
- my $self = shift;
my $data = shift;
require CNFSQL; $SQL = CNFSQL->new({parser=>$self});
}
#!/usr/bin/env perl
-use warnings; use strict;
+use warnings; use strict; use v5.35;
use lib "tests";
use lib "system/modules";
$test -> nextCase();
#
- # #
+ $test -> case("Find path test for selecting children by certain name.");
+
+ $node -> process( CNFParser->new(),q(
+ <parent<
+ [has_div_children[
+ <div<
+ <#< One >#>
+ >div>
+ <div<
+ <#< Two >#>
+ >div>
+ <div<Three>div>
+ <div< Four >div>
+ ]has_div_children]
+ <div<
+ <div<
+ <div<
+ <text<Deeply Nested!>text>
+ >div>
+ <div<
+ <div<
+ <div<
+ <text<This Too!>text>
+ >div>
+ >div>
+ >div>
+ >div>
+ >div>
+ >parent>
+ ));
+
+ my $find = $node->find('/parent/has_div_children/@$');
+ $test -> isDefined("\@find[/parent/has_div_children/@@]",$find);
+ $test -> evaluate("\$find[0]"," One ",$find->[0]->val());
+ $test -> evaluate("\$find[0]"," Two ",$find->[1]->val());
+ $test -> evaluate("\$find[0]","Three",$find->[2]->val());
+ $test -> evaluate("\$find[0]"," Four ",$find->[3]->val());
+
+ $find = $node->find('/parent/div/*/text');
+ $test -> isZeroOrEqual("\$find",CNFNode::_isNode($find));
+ foreach(@$find){
+ my $path = $_->toPath();
+ say "<<$path<", $_->val(),">>>";
+ $test -> failed("Path:$path not recognise!")
+ if $path ne 'node/parent/div/div/div/text' &
+ $path ne 'node/parent/div/div/div/div/div/text'
+ }
+ $test -> evaluate("\$find[/parent/div/*/text]","Deeply Nested!",$find->[0]->val());
+ $test -> evaluate("\$find[/parent/div/*/text]","This Too!",$find->[1]->val());
+
+
+
+ #
+ $test -> nextCase();
+ #
+
+ #
$test->done();
#
}
catch{
$test -> dumpTermination($@);
- $test -> doneFailed();
+ $test->doneFailed();
}
#TODO Currently doesn't work with shortifes parsed nodes to return expected -> my $divs = $node->find("content/div/*");
my $content = $node->find('content/div');
my @divs = @{$content->{'@$'}};
- say scalar @divs;
- $test -> evaluate("Does [".$content->name()."] have 2 'div' child nodes?",2,scalar(@divs));
+ $test -> evaluate("Does [".$content->name()."] have 2 child nodes?",2,scalar(@divs));
#TODO Following not working at the moment:
+#say $node->toScript();
my $div1 = $node->find('content/div/div1');
- $test->failed('content/div/div1 not found!') if $test->isZeroOrEqual("div1",scalar(@{$div1}),0);
+ $test->failed('content/div/div1 not found!') if not $test->isDefined("div1",$div1);
+ $test->evaluate('content/div/div1[class] value matches?','paragraph',$div1->{class});
say $node->toScript();
###
$test->done();
--- /dev/null
+alefragnani.project-manager
+angular.ng-template
+awehook.vscode-blink-mind
+bianxianyang.htmlplay
+bibhasdn.git-easy
+bierner.markdown-mermaid
+bierner.markdown-preview-github-styles
+bpruitt-goddard.mermaid-markdown-syntax-highlighting
+bscan.perlnavigator
+codezombiech.gitignore
+conradludgate.rust-playground
+davidanson.vscode-markdownlint
+dbaeumer.vscode-eslint
+donjayamanne.git-extension-pack
+donjayamanne.githistory
+dustypomerleau.rust-syntax
+dzhavat.bracket-pair-toggler
+eamodio.gitlens
+ecmel.vscode-html-css
+esbenp.prettier-vscode
+felipecaputo.git-project-manager
+firefox-devtools.vscode-firefox-debug
+formulahendry.auto-rename-tag
+fractalboy.pls
+george-alisson.html-preview-vscode
+github.github-vscode-theme
+github.remotehub
+github.vscode-pull-request-github
+gruntfuggly.todo-tree
+harryhopkinson.vs-code-runner
+hediet.vscode-drawio
+howardzuo.vscode-git-tags
+irongeek.vscode-env
+james-yu.latex-workshop
+jeff-hykin.better-perl-syntax
+jorol.perl-completions
+letmaik.git-tree-compare
+mdickin.markdown-shortcuts
+mhutchie.git-graph
+mikestead.dotenv
+ms-azuretools.vscode-docker
+ms-edgedevtools.vscode-edge-devtools
+ms-python.debugpy
+ms-python.isort
+ms-python.python
+ms-python.vscode-pylance
+ms-toolsai.jupyter
+ms-toolsai.jupyter-keymap
+ms-toolsai.jupyter-renderers
+ms-toolsai.vscode-jupyter-cell-tags
+ms-toolsai.vscode-jupyter-slideshow
+ms-vscode-remote.remote-containers
+ms-vscode-remote.remote-ssh
+ms-vscode-remote.remote-ssh-edit
+ms-vscode.azure-repos
+ms-vscode.cpptools
+ms-vscode.live-server
+ms-vscode.makefile-tools
+ms-vscode.remote-explorer
+ms-vscode.remote-repositories
+ms-vscode.vscode-speech
+nopeslide.vscode-drawio-plugin-mermaid
+richterger.perl
+ritwickdey.liveserver
+rust-lang.rust-analyzer
+s2junn.git-essentials
+serayuzgur.crates
+shaharkazaz.git-merger
+smallcloud.codify
+solnurkarim.html-to-css-autocompletion
+streetsidesoftware.code-spell-checker
+swellaby.rust-pack
+tamasfe.even-better-toml
+thekalinga.bootstrap4-vscode
+thinker.properties
+valentjn.vscode-ltex
+wbudic.perlcnf
+xabikos.javascriptsnippets
+ziyasal.vscode-open-in-github