From: Tara L Andrews Date: Thu, 19 Apr 2012 13:42:44 +0000 (+0200) Subject: add -from and -to options; TODO rationalize these across outputs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd7014c4732ae63f493ba3563a706aa88f88e174;p=scpubgit%2Fstemmatology.git add -from and -to options; TODO rationalize these across outputs --- diff --git a/script/make_tradition.pl b/script/make_tradition.pl index d1af8bf..97e8145 100755 --- a/script/make_tradition.pl +++ b/script/make_tradition.pl @@ -14,9 +14,9 @@ binmode STDOUT, ":utf8"; eval { no warnings; binmode $DB::OUT, ":utf8"; }; my( $informat, $inbase, $outformat, $help, $language, $name, $sep, $stemmafile, - $dsn, $dbuser, $dbpass ) + $dsn, $dbuser, $dbpass, $from, $to ) = ( '', '', '', '', 'Default', 'Tradition', "\t", '', - "dbi:SQLite:dbname=stemmaweb/db/traditions.db", undef, undef ); + "dbi:SQLite:dbname=stemmaweb/db/traditions.db", undef, undef, undef, undef ); GetOptions( 'i|in=s' => \$informat, 'b|base=s' => \$inbase, @@ -27,6 +27,8 @@ GetOptions( 'i|in=s' => \$informat, 's|stemma=s' => \$stemmafile, 'u|user=s' => \$dbuser, 'p|pass=s' => \$dbpass, + 'f|from=s' => \$from, + 't|to=s' => \$to, 'sep=s' => \$sep, 'dsn=s' => \$dsn, ); @@ -50,6 +52,11 @@ unless( $outformat =~ /^(graphml|svg|dot|stemma|csv|db)$/ ) { help( "Output format must be one of db, graphml, svg, csv, stemma, or dot" ); } +if( $from || $to ) { + help( "Subgraphs only supported in GraphML format" ) + unless $outformat eq 'graphml'; +} + # Do we have a base if we need it? if( $informat =~ /^(KUL|CollateText)$/ && !$inbase ) { help( "$informat input needs a base text" ); @@ -95,7 +102,10 @@ if( $outformat eq 'stemma' ) { print STDERR "Saved tradition to database with ID $uuid\n"; } else { my $output = "as_$outformat"; - print $tradition->collation->$output(); + my $opts = {}; + $opts->{'from'} = $from if $from; + $opts->{'to'} = $to if $to; + print $tradition->collation->$output( $opts ); } sub help {