line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Slackware::Slackget::PackageList; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
87
|
|
4
|
3
|
|
|
3
|
|
9
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1433
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Slackware::Slackget::Package; |
7
|
|
|
|
|
|
|
require Slackware::Slackget::List ; |
8
|
|
|
|
|
|
|
require Slackware::Slackget::Date ; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Slackware::Slackget::PackageList - This class is a container of Slackware::Slackget::Package object |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 1.0.0 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
21
|
|
|
|
|
|
|
our @ISA = qw( Slackware::Slackget::List ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This class is a container of Slackware::Slackget::Package object, and allow you to perform some operations on this packages list. As the Package's list class, it is a slack-get's internal representation of data. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use Slackware::Slackget::PackageList; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $packagelist = Slackware::Slackget::PackageList->new(); |
30
|
|
|
|
|
|
|
$packagelist->add($package); |
31
|
|
|
|
|
|
|
$packagelist->get($index); |
32
|
|
|
|
|
|
|
my $package = $packagelist->Shift(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 new |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This class constructor don't take any parameters to works properly, but you can eventually disable the root tag <packagelist> by using 'no-root-tag' => 1, and modify the default encoding (utf8) by passing an 'encoding' => <your encoding> parameter. Thoses options are only related to the export functions. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $PackageList = new Slackware::Slackget::PackageList (); |
42
|
|
|
|
|
|
|
my $PackageList = new Slackware::Slackget::PackageList ('no-root-tag' => 1); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
1
|
|
my ($class,%args) = @_ ; |
49
|
0
|
|
|
|
|
|
my $encoding = 'utf8'; |
50
|
0
|
0
|
0
|
|
|
|
if(defined($args{'encoding'}) && $args{'encoding'} !~ /^\s*$/) |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
|
|
|
$encoding = $args{'encoding'} ; |
53
|
0
|
|
|
|
|
|
delete($args{'encoding'}) ; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
my $self={list_type => 'Slackware::Slackget::Package','root-tag' => 'package-list',ENCODING => $encoding}; |
56
|
0
|
|
|
|
|
|
foreach (keys(%args)) |
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
|
|
|
$self->{$_} = $args{$_}; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
bless($self,$class); |
61
|
0
|
|
|
|
|
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 FUNCTIONS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This class inheritate from Slackware::Slackget::List (L<Slackware::Slackget::List>), so you may want read the Slackware::Slackget::List documentation for the supported methods of this class. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 fill_from_xml |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Fill the Slackware::Slackget::PackageList from the XML data passed as argument. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$packagelist->fill_from_xml( |
75
|
|
|
|
|
|
|
'<choice action="installpkg"> |
76
|
|
|
|
|
|
|
<package id="gcc-objc-3.3.4-i486-1"> |
77
|
|
|
|
|
|
|
<date hour="12:32:00" day-number="12" month-number="06" year="2004" /> |
78
|
|
|
|
|
|
|
<compressed-size>1395</compressed-size> |
79
|
|
|
|
|
|
|
<location>./slackware/d</location> |
80
|
|
|
|
|
|
|
<package-source>slackware</package-source> |
81
|
|
|
|
|
|
|
<version>3.3.4</version> |
82
|
|
|
|
|
|
|
<name>gcc-objc</name> |
83
|
|
|
|
|
|
|
<uncompressed-size>3250</uncompressed-size> |
84
|
|
|
|
|
|
|
<description>gcc-objc (Objective-C support for GCC) |
85
|
|
|
|
|
|
|
Objective-C support for the GNU Compiler Collection. |
86
|
|
|
|
|
|
|
This package contains those parts of the compiler collection needed to |
87
|
|
|
|
|
|
|
compile code written in Objective-C. Objective-C was originally |
88
|
|
|
|
|
|
|
developed to add object-oriented extensions to the C language, and is |
89
|
|
|
|
|
|
|
best known as the native language of the NeXT computer. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
</description> |
92
|
|
|
|
|
|
|
<signature-checksum>565a10ce130b4287acf188a6c303a1a4</signature-checksum> |
93
|
|
|
|
|
|
|
<checksum>23bae31e3ffde5e7f44617bbdc7eb860</checksum> |
94
|
|
|
|
|
|
|
<architecture>i486</architecture> |
95
|
|
|
|
|
|
|
<package-location>slackware/d/</package-location> |
96
|
|
|
|
|
|
|
<package-version>1</package-version> |
97
|
|
|
|
|
|
|
<referer>gcc-objc</referer> |
98
|
|
|
|
|
|
|
</package> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
<package id="gcc-objc-3.4.3-i486-1"> |
101
|
|
|
|
|
|
|
<date hour="18:24:00" day-number="21" month-number="12" year="2004" /> |
102
|
|
|
|
|
|
|
<compressed-size>1589</compressed-size> |
103
|
|
|
|
|
|
|
<package-source>slackware</package-source> |
104
|
|
|
|
|
|
|
<version>3.4.3</version> |
105
|
|
|
|
|
|
|
<name>gcc-objc</name> |
106
|
|
|
|
|
|
|
<signature-checksum>1027468ed0d63fcdd584f74d2696bf99</signature-checksum> |
107
|
|
|
|
|
|
|
<architecture>i486</architecture> |
108
|
|
|
|
|
|
|
<checksum>5e659a567d944d6824f423d65e4f940f</checksum> |
109
|
|
|
|
|
|
|
<package-location>testing/packages/gcc-3.4.3/</package-location> |
110
|
|
|
|
|
|
|
<package-version>1</package-version> |
111
|
|
|
|
|
|
|
<referer>gcc-objc</referer> |
112
|
|
|
|
|
|
|
</package> |
113
|
|
|
|
|
|
|
</choice>' |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub fill_from_xml |
119
|
|
|
|
|
|
|
{ |
120
|
0
|
|
|
0
|
1
|
|
my ($self,@xml) = @_ ; |
121
|
0
|
|
|
|
|
|
my $xml = ''; |
122
|
0
|
|
|
|
|
|
foreach (@xml) |
123
|
|
|
|
|
|
|
{ |
124
|
0
|
|
|
|
|
|
$xml .= $_ ; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
|
require XML::Simple ; |
127
|
0
|
|
|
|
|
|
$XML::Simple::PREFERRED_PARSER='XML::Parser' ; |
128
|
0
|
|
|
|
|
|
my $xml_in = XML::Simple::XMLin($xml,KeyAttr => {'package' => 'id'}); |
129
|
|
|
|
|
|
|
# use Data::Dumper ; |
130
|
|
|
|
|
|
|
# print Data::Dumper::Dumper($xml_in); |
131
|
0
|
|
|
|
|
|
foreach my $pack_name (keys(%{$xml_in->{'package'}})){ |
|
0
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $package = new Slackware::Slackget::Package ($pack_name); |
133
|
0
|
|
|
|
|
|
foreach my $key (keys(%{$xml_in->{'package'}->{$pack_name}})){ |
|
0
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
if($key eq 'date') |
135
|
|
|
|
|
|
|
{ |
136
|
0
|
|
|
|
|
|
$package->setValue($key,Slackware::Slackget::Date->new(%{$xml_in->{'package'}->{$pack_name}->{$key}})); |
|
0
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
else |
139
|
|
|
|
|
|
|
{ |
140
|
0
|
|
|
|
|
|
$package->setValue($key,$xml_in->{'package'}->{$pack_name}->{$key}) ; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
} |
144
|
0
|
|
|
|
|
|
$self->add($package); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 Sort |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Apply the Perl built-in function sort() on the PackageList. This method return nothing. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
$list->Sort() ; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub Sort |
157
|
|
|
|
|
|
|
{ |
158
|
0
|
|
|
0
|
1
|
|
my $self = shift ; |
159
|
0
|
|
|
|
|
|
$self->{LIST} = [ sort {$a->{ROOT} cmp $b->{ROOT} } @{ $self->{LIST} } ] ; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 index_list |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Create an index on the PackageList. This index don't take many memory but speed a lot search, especially when you already have the package id ! |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The index is build with the Package ID. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub index_list |
171
|
|
|
|
|
|
|
{ |
172
|
0
|
|
|
0
|
1
|
|
my $self = shift ; |
173
|
0
|
|
|
|
|
|
$self->{INDEX} = {} ; |
174
|
0
|
|
|
|
|
|
foreach my $pkg (@{$self->{LIST}}) |
|
0
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
{ |
176
|
|
|
|
|
|
|
# print "[Slackware::Slackget::PackageList] indexing package: ",$pkg->get_id(),"\n"; |
177
|
0
|
|
|
|
|
|
$self->{INDEX}->{$pkg->get_id()} = $pkg ; |
178
|
|
|
|
|
|
|
} |
179
|
0
|
|
|
|
|
|
return 1; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 get_indexed |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Return a package, as well as Get() do but use the index to return it quickly. You must provide a package ID to this method. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
my $pkg = $list->get_indexed($qlistviewitem->text(5)) ; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub get_indexed |
191
|
|
|
|
|
|
|
{ |
192
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_ ; |
193
|
0
|
|
|
|
|
|
return $self->{INDEX}->{$id} ; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 get_indexes |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Return the list of all indexes |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
my @indexes = $list->get_indexes() ; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub get_indexes |
205
|
|
|
|
|
|
|
{ |
206
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_ ; |
207
|
0
|
|
|
|
|
|
return keys(%{$self->{INDEX}}) ; |
|
0
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 AUTHOR |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 BUGS |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
219
|
|
|
|
|
|
|
C<bug-slackget10@rt.cpan.org>, or through the web interface at |
220
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=slackget10>. |
221
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
222
|
|
|
|
|
|
|
your bug as I make changes. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 BUGS |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
227
|
|
|
|
|
|
|
C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at |
228
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>. |
229
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
230
|
|
|
|
|
|
|
your bug as I make changes. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 SUPPORT |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
perldoc Slackware::Slackget |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
You can also look for information at: |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over 4 |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * Infinity Perl website |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
L<http://www.infinityperl.org/category/slack-get> |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * slack-get specific website |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
L<http://slackget.infinityperl.org> |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget> |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Slackware-Slackget> |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item * CPAN Ratings |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Slackware-Slackget> |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item * Search CPAN |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Slackware-Slackget> |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 SEE ALSO |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Copyright 2005 DUPUIS Arnaud, All Rights Reserved. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
280
|
|
|
|
|
|
|
under the same terms as Perl itself. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
1; # End of Slackware::Slackget::PackageList |