version 1.1, 2004/09/14 19:47:02
|
version 1.4, 2008/07/29 21:18:16
|
Line 4 use strict;
|
Line 4 use strict;
|
use HTML::TokeParser; |
use HTML::TokeParser; |
use Getopt::Long; |
use Getopt::Long; |
|
|
my ($help) = (0,0,0); |
my ($usage,$build_unused) = (0,0); |
&GetOptions( "help" => \$help); |
&GetOptions( "usage" => \$usage, |
|
"build-unused" => \$build_unused); |
|
|
sub get_all_files { |
sub get_all_files { |
my $dir="../../loncom/html/adm/help/tex/"; |
my $dir="../../loncom/html/adm/help/tex/"; |
opendir(DIR,$dir); |
opendir(DIR,$dir); |
my @files=sort {uc($a) cmp uc($b)} (readdir(DIR)); |
my @files=sort {uc($a) cmp uc($b)} (readdir(DIR)); |
return @files; |
my @realfiles; |
|
foreach my $file (@files) { |
|
if ($file eq '.' || $file eq '..' || $file eq 'CVS' || |
|
$file eq 'Latex_Footer.tex' || $file eq 'Latex_Header.tex') {next;} |
|
push(@realfiles,$file); |
|
} |
|
return @realfiles; |
} |
} |
|
|
sub get_usage { |
sub get_usage { |
Line 30 sub print_unused {
|
Line 37 sub print_unused {
|
my ($all,$usage)=@_; |
my ($all,$usage)=@_; |
my %all; |
my %all; |
my %no_exist; |
my %no_exist; |
foreach my $file (@{ $all }) {$all{$file}=0;} |
foreach my $file (@{ $all }) { |
|
$all{$file}=[]; |
|
} |
|
my @order=('author','course','developer','domain'); |
foreach my $list (@{ $usage }) { |
foreach my $list (@{ $usage }) { |
foreach my $file (@{ $list }) { |
foreach my $file (@{ $list }) { |
if (exists($all{$file})) { $all{$file}++; } else { $no_exist{$file}++; } |
if (exists($all{$file})) { |
|
push(@{$all{$file}},$order[0]); |
|
} else { |
|
push(@{$no_exist{$file}},$order[0]); |
|
} |
} |
} |
|
shift(@order); |
} |
} |
print("Usage count for existing Files:\n"); |
print("Usage count for existing Files:\n"); |
foreach my $file (sort {uc($a) cmp uc($b)} (keys(%all))) { |
foreach my $file (sort {uc($a) cmp uc($b)} (keys(%all))) { |
printf("%-50s: %s\n",$file,$all{$file}); |
if (scalar(@{ $all{$file} }) ne 0) { |
|
printf("%-50s: %s in %s\n",$file,scalar(@{$all{$file}}), |
|
join(',',@{$all{$file}})); |
|
} else { |
|
printf("%-50s: %s\n",$file,scalar(@{$all{$file}})); |
|
} |
} |
} |
print("Usage count for nonexistint Files:\n"); |
print("Usage count for nonexistint Files:\n"); |
foreach my $file (sort {uc($a) cmp uc($b)} (keys(%no_exist))) { |
foreach my $file (sort {uc($a) cmp uc($b)} (keys(%no_exist))) { |
printf("%-50s: %s\n",$file,$no_exist{$file}); |
printf("%-50s: %s in %s\n",$file,scalar(@{$no_exist{$file}}), |
|
join(',',@{$no_exist{$file}})); |
|
} |
|
} |
|
|
|
sub texxml_unused { |
|
my ($all,$usage)=@_; |
|
my %all; |
|
foreach my $file (@{ $all }) {$all{$file}='1';} |
|
foreach my $list (@{ $usage }) { |
|
foreach my $file (@{ $list }) { |
|
if (exists($all{$file})) { |
|
delete($all{$file}); |
|
} |
|
} |
} |
} |
|
print("<texxml>\n"); |
|
print("<title name=\"Unused files\" />\n"); |
|
foreach my $file (sort {uc($a) cmp uc($b)} (keys(%all))) { |
|
print("<section name=\"$file\">\n"); |
|
print("<file name=\"$file\">\n"); |
|
print("</section>\n"); |
|
} |
|
print("</texxml>\n"); |
} |
} |
|
|
sub main { |
sub main { |
Line 51 sub main {
|
Line 93 sub main {
|
my @author_usage=&get_usage('author'); |
my @author_usage=&get_usage('author'); |
my @course_usage=&get_usage('course'); |
my @course_usage=&get_usage('course'); |
my @developer_usage=&get_usage('developer'); |
my @developer_usage=&get_usage('developer'); |
|
my @domain_usage=&get_usage('domain'); |
&print_unused(\@all_files,[\@author_usage,\@course_usage, |
if ($usage) { |
\@developer_usage]); |
&print_unused(\@all_files,[\@author_usage,\@course_usage, |
|
\@developer_usage,\@domain_usage]); |
|
} elsif($build_unused) { |
|
&texxml_unused(\@all_files,[\@author_usage,\@course_usage, |
|
\@developer_usage,\@domain_usage]); |
|
} else { |
|
print("Please specify either --usage or --build-unused\n"); |
|
} |
} |
} |
|
|
&main; |
&main; |