From: Ian Jackson Date: Thu, 27 Aug 2009 14:51:11 +0000 (+0100) Subject: New masterinfoversion machinery; new masterinfoversion 2 for "nocommods", which elmin... X-Git-Tag: 3.4~81 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=commitdiff_plain;h=ab84a4347f797dda5c1ea7b9b0ac2d724e5f49cd New masterinfoversion machinery; new masterinfoversion 2 for "nocommods", which elminates Black dye --- diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index fa8e7bf..f4fb346 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -42,12 +42,14 @@ BEGIN { &pipethrough_run_along &pipethrough_run_finish &pipethrough_run_gzip &cgipostform &yarrgpostform &cgi_get_caller - &set_ctype_utf8); + &set_ctype_utf8 $masterinfoversion); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); } +our $masterinfoversion= 2; # version we understand + our %oceans; # eg $oceans{'Midnight'}{'Ruby'}{'Eta Island'}= $sources; our %clients; # eg $clients{'ypp-sc-tools'}= [ qw(last-page) ]; our %routes; # eg $routes{'Midnight'}{'Orca'}{'Tinga'}= $sources NB abbrevs! @@ -63,7 +65,7 @@ our %commods; 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 (@rawcm, @nocm); # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth' # IMPORTANT # when extending the format of source-info in a non-backward @@ -82,6 +84,8 @@ sub parse_info1 ($$) { @ctx= (sub { $colours{$colourkind}{lc $_} .= $src; }); } elsif (m/^commods$/) { @ctx= (sub { push @rawcm, lc $_; }); + } elsif (m/^nocommods$/) { + @ctx= (sub { push @nocm, lc $_; }); } elsif (m/^ocean (\w+)$/) { my $ocean= $1; @ctx= (sub { @@ -128,6 +132,7 @@ sub parse_info1 ($$) { my ($name, $props) = $s =~ /^(\S[^\t]*\S)(?:\t+(\S[^\t]*\S))?$/ or die "bad commodspec $s"; + return if grep { $name eq $_ } @nocm; my $ucname= ucfirst $name; $commods{$ucname}{Srcs} .= $ss; my $c= $commods{$ucname}; @@ -171,7 +176,7 @@ sub parse_info1 ($$) { sub parse_info_clientside () { my $yarrg= $ENV{'YPPSC_YARRG_DICT_UPDATE'}; return unless $yarrg; - my $master= fetch_with_rsync('info'); + my $master= fetch_with_rsync("info-$masterinfoversion"); parse_info1($master,'s'); my $local= '_local-info.txt'; if (stat $local) { diff --git a/yarrg/TODO b/yarrg/TODO index 1c158a0..f3e2cda 100644 --- a/yarrg/TODO +++ b/yarrg/TODO @@ -16,13 +16,12 @@ DATABASE/DICTIONARY MANAGER --------------------------- commodity mass/volume in live database + eliminate black dye from live database O N yppedia distance scraper finish O N yppedia distances support hints in master-info O N yppedia also cross-check arch/island pages - eliminate black dye - when update rejected print better error message including broken commodity name diff --git a/yarrg/source-info.txt b/yarrg/source-info.txt index 312e81c..1d68915 100644 --- a/yarrg/source-info.txt +++ b/yarrg/source-info.txt @@ -9,6 +9,9 @@ commods fine %c cloth 700g sail cloth 700g +nocommods + black dye + %c aqua black diff --git a/yarrg/update-master-info b/yarrg/update-master-info index 3aa9ac2..4c1547b 100755 --- a/yarrg/update-master-info +++ b/yarrg/update-master-info @@ -16,28 +16,34 @@ foreach my $oceanname (sort keys %oceans) { system('./db-idempotent-populate',$oceanname); die $? if $?; } -print STDERR "installing new master-info...\n"; - 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.*//; +foreach my $v (1..$masterinfoversion) { + my $dfnl= sprintf "master-info%s.txt", ($v>1 ? "-v$v" : ''); + print STDERR "installing new $dfnl...\n"; + + my $dfn= "$rsyncdir/$dfnl"; + 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.*//; + } + if ($v<2) { + next if $h =~ m/^nocommods/; + } + print $df $_, "\n" or die $!; } - print $df $_, "\n" or die $!; -} -$sf->error and die $!; -close $df or die $!; -rename "$dfn.tmp", "$dfn" or die $!; + $sf->error and die $!; + close $df or die $!; + rename "$dfn.tmp", "$dfn" or die $!; +}