Subversion Repositories wimsdev

Rev

Rev 11480 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11480 schaersvoo 1
#!/usr/bin/perl
7708 bpr 2
 
3
use warnings;
4
use strict;
5
use Encode qw(encode decode);
6
#### for an identifier in a taxo, make the list of the modules
7
#### which refers to this identifier
8
####
8946 bpr 9
print "prepare taxonomy files ...";
7716 bpr 10
for my $f (glob("src/*")) {
11
  my $f0=$f ; $f0 =~ s/src\///;
12
  dicclassification ($f0, ($f));
7712 bpr 13
}
14
 
7880 bpr 15
my $prelim="##This file is generated by classif.pl. Do not modify directly\n";
7708 bpr 16
sub  dicclassification { my ($dirout, @liste)=@_;
17
  my %ref=reverse_dic(@liste);
18
  my $TEXT=$prelim;
19
  for my $k (sort keys %ref) {
16604 bpr 20
    if ($ref{$k}) {
21
      $TEXT .= "$k:$ref{$k}\n";
22
    }
23
    out("$dirout", $TEXT);
7708 bpr 24
  }
25
}
26
 
27
sub reverse_dic { my @liste=@_;
28
  my %ref = ( ) ; my $ref=\%ref;
29
  for my $file (@liste) {
16604 bpr 30
    open IN, "$file";
31
    while (<IN>) {
32
      next if ($_ =~ /^#/);
33
      my $text= $_ ; $text=~ s/\n//;
34
      my @text=split(":", $text);
35
      next if !($text[1]);
36
      my $t=$text[0]; $t=~ s/\n//;
37
      my @L= split(",",$text[1]);
38
      for my $a (@L) {
39
       if ($ref{$a}) {  $ref{$a}.= "," . $t ; } else { $ref{$a} = $t ; }
40
      }
7708 bpr 41
    }
16604 bpr 42
    close IN;
7708 bpr 43
  }
44
  %ref
45
}
46
 
47
sub out { my ($bloc, $text) = @_;
48
  open  (OUT, ">$bloc") ;
49
  print OUT $text ; close OUT;
50
}