Update for new ann html schema.
[utils.git] / anndata
CommitLineData
5364a3ac 1#!/usr/bin/perl -w
2
5364a3ac 3use Getopt::Long;
639d9800 4use Anime::ANN;
5364a3ac 5
639d9800 6GetOptions(\%options, ("l=s", "b=s"));
5364a3ac 7
8if($options{"l"}) {
639d9800 9 @list = Anime::ANN::getlist($options{"l"});
5364a3ac 10 foreach $name (@list) {
11 print "$name\n";
12 }
13 exit 0;
14}
15
639d9800 16if($options{"b"}) {
17 exec "htmlview", Anime::ANN::geturl(Anime::ANN::getid $options{"b"});
18}
19
20if(!defined($ARGV[0])) {
21 printf STDERR "usage: anndata NAME\n";
22 exit 1;
23}
24
25unless($id = Anime::ANN::getid $ARGV[0]) {
5364a3ac 26 printf STDERR "could not find $ARGV[0]\n";
27 exit 1;
28}
29
639d9800 30$info = Anime::ANN::getseries $id;
31
32sub refdump
33{
34 my($ref, $ind);
35 ($ref, $ind) = @_;
36 if(!defined($ind)) {
37 $ind = 0;
38 }
39
40 if(ref $ref eq "HASH") {
41 for $key (sort keys %{$ref}) {
42 print ((" " x $ind) . "$key: " . (" " x (20 - length $key)) . "(" . $ref->{$key} . ")\n");
43 refdump($ref->{$key}, $ind + 1) if ref $ref->{$key};
44 }
45 } elsif(ref $ref eq "ARRAY") {
46 for($i = 0; $i < @{$ref}; $i++) {
47 print ((" " x $ind) . "$i: " . $ref->[$i] . "\n");
48 refdump($ref->[$i], $ind + 1) if ref $ref->[$i];
49 }
50 } else {
51 print ((" " x $ind) . "Unknown ref: $ref\n");
52 }
53}
5364a3ac 54
639d9800 55binmode STDOUT, ":utf8";
56refdump $info;