Revision 51ef5fe0 autotools/check-news
b/autotools/check-news | ||
---|---|---|
35 | 35 |
RELEASED_RE = re.compile(r"^\*\(Released (?P<day>[A-Z][a-z]{2})," |
36 | 36 |
r" (?P<date>.+)\)\*$") |
37 | 37 |
UNRELEASED_RE = re.compile(r"^\*\(unreleased\)\*$") |
38 |
VERSION_RE = re.compile(r"^Version \d+(\.\d+)+( (beta|rc)\d+)?$") |
|
38 | 39 |
|
39 | 40 |
|
40 | 41 |
def main(): |
... | ... | |
45 | 46 |
|
46 | 47 |
prevline = None |
47 | 48 |
expect_date = False |
49 |
count_empty = 0 |
|
48 | 50 |
|
49 | 51 |
for line in fileinput.input(): |
50 | 52 |
line = line.rstrip("\n") |
51 | 53 |
|
54 |
if VERSION_RE.match(line): |
|
55 |
if count_empty != 2: |
|
56 |
raise Exception("Line %s: Missing 2 empty lines before %s" % |
|
57 |
(fileinput.filelineno(), line)) |
|
58 |
|
|
59 |
if UNRELEASED_RE.match(line) or RELEASED_RE.match(line): |
|
60 |
if count_empty != 1: |
|
61 |
raise Exception("Line %s: Missing 1 empty line before %s" % |
|
62 |
(fileinput.filelineno(), line)) |
|
63 |
|
|
64 |
if line: |
|
65 |
count_empty = 0 |
|
66 |
else: |
|
67 |
count_empty += 1 |
|
68 |
|
|
52 | 69 |
if DASHES_RE.match(line): |
53 |
if not prevline.startswith("Version "): |
|
54 |
raise Exception("Line %s: Invalid title" % (fileinput.filelineno() - 1)) |
|
70 |
if not VERSION_RE.match(prevline): |
|
71 |
raise Exception("Line %s: Invalid title" % |
|
72 |
(fileinput.filelineno() - 1)) |
|
73 |
if len(line) != len(prevline): |
|
74 |
raise Exception("Line %s: Invalid dashes length" % |
|
75 |
(fileinput.filelineno())) |
|
55 | 76 |
expect_date = True |
56 | 77 |
|
57 | 78 |
elif expect_date: |
Also available in: Unified diff