X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=pctb%2FCommods.pm;h=d59529b0a6b1eb0121d3761e45a5a34c42686993;hp=dee9fbed5ab45368da33416d9bf2fe20812b381c;hb=3ff1e35cbf0515fbc42a43476e7c8ec1834e8db6;hpb=38e3d1bf1be975c8edd6a166106ab2729d15249c diff --git a/pctb/Commods.pm b/pctb/Commods.pm index dee9fbe..d59529b 100644 --- a/pctb/Commods.pm +++ b/pctb/Commods.pm @@ -1,5 +1,6 @@ package Commods; +use IO::File; use strict; use warnings; @@ -9,17 +10,21 @@ BEGIN { our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); - @EXPORT = qw(%oceans %commods &parse_masters); + @EXPORT = qw(&parse_masters %oceans %commods %clients + &parse_pctb_commodmap %pctb_commodmap @pctb_commodmap); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); } -our %oceans; # eg $oceans{'Midnight'}{'Ruby'}{'Eta Island'}= $sources +our %oceans; # eg $oceans{'Midnight'}{'Ruby'}{'Eta Island'}= $sources; our %commods; # eg $commods{'Fine black cloth'}= $sources; +our %clients; # eg $clients{'ypp-sc-tools'}= [ qw(last-page) ]; # $sources = 's[l]b'; # 's' = Special Circumstances; 'l' = local ; B = with Bleach +our (%pctb_commodmap,@pctb_commodmap); + my %colours; # eg $colours{'c'}{'black'}= $sources my @rawcm; # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth' @@ -46,6 +51,13 @@ sub parse_master_master1 ($$) { $oceans{$ocean}{$arch}{$_} .= $src; }; }); + } elsif (m/^client (\S+)$/) { + my $client= $1; + $clients{$client}= [ ]; + @ctx= (sub { + my $bug= $_; + push @{ $clients{$client} }, $bug; + }); } elsif (s/^ +//) { my $indent= length $&; die "wrong indent $indent" unless defined $ctx[$indent-1]; @@ -78,4 +90,22 @@ sub parse_masters () { parse_master_master1('master-master.txt','s'); } +sub parse_pctb_commodmap () { + undef %pctb_commodmap; + foreach my $commod (keys %commods) { $commods{$commod} =~ s/b//; } + + my $c= new IO::File '_commodmap.tsv' or die $!; + if (!$c) { $!==&ENOENT or die $!; return 0; } + + while (<$c>) { + m/^(\S.*\S)\t(\d+)\n$/ or die "$_"; + die if defined $pctb_commodmap{$1}; $pctb_commodmap{$1}= $2; + die if defined $pctb_commodmap[$2]; $pctb_commodmap[$2]= $1; + $commods{$1} .= 'b'; + } + $c->error and die $!; + close $c or die $!; + return 1; +} + 1;