Document bufrTemplate key on the wiki ECC-187

This commit is contained in:
Sandor Kertesz 2015-11-16 10:49:20 +00:00
parent c92634105b
commit 9d631edd7a
2 changed files with 126 additions and 2 deletions

View File

@ -8,8 +8,6 @@ our $confSpace="ECC";
my $CONF=$ENV{CONF};
die "Env var CONF should point to confluence.sh script" if ( $CONF eq "" || ! -f "$CONF" );
our $confSpace="ECC";
#====================================================
#
# Generic functions related to confluence

126
confluence/load_templates.pl Executable file
View File

@ -0,0 +1,126 @@
#!/usr/local/apps/perl/current/bin/perl -I/usr/local/lib/metaps/perl -I.
use confUtils;
use Getopt::Long;
use strict;
my %res=();
#The confluence space
my $confSpace="ECC";
#---------------------------------
# Read arguments
#---------------------------------
GetOptions("confSpace=s" => \$confUtils::confSpace)
or die("Error in command line arguments\n");
print "confluence space=".$confUtils::confSpace."\n";
#----------------------------------
# Dirs
#----------------------------------
#The root dir of the examples
my $inFile="../definitions/bufr/templates/BufrTemplate.def";
#The genareted html files are stored here
my $htmlDir=$ENV{TMPDIR}."/res_html";
#--------------------------------------------------
# The confluence pages
#--------------------------------------------------
#The root page of templates in confluence!!!
my $pageTitle="BUFR templates";
my $parentPage="Internal";
#----------------------------------------
# Preparations
#----------------------------------------
unless ( -d $htmlDir ) {
mkdir $htmlDir
}
#---------------------------------------------------
# Read the templates file
#---------------------------------------------------
read_templates();
#---------------------------------------------------
# Generate confluence tabel
#---------------------------------------------------
my $fOut=$htmlDir."/bufr_templates.html";
open(OUT,">$fOut") or die "$fOut: $!";
my $header="Teplate name</th><th>Unexpanded descriptors</th>";
print OUT "<table><tbody>"."\n";
print OUT "<tr><th>Teplate name</th><th>Unexpanded descriptors</th></tr>\n";
foreach my $name (sort {$a cmp $b} keys %res) {
#Get the examples
my @desc=$res{$name};
print OUT "<tr><td>$name</td><td>".$res{$name}."</td></tr>\n";
print "$name--> $res{$name}\n";
}
print OUT "</tbody></table>"."\n";
close(OUT);
#Upload to confluence
confUtils::loadToConf($fOut,$pageTitle,$parentPage);
#==========================================================
#===========================================================
#
# FUNCTIONS
#
#===========================================================
#===========================================================
sub read_templates {
#my %res=();
my $fIn=$inFile;
open(IN,"<$fIn") or die "$fIn: $!";
my $line;
my $actType;
while (defined ($line = <IN>)) {
chomp($line);
if ($line =~ /.*#/) {next;}
#print $line."\n";
$line =~ s/\s+//g;
#print $line."\n";
my @desc;
my ($a,$b)=($line =~ /\"(\S+)\"=\{unexpandedDescriptors=(\S+);\}/);
unless ($a) {next;}
$res{$a}=$b;
my ($c) = ($b =~ /\[(\S+)\]/);
if($c) {
$res{$a}=$c;
}
#print " ".$res{$a}."\n";
}
close(IN);
}