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

Re: http://www.debian.org/intl/l10n/ popularity sorting?



On Sat, Jan 22, 2005 at 05:42:30PM +0100, Denis Barbier wrote:
> On Sat, Jan 22, 2005 at 04:52:46PM +0100, Claus Hindsgaul wrote:
> > Hi,
> > 
> > Who wrote/maintains the scripts creating the pages below
> > http://www.debian.org/intl/l10n/ ?

Denis and me.

> > I want to suggest sorting the untranslated package list on each language
> > page after popularity (from popcon.debian.org) instead of
> > alphabetically. 
> 
> I can do that but I need a sorted list of source packages, any idea on
> how to generate it?

I think the attached script does the work. It's discutable because it uses
the /var/lib/apt/lists files to do the job, but anyway.


I'll propose this to the popcon maintainer. Who knows? they may propose a
source package list on there web page for us to download directly.


Thanks for your time, 
Mt.
#! /usr/bin/perl

use warnings;
use strict;

my $verbose = 0;

##
## Get information about which bin package is generated from which source one
##  result in $source{"toto"} = name of source pkg generating toto

my %source;

my $APTROOT="/var/lib/apt/lists";

opendir APTLIB, $APTROOT || die "Cannot read $APTROOT: $!\n";
my @sources = grep { /source_Sources$/ && -f "$APTROOT/$_" } readdir(APTLIB);
closedir APTLIB;


foreach my $source (@sources) {
    print STDERR "Parse $APTROOT/$source\n";
    open SOURCE,"$APTROOT/$source" || die "Cannot read $APTROOT/$source: $!\n";
    my $pkg;
    while (<SOURCE>) {
	$pkg = $1 if (/^Package: (.*)$/);
	if (/^Binary: (.*)$/) {
	    map { s/ //g; $source{$_}=$pkg; } split (/,/, $1);
	}
    }
    close SOURCE;
}

# map {print "$_ -> ".$source{$_}."\n"} keys %source;
		   
##
## Get info about src pkg ranking 
##  $rank{"toto"}= the better position achieved by a package generated from src:toto
##

my %rank;

open POPCON, "by_inst" || die "Cannot read by_inst. Grab it from http://popcon.debian.org/by_inst\n";;

while (<POPCON>) {
    s/ *#.*$//;
    next unless /\S/;
    next if (/Not in sid/);
    unless (m/([0-9]*)\s*(\S*)\s/) {
	warn "Unparsable line: $_\n";
	next;
    }
    
    my ($rank,$pkg)=($1,$2);
    my $src = $source{$pkg};
    
    unless (defined($src)) {    
	warn "Package without source: $pkg\n" if $verbose;
	next;
    }
    
    $rank{$src} = defined($rank{$src}) ? ($rank{$src} > $rank ? $rank : $rank{$src}) 
                                       : $rank;
}

##
## Output the ranking
##
map {print $rank{$_}."  $_\n"; } sort {$rank{$a} <=> $rank{$b}} keys %rank;

Attachment: signature.asc
Description: Digital signature


Reply to: