script/moses-testing-parser.pl untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 52 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl -w
2 #
3 # Testing parser of BioMoby XML inputs.
4 #
5 # $Id: moses-testing-parser.pl,v 1.3 2008/02/21 00:12:55 kawas Exp $
6 # Contact: Martin Senger <martin.senger@gmail.com>
7 # -----------------------------------------------------------
8  
9 # some command-line options
10 use Getopt::Std;
11 use vars qw/ $opt_h $opt_d $opt_v $opt_n $opt_r $opt_b /;
12 getopt ('b');
13  
14 # usage
15 if ($opt_h or @ARGV == 0) {
16 print STDOUT <<'END_OF_USAGE';
17 Parsing of BioMoby XML inputs.
18 Usage: [-nrvd] [-b <input-name>:<known-type>] <XML-input-file>
19  
20 It also needs to get a location of a local cache (and potentially
21 a BioMoby registry endpoint). It takes it from the
22 'moby-service.cfg' configuration file.
23  
24 -b ... indicates a "backup" data type that is used when an
25 unknown XML top-level tag is encountered
26 (this is not usually needed at all - only when your
27 data type definitions, the generated data types, are
28 not up-to-date):
29  
30 Input data with article name <input-name>, if encoutered
31 an uknown type, will use <known-type>.
32  
33 -n ... does not print the parsed result (by default it does)
34 -r ... converts back (reverse) the parsed result into XML
35 and prints it
36 -v ... verbose
37 -d ... debug
38 -h ... help
39 END_OF_USAGE
40 exit (0);
41 }
42 # -----------------------------------------------------------
43  
44 use strict;
45  
46 use MOSES::MOBY::Base;
47 use MOSES::MOBY::Parser;
48  
49 $LOG->level ('INFO') if $opt_v;
50 $LOG->level ('DEBUG') if $opt_d;
51  
52 my @parser_args = ();
53 if ($opt_b) {
54 my ($input_name, $known_type) = split (/\s*:\s*/, $opt_b, 2);
55 push (@parser_args, ( lowestKnownDataTypes => { $input_name => $known_type }));
56 }
57 my $parser = new MOSES::MOBY::Parser (@parser_args);
58 my $package = $parser->parse ( method => 'file', data => $ARGV[0] );
59  
60 print $package unless $opt_n;
61 print $package->toXML->toString(1) if $opt_r;
62  
63 __END__