my $warnings = 1;
my $dir = $RealBin;
my $dump = 0;
+my $dumpitem;
Getopt::Long::Configure(qw(gnu_getopt));
GetOptions(
'verbose|v+' => \$verbose,
'warnings|w!' => \$warnings,
'dir=s' => \$dir,
- 'dump' => \$dump
+ 'dump' => \$dump,
+ 'dumpitem|i=s' => \$dumpitem
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-exitval => 0, -verbose => 2) if $man;
# jump to subroutine which handles the job,
# depending on the options
+
&Main;
sub Main {
my @docs;
{
+ local $CWD = $db_dir;
my %filter;
foreach (@ARGV) {
$_ = "$_.xml" unless /\.xml$/;
$filter{$_} = 1;
}
my $num = scalar @ARGV;
- local $CWD = $db_dir;
while (<*.xml>) {
next if $num>0 and not defined $filter{$_};
my $doc = LoadXML($_);
#print Dumper($db->{'ReadoutFSM'});
#print Dumper($db->{'JtagErrorCount1'});
#print Dumper($db->{'JtagLastDataChanged'});
- #print Dumper($db->{'IdleTime'});
- #print DumpTree($db);
my $name = $doc->getDocumentElement->getAttribute('name');
+ if($dumpitem) {
+ my $item = $db->{$dumpitem};
+ next unless defined $item;
+ MyDumpTree($item,"$dumpitem (in entity $name)");
+ next;
+ }
+ #print DumpTree($db);
my $cachefile = "cache/$name.entity";
lock_store($db, $cachefile);
print STDERR "Wrote $cachefile\n" if $verbose>0;
print STDERR "\n",DumpTree($db,$name),"\n" if $verbose>2;
-
}
# recursively populate tree and print it
my $tree = {};
IterateChildren($tree, $doc->getDocumentElement, $entityAddr);
- print DumpTree($tree, $entityName,
+ MyDumpTree($tree, $entityName);
+}
+
+sub MyDumpTree {
+ print DumpTree(shift, shift,
USE_ASCII => 0, DISPLAY_OBJECT_TYPE => 0,
DISPLAY_ADDRESS => 0, NO_NO_ELEMENTS => 1);
-
}
sub IterateChildren {
xml-db.pl [entity names]
xml-db.pl --dump [entity names]
+xml-db.pl --dumpitem=<name> [entity names]
Options:
-h, --help brief help message
-w, --warnings print warnings to STDERR
--dir directory that contains database and schema subdirs
--dump dump the database as tree, restricted to given entity names
+ -i, --dumpitem dump a given named item as tree
=head1 OPTIONS
sub-directories database and schema. In the same directory the cache
will be created.
+=item B<--dump>
+
+Dump the Database.
+
+=item B<--dumpitem>
+
+Dump a given item (specify the unique name) to be found in the
+database of the given entities.
+
=back
=head1 DESCRIPTION
-B<This program> updates the cache directory from the provided XML
-files in the database directory (also validates them against the
-schema). You can restrict the files being worked by stating them as
-arguments, the extension .xml will be added for convenience.
+This program updates the cache directory from the provided XML files
+in the database directory (also validates them against the schema).
+You can restrict the files being worked by stating them as arguments,
+the extension .xml will be added for convenience.
=cut