OSDN Git Service

Address unmatch newlines in special ja.po
[linuxjm/LDP_man-pages.git] / tools / generate-list.pl
1 #!/usr/bin/env perl
2
3 use File::Basename qw/basename/;
4 use Getopt::Std qw/getopts/;
5
6 $debug = 0;
7 $page_count = 0;
8 %opts = ();
9 %exclude_pages = ();
10
11 sub print_header {
12     print <<EOF;
13 <HTML>
14 <HEAD><TITLE>Translation status of LDP man-pages</TITLE>
15 <STYLE type="text/css">
16 <!--
17  tr.over80 { background-color: #AAFFAA; }
18  tr.over70 { background-color: #FFAAFF; }
19 -->
20 </STYLE>
21 </HEAD>
22 <BODY>
23 <TABLE BORDER=1>
24 <TR class=\"over80\"><TD COLSPAN=3>Released pages but not completed (released if &gt;=80%)</TD></TR>
25 <TR class=\"over70\"><TD COLSPAN=3>Near release pages (&gt;= 70%)</TD></TR>
26 <TR><TH>page name</TH><TH>remaining</TH><TH>comp. %</TH></TR>
27 EOF
28 }
29
30 sub print_footer {
31     print <<EOF;
32 <TR><TD COLSPAN=3>Total $page_count pages</TD></TR>
33 </TABLE>
34 </BODY></HTML>
35 EOF
36 }
37
38 sub print_poname {
39     my $poname = shift;
40     printf("<TR><TD ALIGN=\"center\" COLSPAN=3 BGCOLOR=\"Yellow\">" .
41            "<B>%s</B></TD></TR>\n", $poname);
42 }
43
44 sub print_manpage {
45     my ($page, $all, $remaining, $ratio) = @_;
46     if ($ratio >= 80) {
47         print '<TR class="over80">';
48     } elsif ($ratio >= 70) {
49         print '<TR class="over70">';
50     } else {
51         print '<TR>';
52     }
53     printf("<TD>%s</TD><TD>%d/%d</TD><TD>%.2f</TD>",
54            $page, $remaining, $all, $ratio);
55     print "</TR>\n";
56 }
57
58 sub process_postat {
59     my $postat = shift;
60     my $poname = basename($postat);
61     my $poname_print = 1;
62
63     open(POSTAT, $postat);
64     while (<POSTAT>) {
65         next if /^#/;
66         # format: pagename, #complete, #remaining, #total
67         my ($page, $comp, $remaining, $total) = split(',');
68         next if (defined $opts{"e"} && defined $exclude_pages{$page});
69         $ratio = $comp / $total * 100;
70         if ($poname_print) {
71             print_poname($poname);
72             $poname_print = 0;
73         }
74         print_manpage($page, $total, $remaining, $ratio);
75         $page_count++;
76     }
77 }
78
79 sub read_exclude_list {
80     my $file = shift;
81     open(EXCLUDES, $file);
82     while(<EXCLUDES>) {
83         next if /^#/;
84         chop;
85         my $page = $_;
86         $exclude_pages{$page} = 1;
87     }
88 }
89
90 getopts("e:", \%opts);
91 if (defined $opts{"e"}) {
92     read_exclude_list($opts{"e"});
93 }
94
95 print_header();
96 foreach my $name (@ARGV) {
97     print STDERR "$name...\n" if $debug;
98     process_postat($name);
99 }
100 print_footer();