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

Bug#476909: suggestions on reorganisation of the stardict package.

Package: stardict
Severity: normal

Hi, Andrew Lee and Anthony Fok!

I use stardict, I like this dictionary very much, but there is a great
discomfort: at every new installation it is necessary to download the
dictionaries from the site http://stardict.sourceforge.net by hand and
to install them.

It would be nice if the deb-package included the dictionaries from this
site, however it is most likely impossible because mostly they will not
correspond to DFSG.

I have a proposal to you:

to modify the package thus it has configure and template scripts for
debconf, which would allow users to choose and install the dictionaries
automatically (dpkg-reconfigure).

I've written a small script (it is attached) which creates a list of
what to download and where from: according to the results of the work of
this script one may generate the menu for choosing). Some time later I
would be able to complete the work on this system [1].

However now I have to choose whether to make a fake package only for
automatisation of downloading the dictionaries for stardict or to work
further on the stardict package.

Here I need your agreement or disagreement about working on the stardict
package: in the first case you'll include the results of my work into
package and add me to the  Uploaders group and in the second one I'll
make a retitle of this bug in ITP: staridct-dicts [1].

Please inform me what is your opinion on this subject.

Sincerely yours, Dmitry

PS: notes:

[1] _example_ of staridct-dicts.deb uploaded to:


use warnings;
use strict;

package MechUTF8;
use base qw(WWW::Mechanize);
use Encode qw(encode decode);

sub content
  my $self=shift;
  my $content=$self->SUPER::content(@_);
    and $content=encode(utf8=>decode($1=>$content));
  return $content;

package main;
use URI;
use File::Basename qw(basename);
use Getopt::Std qw(getopts);

my $server="http://stardict.sourceforge.net";;
my $durl="$server/Dictionaries.php";

sub die_if_error($$)
  my ($browser, $errtxt)=@_;
  $browser->success and return;
  die sprintf "$errtxt, server status: %s\n",

sub usage()
  print <<endusage;
  usage: $0 [OPTIONS]

    -h            - this helpscreen
    -v            - print verbose messages
    -o file       - save list to file
  exit -1;

getopts('o:hv', \my %opts) or usage;
$opts{h} and usage;
if ($opts{o})
  open STDOUT, '>', $opts{o}
    or die "Can not create file $opts{o}: $!\n";

$|=1; select STDERR; $|=1; select STDOUT;
my $browser=new MechUTF8;
$opts{v} and print STDERR "Getting $durl ...\n";
die_if_error $browser, "Can not get categories list from $server";

my %ans=
    map { m{href="(.*?)".*?>\s*(.*?)\s*<}s; ($2, "$server/$1") }
for (sort keys %ans)
  unless ($ans{$_}=~m{$server/Dictionaries_})
    delete $ans{$_};

  $opts{v} and print STDERR "\tGetting $ans{$_} ...\n";
  die_if_error $browser, "Can not get category `$_'";
  my $content=$browser->content;

  for ($content)
    s[<\s*(?:/)?\s*(?:font|span|strong|b|b|br).*?>][ ]sig;

  my %dlist=
    map { $$_[0]=~s[<td.*?>\s*(.*?)\s*<.*][$1]; ($$_[0], $$_[1]) }
    grep { $$_[1] !~ /rpm$/i }
    map { $$_[1]=~s/\?.*//s; $_ }
    map { ($$_[1]=~m[.*<a\s*href="(.*?)"\s*>\s*tarbal]si)?[$$_[0], $1]:() }
    map { [ $$_[0], "$$_[1] $$_[2]" ] }
    grep { @$_ == 4  or @$_ == 3 }
    map { [ m[(<td.*?/td>)]sig ] }
  for my $url (values %dlist)
    my $basename=basename(URI->new($url)->path);
    $url={file=>$basename, url=>$url, section=>$_};
  $opts{v} and
    printf STDERR "\t\tfound %d tarbal-links for download\n",
      scalar keys %dlist;
  unless (%dlist)
    delete $ans{$_};
  printf "%s\n",
    join "\t", 
      $dlist{$_}{url} for sort keys %dlist;

keys %ans or
  die "Can not find categories list in $durl\n";

exit 0;

Attachment: signature.asc
Description: Digital signature

Reply to: