my %colours; # eg $colours{'c'}{'black'}= $sources
my @rawcm; # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth'
+# IMPORTANT
+# when extending the format of source-info in a non-backward
+# compatible way, be sure to update update-master-info too.
+
sub parse_info1 ($$) {
my ($mmfn,$src)= @_;
my $mm= new IO::File $mmfn, 'r' or die "$mmfn $!";
}
sub parse_info_serverside () {
- parse_info1('master-info.txt','s');
+ parse_info1('source-info.txt','s');
}
sub parse_info_serverside_ocean ($) {
my ($oceanname) = @_;
sub ocean_list () {
my $datadir= datadir();
if (!@ocean_list) {
- my $fn= "$datadir/master-info.txt";
+ my $fn= "$datadir/source-info.txt";
my $f= new IO::File $fn or die "$fn $!";
my @r;
while (<$f>) {
DATABASE/DICTIONARY MANAGER
---------------------------
-P N master-info sanitiser (new master-info with distances hints etc. is
- no good for old clients and clients don't need all that stuff anyway)
-
commodity mass/volume in live database
O N yppedia distance scraper finish
when update rejected print better error message including
broken commodity name
+ notice commodities deleted from source-info and warn about them
+
WEBSITE
-------
#!/usr/bin/perl -w
#
+# Normally run from
+# update-master-info
+#
# usage: ./db-idempotent-populate <Oceanname>
# creates or updates OCEAN-Oceanname.db
# from master-master.txt
}
print STDERR "installing new master-info...\n";
-my $df= "$rsyncdir/master-info.txt";
-system('cp','--','master-info.txt',"$df.tmp"); die $? if $?;
-system('mv','--',"$df.tmp",$df); die $? if $?
+
+my $sfn= 'source-info.txt';
+my $dfn= "$rsyncdir/master-info.txt";
+
+my $sf= new IO::File $sfn or die "$sfn $!";
+my $df= new IO::File "$dfn.tmp", 'w' or die "$dfn.tmp $!";
+
+my $h;
+while (<$sf>) {
+ chomp; s/\s+$//;
+ next if m/^\s*\#/ || !m/\S/;
+ if (m/^\S.*/) {
+ $h= $&;
+ }
+ die "$_ ?" unless defined $h;
+ if ($h =~ m/^commods|^\%[a-z]\b/) {
+ s/\t.*//;
+ }
+ print $df $_, "\n" or die $!;
+}
+
+$sf->error and die $!;
+close $df or die $!;
+rename "$dfn.tmp", "$dfn" or die $!;