User:AnomieBOT/source/AnomieBOT/API/Iterator.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: OrphanReferenceFixer: * Fix log message AnomieBOT::Iterator: * Have the iterator ignore 'normalized' and 'redirects' nodes in the result. d::WikiProjectTagging: * When adding to a banner shell, make sure there is a CR befo
AnomieBOT (talk | contribs)
Updating published sources: General: * Remove pointless copyright notices with dates I never remember to update. * Add LICENSE.txt file instead.
 
(6 intermediate revisions by the same user not shown)
Line 1:
{{ombox|text=See [[/doc]] for formatted documentation}}
<sourcesyntaxhighlight lang="perl">
package AnomieBOT::API::Iterator;
 
Line 61:
}
 
my %res=exists($res->{'query'})?%{$res->{'query'}}:();
delete $res{'normalized'};
delete $res{'redirects'};
delete $res{'interwiki'};
my @res=values %res;
if(@res > 1){
Line 139 ⟶ 140:
 
Note that no API query is done on creation, and thus no result object is
current. C<< $iter->next >> must be called at least once before this function is
useful.
 
Line 149 ⟶ 150:
The return object is normally a hashref representing one page object, with an
additional property C<_ok_> set to a true value. If C<_ok_> is false, the
returned hashref is instead the error object as returned by C<< $api->query() >>.
C<< $api->query() >>. Calling C<< $iter->next >> again after an error will
retry the API query, which may or may not succeed.
may not succeed.
 
When no more results are available, undef is returned.
 
=back
 
=head1 COPYRIGHT
 
Copyright 2008 Anomie
 
This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
 
=cut
 
</syntaxhighlight>
</source>