line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
2
|
|
|
2
|
|
157983
|
use warnings; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
65
|
|
4
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
5
|
|
|
|
|
|
|
use Class::Utils qw(set_params); |
6
|
2
|
|
|
2
|
|
958
|
use File::Spec::Functions qw(catfile); |
|
2
|
|
|
|
|
57856
|
|
|
2
|
|
|
|
|
44
|
|
7
|
2
|
|
|
2
|
|
1088
|
use IO::Barf qw(barf); |
|
2
|
|
|
|
|
1799
|
|
|
2
|
|
|
|
|
129
|
|
8
|
2
|
|
|
2
|
|
925
|
use JSON::XS qw(decode_json encode_json); |
|
2
|
|
|
|
|
1238
|
|
|
2
|
|
|
|
|
28
|
|
9
|
2
|
|
|
2
|
|
1499
|
use Perl6::Slurp qw(slurp); |
|
2
|
|
|
|
|
10530
|
|
|
2
|
|
|
|
|
122
|
|
10
|
2
|
|
|
2
|
|
1052
|
use Readonly; |
|
2
|
|
|
|
|
3159
|
|
|
2
|
|
|
|
|
14
|
|
11
|
2
|
|
|
2
|
|
80
|
use Wikibase::API; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
87
|
|
12
|
2
|
|
|
2
|
|
912
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
696
|
|
13
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(resolve); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.03; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my ($class, @params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
0
|
|
# Create object. |
20
|
|
|
|
|
|
|
my $self = bless {}, $class; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
# Login name. |
23
|
|
|
|
|
|
|
$self->{'login_name'} = undef; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
# Login password. |
26
|
|
|
|
|
|
|
$self->{'login_password'} = undef; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
# MediaWiki::API object. |
29
|
|
|
|
|
|
|
$self->{'mediawiki_api'} = MediaWiki::API->new; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
# MediaWiki site. |
32
|
|
|
|
|
|
|
$self->{'mediawiki_site'} = 'www.wikidata.org'; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
# Resolve directory. |
35
|
|
|
|
|
|
|
$self->{'resolve_dir'} = '/var/lib/wb_resolve'; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
# Process parameters. |
38
|
|
|
|
|
|
|
set_params($self, @params); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my ($self, $qid) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $qid_label; |
46
|
0
|
|
|
0
|
0
|
|
my $qid_file = catfile($self->{'resolve_dir'}, uc($qid)); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $struct_hr; |
49
|
0
|
|
|
|
|
|
if (-r $qid_file) { |
50
|
|
|
|
|
|
|
$struct_hr = decode_json(slurp($qid_file)); |
51
|
0
|
|
|
|
|
|
} else { |
52
|
0
|
0
|
|
|
|
|
$self->_lazy_api; |
53
|
0
|
|
|
|
|
|
$struct_hr = $self->{'api'}->get_item_raw($qid); |
54
|
|
|
|
|
|
|
barf($qid_file, encode_json($struct_hr)); |
55
|
0
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $item_obj = Wikibase::Datatype::Struct::Item::struct2obj($struct_hr); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $item_obj; |
60
|
0
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
if (defined $self->{'api'}) { |
65
|
|
|
|
|
|
|
return; |
66
|
0
|
|
|
0
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
$self->{'api'} = Wikibase::API->new( |
69
|
0
|
|
|
|
|
|
'mediawiki_api' => $self->{'mediawiki_api'}, |
70
|
|
|
|
|
|
|
'mediawiki_site' => $self->{'mediawiki_site'}, |
71
|
|
|
|
|
|
|
'login_name' => $self->{'login_name'}, |
72
|
|
|
|
|
|
|
'login_password' => $self->{'login_password'}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
return; |
76
|
0
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
0
|
|
|
|
|
|
|