-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck-org.pl
More file actions
executable file
·79 lines (63 loc) · 1.52 KB
/
check-org.pl
File metadata and controls
executable file
·79 lines (63 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env perl
use Getopt::Long qw/GetOptions/;
use Pod::Usage qw/pod2usage/;
use Gcis::Client;
use Data::Dumper;
use YAML::XS qw/Dump Load/;
use Org;
use strict;
use v5.14;
my $n_max = -1;
# my $url = qq(https://data.gcis-dev-front.joss.ucar.edu);
my $url = qq(https://data-stage.globalchange.gov);
# my $url = qq(http://data.globalchange.gov);
&main;
sub main {
my $g = Gcis::Client->new(url => $url);
my $o = Org->new($g);
my $r = load_list();
my @d;
my $i = 0;
for (sort keys %$r) {
$i++;
last if $n_max > 1 && $i > $n_max;
my $b = $r->{$_};
my $v = $o->uri($_);
my $w;
$w = "no uri : ".($o->strip($_)) unless $v;
if ($v && $b) {
my $b1 = $o->bureau($v);
if (!$b1) {
$w = "no bureau code";
} elsif ($b ne $b1) {
$w = "bureau code different : $b1";
}
}
my %s;
$s{name} = $_;
$s{bureau} = $b if $b;
$s{uri} = $v if $v;
$s{warning} = $w if $w;
push @d, \%s;
}
say Dump(\@d);
}
sub load_list {
my $yml = do { local $/; <> };
my $e = Load($yml);
my %r;
for (@$e) {
# say " e :\n".Dumper($_);
$a = $_->{_poc_org};
$a =~ s/^'+//;
$a =~ s/'+$//;
$a =~ s/^\s+//;
$a =~ s/\s+$//;
$r{$a} = undef;
$b = $_->{_ckan}->{bureauCode} or next;
$b =~ s/^\s+//;
$b =~ s/\s+$//;
$r{$a} = $b;
}
return \%r;
}