[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#553661: bugs.debian.org: provide some way through the SOAP interface to determine if a package exists



tag 553661 - patch
thanks

On Wed, 23 Dec 2009, Ryan Niebur wrote:
> On Sun, Nov 01, 2009 at 03:21:33PM -0800, Don Armstrong wrote:
> > reassign 553661 debbugs
> > retitle 553661 expose Debbugs::Common::package_maintainer via soap
> > thanks
> > 
> > On Sun, 01 Nov 2009, Ryan Niebur wrote:
> > > one way I thought of is to check the maintainer. it looks like just
> > > exposing Debbugs::Common::package_maintainer is all that's needed
> > > for that. if there's a better way, of course please do that instead.
> > 
> > That's basically how Debbugs does it.
> > 
> 
> how does this patch look? rather than exposing package_maintainer
> itself, it uses package_maintainer to determine if the package exists.
> this way the implimentation on how to tell if a package exists is left
> to Debbugs rather than the client program. and feel free to make me
> redo it, I just want this fixed. ;)

This part of the implementation is so trivial that I don't think it
needs to be done in Debbugs. It will just be a documented conclusion
you can make when you call package_maintainer. [The perl code for this
is trivial:

  sub packages_exist {
      return {map {($_,package_maintainer(binary=>$_)?1:0);} @_};
  }
  

I suppose it would be reasonable to return a hashref of
package=>maintainer pairs, but that's not currently what
package_maintainer does. [The reason why this would be a good idea is
because package_maintainer is a relatively expensive call to make
currently.]

[...]

> +sub packages_exist {
> +     my $VERSION = __populate_version(pop);
> +     my ($self, @list) = @_;
> +     my %res;
> +     foreach my $pkg(@list) {
> +       my $keyword;


> +       if($pkg =~ /^src:/) {
> +         $keyword = "source";
> +       } else {
> +         $keyword = "binary";
> +       }

This bit above is superfluous; package_maintainer already does this
for you.

> +       $res{$pkg} = !!Debbugs::Common::package_maintainer($keyword => [($pkg)]) || 0;

This isn't obvious what it does on first glance. You really want
something like

package_maintainer(binary=>$pkg)?1:0

instead.

[...]


Don Armstrong

-- 
Fate and Temperament are two words for one and the same concept.
 -- Novalis [Hermann Hesse _Demian_]

http://www.donarmstrong.com              http://rzlab.ucr.edu



Reply to: