line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Print::MediainfoSnak; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
892443
|
use base qw(Exporter); |
|
9
|
|
|
|
|
86
|
|
|
9
|
|
|
|
|
1131
|
|
4
|
9
|
|
|
9
|
|
62
|
use strict; |
|
9
|
|
|
|
|
46
|
|
|
9
|
|
|
|
|
203
|
|
5
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
313
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
977
|
use Error::Pure qw(err); |
|
9
|
|
|
|
|
22567
|
|
|
9
|
|
|
|
|
303
|
|
8
|
9
|
|
|
9
|
|
174
|
use Readonly; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
395
|
|
9
|
9
|
|
|
9
|
|
1494
|
use Wikibase::Datatype::Print::Value; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
2434
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(print); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.13; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub print { |
16
|
8
|
|
|
8
|
1
|
8202
|
my ($obj, $opts_hr) = @_; |
17
|
|
|
|
|
|
|
|
18
|
8
|
100
|
|
|
|
47
|
if (! $obj->isa('Wikibase::Datatype::MediainfoSnak')) { |
19
|
1
|
|
|
|
|
5
|
err "Object isn't 'Wikibase::Datatype::MediainfoSnak'."; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
7
|
|
|
|
|
16
|
my $property_name = ''; |
23
|
7
|
100
|
|
|
|
30
|
if (exists $opts_hr->{'cache'}) { |
24
|
1
|
|
|
|
|
26
|
$property_name = $opts_hr->{'cache'}->get('label', $obj->property); |
25
|
1
|
50
|
|
|
|
79
|
if (defined $property_name) { |
26
|
1
|
|
|
|
|
5
|
$property_name = " ($property_name)"; |
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
0
|
$property_name = ''; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
42
|
my $ret = $obj->property.$property_name.': '; |
33
|
7
|
100
|
|
|
|
79
|
if ($obj->snaktype eq 'value') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
34
|
4
|
|
|
|
|
62
|
$ret .= Wikibase::Datatype::Print::Value::print($obj->datavalue, $opts_hr); |
35
|
|
|
|
|
|
|
} elsif ($obj->snaktype eq 'novalue') { |
36
|
1
|
|
|
|
|
14
|
$ret .= 'no value'; |
37
|
|
|
|
|
|
|
} elsif ($obj->snaktype eq 'somevalue') { |
38
|
1
|
|
|
|
|
21
|
$ret .= 'unknown value'; |
39
|
|
|
|
|
|
|
} else { |
40
|
1
|
|
|
|
|
17
|
err 'Bad snaktype.', |
41
|
|
|
|
|
|
|
'snaktype', $obj->snaktype, |
42
|
|
|
|
|
|
|
; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
30
|
return $ret; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=encoding utf8 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Wikibase::Datatype::Print::MediainfoSnak - Wikibase mediainfo snak pretty print helpers. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::MediainfoSnak qw(print); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
65
|
|
|
|
|
|
|
my @pretty_print_lines = print($obj, $opts_hr); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SUBROUTINES |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 C<print> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
72
|
|
|
|
|
|
|
my @pretty_print_lines = print($obj, $opts_hr); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Construct pretty print output for L<Wikibase::Datatype::MediainfoSnak> |
75
|
|
|
|
|
|
|
object. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Returns string in scalar context. |
78
|
|
|
|
|
|
|
Returns list of lines in array context. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 ERRORS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
print(): |
83
|
|
|
|
|
|
|
Object isn't 'Wikibase::Datatype::MediainfoSnak'. |
84
|
|
|
|
|
|
|
Bad snaktype. |
85
|
|
|
|
|
|
|
snaktype: %s |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=for comment filename=create_and_print_mediainfo_snak.pl |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use strict; |
92
|
|
|
|
|
|
|
use warnings; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::MediainfoSnak; |
95
|
|
|
|
|
|
|
use Wikibase::Datatype::MediainfoSnak; |
96
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Object. |
99
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::MediainfoSnak->new( |
100
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
101
|
|
|
|
|
|
|
'value' => 'Q5', |
102
|
|
|
|
|
|
|
), |
103
|
|
|
|
|
|
|
'property' => 'P31', |
104
|
|
|
|
|
|
|
); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Print. |
107
|
|
|
|
|
|
|
print Wikibase::Datatype::Print::MediainfoSnak::print($obj)."\n"; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Output: |
110
|
|
|
|
|
|
|
# P31: Q5 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=for comment filename=create_and_print_mediainfo_snak_translated.pl |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use strict; |
117
|
|
|
|
|
|
|
use warnings; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
use Wikibase::Cache; |
120
|
|
|
|
|
|
|
use Wikibase::Cache::Backend::Basic; |
121
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::MediainfoSnak; |
122
|
|
|
|
|
|
|
use Wikibase::Datatype::MediainfoSnak; |
123
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# Object. |
126
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::MediainfoSnak->new( |
127
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
128
|
|
|
|
|
|
|
'value' => 'Q5', |
129
|
|
|
|
|
|
|
), |
130
|
|
|
|
|
|
|
'property' => 'P31', |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Cache. |
134
|
|
|
|
|
|
|
my $cache = Wikibase::Cache->new( |
135
|
|
|
|
|
|
|
'backend' => 'Basic', |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# Print. |
139
|
|
|
|
|
|
|
print Wikibase::Datatype::Print::MediainfoSnak::print($obj, { |
140
|
|
|
|
|
|
|
'cache' => $cache, |
141
|
|
|
|
|
|
|
})."\n"; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# Output: |
144
|
|
|
|
|
|
|
# P31 (instance of): Q5 |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L<Error::Pure>, |
149
|
|
|
|
|
|
|
L<Exporter>, |
150
|
|
|
|
|
|
|
L<Readonly>, |
151
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value>. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SEE ALSO |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::MediainfoSnak> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Wikibase mediainfo snak datatype. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 REPOSITORY |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Print> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHOR |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L<http://skim.cz> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
BSD 2-Clause License |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 VERSION |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
0.13 |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|