X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=script%2Fsave_to_db.pl;h=497c7231e204009b67c2ac5cad1991c2f4bde395;hb=b74d89f9e926466ba4ded77746fd0f98912cc17a;hp=45ebb17a5e4efc0ca2815c41c32f95ed1710fd1d;hpb=3837c155d39333869a93adf1e8375960ffbf3a92;p=scpubgit%2Fstemmatology.git diff --git a/script/save_to_db.pl b/script/save_to_db.pl index 45ebb17..497c723 100644 --- a/script/save_to_db.pl +++ b/script/save_to_db.pl @@ -36,24 +36,27 @@ if( $dir ) { opendir( DIR, $dir ) or die "Could not open directory $dir"; while( readdir DIR ) { next unless /\.xml$/; - my $stemmafile = "$dir/" . $stemma_map{$_}; + print STDERR "Looking at $_\n"; my $tradition = Text::Tradition->new( 'input' => 'Self', 'file' => "$dir/$_", 'linear' => 1, ); - open my $stemma_fh, '<', $stemmafile or die "Could not read stemma file $stemmafile"; - my $stemma = Text::Tradition::Stemma->new( - 'collation' => $tradition->collation, - 'dot' => $stemma_fh, - ); + my $stemma; + if( exists $stemma_map{$_} ) { + my $stemmafile = "$dir/" . $stemma_map{$_}; + open my $stemma_fh, '<', $stemmafile or die "Could not read stemma file $stemmafile"; + $stemma = Text::Tradition::Stemma->new( + 'collation' => $tradition->collation, + 'dot' => $stemma_fh, + ); + } my $scope = $kdb->new_scope; my $tid = $kdb->store( $tradition ); - my $sid = $kdb->store( $stemma ); - - print STDERR "Stored tradition and stemma for " . $tradition->name - . ", got $tid / $sid as the ref\n"; + my $sid = $kdb->store( $stemma ) if $stemma; + print STDERR "Stored tradition for " . $tradition->name . " at $tid\n"; + print STDERR "\tand stemma at $sid\n" if $stemma; } }