From: dondelelcaro Date: Mon, 15 Sep 2008 18:40:31 +0000 (+0000) Subject: * totally replace do_id with the copy from DebianBugs.pl X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=4e78a5f8f967fd12cca3856f54c862e6553cf315;p=infobot.git * totally replace do_id with the copy from DebianBugs.pl git-svn-id: https://svn.code.sf.net/p/infobot/code/branches/don/dpkg@1842 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/src/Modules/DebianExtra.pl b/src/Modules/DebianExtra.pl index 8df9343..f70dd2e 100644 --- a/src/Modules/DebianExtra.pl +++ b/src/Modules/DebianExtra.pl @@ -73,79 +73,41 @@ sub debianBugs { } } +use SOAP::Lite; + sub do_id($) { - my ($bug_num) = shift; + my ($bug_num,$options) = @_; + + $options || = {}; if ( not $bug_num =~ /^\#?\d+$/ ) { + warn "Bug is not a number!" and return undef + if not $options->{return_warnings}; return "Bug is not a number!"; } $bug_num =~ s/^\#//; - my @results = - &::getURL("http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=$bug_num"); - my $report = join( "\n", @results ); - - # strip down report to relevant header information. - # $report =~ s/\r//sig; - $report =~ /]*>(.+?)
/si; - $report = $1; - my $bug = {}; - ( $bug->{num}, $bug->{title} ) = - $report =~ m#\#(\d+)\<\/A\>\(.+?)\<\/H1\>#is; - &::DEBUG("Bugnum: $bug->{num}\n"); - $bug->{title} =~ s/</\{title} =~ s/>/\>/g; - $bug->{title} =~ s/"/\"/g; - &::DEBUG("Title: $bug->{title}\n"); - $bug->{severity} = 'n'; #Default severity is normal - my @bug_flags = split /(?{severity} ) = - $bug_flag =~ /(wishlist|minor|normal|important|serious|grave)/i; - - # Just leave the leter instead of the whole thing. - $bug->{severity} =~ s/^(.).+$/$1/; - } - elsif ( $bug_flag =~ /Package:/ ) { - ( $bug->{package} ) = $bug_flag =~ /\"\>\s*([^\<\>\"]+?)\s*\<\/a\>/; - } - elsif ( $bug_flag =~ /Reported by:/ ) { - ( $bug->{reporter} ) = $bug_flag =~ /\"\>\s*(.+?)\s*\<\/a\>/; - - # strip < and > - $bug->{reporter} =~ s/</\{reporter} =~ s/>/\>/g; - } - elsif ( $bug_flag =~ /Date:/ ) { - ( $bug->{date} ) = $bug_flag =~ /Date:\s*(\w.+?)\s*$/; - - #ditch extra whitespace - $bug->{date} =~ s/\s{2,}/\ /; - } - elsif ( $bug_flag =~ /Tags:/ ) { - ( $bug->{tags} ) = $bug_flag =~ /strong\>\s*(.+?)\s*\<\/strong\>/; - } - elsif ( $bug_flag =~ /merged with / ) { - $bug_flag =~ s/merged with\s*//; - $bug_flag =~ s/\<[^\>]+\>//g; - $bug_flag =~ s/\s//sg; - $bug->{merged_with} = $bug_flag; - - } - elsif ( $bug_flag =~ /\>Done:\{done} = 1; - } - elsif ( $bug_flag =~ /\>Fixed\{done} = 1; - } + my $soap = SOAP::Lite->url->('Debbugs/SOAP/1')-> + proxy('http://bugs.debian.org/cgi-bin/soap.cgi'); + $soap->transport->env_proxy(); + my $result = $soap->get_status(bug => $bug_num)->result(); + if (not defined $result) { + return "No such bug (or some kind of error)"; } - + my $bug = {}; + $bug->{num} = $result->{bug_num}; + $bug->{title} = $result->{subject}; + $bug->{severity} = $result->{severity}; #Default severity is normal + # Just leave the leter instead of the whole thing. + $bug->{severity} =~ s/^(.).+$/$1/; + $bug->{package} = $result->{package}; + $bug->{reporter} = $result->{submitter}; + $bug->{date} = $result->{date}; + $bug->{tags} = $result->{keywords}; + $bug->{done} = defined $result->{done} and length $result->{done}; + $bug->{merged_with} = $result->{mergedwith}; # report bug - $report = ''; + my $report = ''; $report .= 'DONE:' if defined $bug->{done} and $bug->{done}; $report .= '#' . $bug->{num} . ':' @@ -160,10 +122,6 @@ sub do_id($) { . join( ',', splice( @{ [ split( /,/, $bug->{merged_with} ) ] }, 0, 3 ) ) . ']' if defined $bug->{merged_with}; - if ($::DEBUG) { - use Data::Dumper; - &::DEBUG( Dumper($bug) ); - } return $report; }