-
Notifications
You must be signed in to change notification settings - Fork 4
/
AuthSummary.perl
122 lines (114 loc) · 3.88 KB
/
AuthSummary.perl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use strict;
use warnings;
my $v = $ARGV[0];
my $s = $ARGV[1];
my %d = ();
my $pP = "";
my %tmp = ();
my $cnt = 0;
for my $ty ($ARGV[2]){
$cnt = 0;
%tmp = ();
$pP = "";
my $pre = "";
$pre = "../c2fb/" if $ty =~/A2[bf]/;
$pre = "../tkns/" if $ty =~/A2tPllPkg/;
open A, "zcat $pre${ty}Full$v$s.s |";
while (<A>){
chop ();
my ($p, $c, @rest) = split (/;/, $_, -1);
if ($pP ne "" && $pP ne $p){
print "$pP;$ty=".(scalar(keys %tmp))."\n";
#$d{$ty}{$pP} = scalar(keys %tmp);
if ($ty eq "A2f"){
doExt ($pP, \%tmp);
}
if ($ty eq "A2tPllPkg"){
doAPI ($pP, \%tmp);
}
%tmp = ();
print STDERR "$s $ty $cnt\n" if (!($cnt++%500000));
#last if $cnt > 10000;
}
if ($ty eq "A2tPllPkg"){
$tmp{$c}{join ";", @rest}++;
}else{
$tmp{$c}++;
}
$pP = $p;
}
print "$pP;$ty=".(scalar(keys %tmp))."\n";
#$d{$ty}{$pP} = scalar(keys %tmp);
doExt ($pP, \%tmp) if ($ty eq "A2f");
doAPI ($pP, \%tmp) if ($ty eq "A2tPllPkg");
print STDERR "done $s $ty $cnt\n";
}
sub doAPI {
my ($p, $tmp) = @_;
my %api;
for my $t (keys %$tmp){
for my $v (keys %{$tmp->{$t}}){
my ($p, $l, $l1, @pkg) = split (/;/, $v);
for my $pk (@pkg){
$api{$l}{$pk}++;
}
}
}
for my $i (keys %api){
print "$p;api;$i";
for my $v (keys %{$api{$i}}){
my $v1 = $v;
$v1 =~ s/=/EQ/g;
print ";$v1=$api{$i}{$v}";
}
print "\n";
}
}
sub doExt {
my ($p, $tmp) = @_;
my @a = keys %$tmp;
my %e = ();
for my $fi (@a){ ext ($fi, \%e, $tmp->{$fi}) if $fi ne ""; }
#my @a = sort { $e{$b} <=> $e{$a} } keys %e;
print "$p;exts";
for my $i (keys %e){
my $i1 = $i;
$i1 =~ s/=/EQ/g;
print ";$i1=$e{$i}";
#$d{e}{$p}{$i}=$e{$i};
}
print "\n"
}
sub ext {
my ($f, $stats) = @_;
if( $f =~ m/(\.java$|\.iml|\.jar|\.class|\.dpj|\.xrb)$/ ) {$stats->{'Java'}++;}
elsif( $f =~ m/\.(js|iced|liticed|iced.md|coffee|litcoffee|coffee.md|cs|ls|es6|jsx|sjs|co|eg|json|json.ls|json5)$/ ) {$stats->{'JavaScript'}++;}
elsif( $f =~ m/\.(py|py3|pyx|pyo|pyw|pyc|whl)$/ ) {$stats->{'Python'}++;}
elsif( $f =~ m/\.CPP$|\.CXX$|\.cpp$|\.[Cch]$|\.hh$|\.cc$|\.cxx$|\.hpp$|\.hxx$|\.Hxx$|\.HXX$|\.C$|\.c$|\.h$|\.H$/ ) { $stats->{'C/C++'}++; }
elsif( $f =~ m/\.cs$/ ) {$stats->{'C#'}++;}
elsif( $f =~ m/\.php$/ ) {$stats->{'PHP'}++;}
elsif( $f =~ m/\.(rb|erb|gem|gemspec)$/ ) {$stats->{'Ruby'}++; }
elsif( $f =~ m/\.go$/ ) {$stats->{'Go'}++;}
elsif( $f =~ m/\.ipy$/ ) {$stats->{'ipy'}++;}
elsif( $f =~ m/\.swift$/ ) {$stats->{'Swift'}++;}
elsif( $f =~ m/\.scala$/ ) {$stats->{'Scala'}++;}
elsif( $f =~ m/\.(kt|kts|ktm)$/ ) {$stats->{'Kotlin'}++;}
elsif( $f =~ m/\.(ts|tsx)$/ ) {$stats->{'TypeScript'}++;}
elsif( $f =~ m/\.dart$/ ) {$stats->{'Dart'}++;}
elsif( $f =~ m/\.(rs|rlib|rst)$/ ) {$stats->{'Rust'}++;}
elsif( $f =~ m'./*(\.Rd|\.[Rr]|\.Rprofile|\.Rdata|\.Rhistory|\.Rproj|^NAMESPACE|^DESCRIPTION|/NAMESPACE|/DESCRIPTION)$' ) {$stats->{'R'}++;}
elsif( $f =~ m/(\.perl|\.pod|\.pl|\.PL|\.pm)$/ ){ $stats->{'Perl'}++; }
elsif( $f =~ m/\.(f[hi]|[fF]|[fF]77|[fF]9[0-9]|fortran|forth)$/ ) {$stats->{'Fortran'}++;}
elsif( $f =~ m/\.ad[abs]$/ ) {$stats->{'Ada'}++;}
elsif( $f =~ m/\.erl$/ ) {$stats->{'Erlang'}++;}
elsif( $f =~ m/\.lua$/ ) {$stats->{'Lua'}++;}
elsif( $f =~ m/\.(sql|sqllite|sqllite3|mysql)$/ ) {$stats->{'Sql'}++;}
elsif( $f =~ m/\.(el|lisp|elc)$/ ) {$stats->{'Lisp'}++;}
elsif( $f =~ m/\.(fs|fsi|ml|mli|hs|lhs|sml|v)$/ ) {$stats->{'fml'}++;}
elsif( $f =~ m/\.jl$/ ) {$stats->{'Julia'}++;}
elsif( $f =~ m/\.(COB|CBL|PCO|FD|SEL|CPY|cob|cbl|pco|fd|sel|cpy)$/ ) {$stats->{'Cobol'}++;}
elsif( $f =~ m/\.(cljs|cljc|clj)$/ ) {$stats->{'Clojure'}++;}
elsif( $f =~ m/\.(aug|mli|ml|aug)$/ ) {$stats->{'OCaml'}++;}
elsif( $f =~ m/\.(bas|bb|bi|pb)$/ ) {$stats->{'Basic'}++;}
else {$stats->{'other'}++};
}