blob: 2727351628e54877a15f525352196fa86dc94400 (
plain)
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
|
#!/usr/bin/perl -w
# Copyright 2007 Nick Mathewson. See LICENSE for licensing information.
use strict;
my $propdir = ".";
local *DIR;
local *F;
opendir(DIR, $propdir) || die "Can't open $propdir";
my @files = sort grep { /^\d\d\d-.*[^\~]$/ } readdir(DIR);
closedir DIR;
my %title = ();
my %status = ();
my @KNOWN_STATUSES = qw{
DRAFT OPEN NEEDS-REVISION NEEDS-RESEARCH ACCEPTED META FINISHED CLOSED
SUPERSEDED DEAD};
for my $f (@files) {
my $num = substr($f, 0, 3);
my $status = undef;
my $title = undef;
my $implemented_in = undef;
my $target = undef;
my $alleged_fname = undef;
if ($f !~ /\.txt/) { print "$f doesn't end with .txt\n"; }
open(F, "$f");
while (<F>) {
last if (/^\s*$/);
if (/^Status: (.*)/) {
$status = uc $1;
chomp $status;
}
if (/^Filename: (.*)/) {
$alleged_fname = $1;
chomp $alleged_fname;
}
if (/^Title: (.*)/) {
$title = $1;
$title =~ s/\.$//;
chomp $title;
}
if (/^Implemented-In: (.*)/) {
$implemented_in = $1;
chomp $implemented_in;
}
if (/^Target: (.*)/) {
$target = $1;
chomp $target;
}
}
close F;
die "Proposal $num has no status line" if (!defined $status);
die "I've never heard of status $status in proposal $num"
unless (grep(/$status/, @KNOWN_STATUSES) == 1);
die "Proposal $num has no title line" if (!defined $title);
die "Proposal $num has no Filename line" unless (defined $alleged_fname);
die "Proposal $num says its fname is $alleged_fname, but it's really $f"
if ($alleged_fname ne $f);
print "No Target for proposal $num\n" if (($status eq 'OPEN' or
$status eq 'ACCEPTED')
and !defined $target);
print "No Implemented-In for proposal $num\n"
if (($status eq 'CLOSED' or $status eq 'FINISHED')
and !defined $implemented_in);
$title{$num} = $title;
$status{$num} = $status;
}
local *OUT;
open(OUT, ">000-index.txt.tmp");
open(F, "000-index.txt") or die "Can't open index file.";
while (<F>) {
print OUT;
last if (/^={3,}/);
}
close(F);
print OUT "Proposals by number:\n\n";
for my $num (sort keys %title) {
print OUT "$num $title{$num} [$status{$num}]\n";
}
print OUT "\n\nProposals by status:\n\n";
for my $status (@KNOWN_STATUSES) {
print OUT " $status:\n";
for my $num (sort keys %status) {
next unless ($status{$num} eq $status);
print OUT " $num $title{$num}\n";
}
}
rename('000-index.txt.tmp', '000-index.txt');
|