chiark / gitweb /
master-info sanitiser. master-info is now renamed source-info
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 27 Aug 2009 14:20:25 +0000 (15:20 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 27 Aug 2009 14:23:36 +0000 (15:23 +0100)
yarrg/Commods.pm
yarrg/CommodsWeb.pm
yarrg/TODO
yarrg/db-idempotent-populate
yarrg/source-info.txt [moved from yarrg/master-info.txt with 100% similarity]
yarrg/update-master-info

index dff539d87166a7e3b7e114d6a0d9d68be6c0f06c..fa8e7bfc2078224658a7e902491e942aed0a6776 100644 (file)
@@ -65,6 +65,10 @@ our (%pctb_commodmap,@pctb_commodmap);
 my %colours; # eg $colours{'c'}{'black'}= $sources
 my @rawcm; # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth'
 
 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_info1 ($$) {
     my ($mmfn,$src)= @_;
     my $mm= new IO::File $mmfn, 'r' or die "$mmfn $!";
@@ -209,7 +213,7 @@ sub parse_info_maproutes ($$$) {
 }
 
 sub parse_info_serverside () {
 }
 
 sub parse_info_serverside () {
-    parse_info1('master-info.txt','s');
+    parse_info1('source-info.txt','s');
 }
 sub parse_info_serverside_ocean ($) {
     my ($oceanname) = @_;
 }
 sub parse_info_serverside_ocean ($) {
     my ($oceanname) = @_;
index 3ad8590fa9313cab26b1b7e225d745a146193e94..198185d32df4f1855fd4ca691d809b482f91bf04 100644 (file)
@@ -91,7 +91,7 @@ my @ocean_list;
 sub ocean_list () {
     my $datadir= datadir();
     if (!@ocean_list) {
 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>) {
        my $f= new IO::File $fn or die "$fn $!";
        my @r;
        while (<$f>) {
index 938ae3db81a706c9311c3eccaac2e2865abebf1d..1c158a0365446b278f94683fe36dc28d5de3c5a2 100644 (file)
@@ -15,9 +15,6 @@ P C   pager scrollbar distance moved check
 DATABASE/DICTIONARY MANAGER
 ---------------------------
 
 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
        commodity mass/volume in live database
 
 O N    yppedia distance scraper finish
@@ -29,6 +26,8 @@ O N   yppedia also cross-check arch/island pages
        when update rejected print better error message including
         broken commodity name
 
        when update rejected print better error message including
         broken commodity name
 
+       notice commodities deleted from source-info and warn about them
+
 
 WEBSITE
 -------
 
 WEBSITE
 -------
index 9d7bab06a426193a15ed073473d6fb85a0bee203..b44d45dd25cc7d63c435059c521bfc0b84a36800 100755 (executable)
@@ -1,5 +1,8 @@
 #!/usr/bin/perl -w
 #
 #!/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
 # usage: ./db-idempotent-populate <Oceanname>
 #  creates or updates OCEAN-Oceanname.db
 #  from master-master.txt
similarity index 100%
rename from yarrg/master-info.txt
rename to yarrg/source-info.txt
index a52b212366ab635becd16399a26baf5ae3cde1b7..3aa9ac2d802fd8508d0e8f5ab43f0730d383d855 100755 (executable)
@@ -17,6 +17,27 @@ foreach my $oceanname (sort keys %oceans) {
 }
 
 print STDERR "installing new master-info...\n";
 }
 
 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 $!;