Complain if filename does not match PEP number.

This commit is contained in:
Georg Brandl 2009-12-31 08:22:12 +00:00
parent bb83ecdc45
commit 107e1f8b14
1 changed files with 7 additions and 3 deletions

View File

@ -41,10 +41,14 @@ def main(argv):
if file_path.startswith("pep-") and file_path.endswith(".txt"): if file_path.startswith("pep-") and file_path.endswith(".txt"):
with codecs.open(abs_file_path, 'r', encoding='UTF-8') as pep_file: with codecs.open(abs_file_path, 'r', encoding='UTF-8') as pep_file:
try: try:
peps.append(PEP(pep_file)) pep = PEP(pep_file)
if pep.number != int(file_path[4:-4]):
raise PEPError('PEP number does not match file name',
file_path, pep.number)
peps.append(pep)
except PEPError, e: except PEPError, e:
errmsg = "Error processing PEP %s, excluding:" % \ errmsg = "Error processing PEP %s (%s), excluding:" % \
(e.number,) (e.number, e.filename)
print >>sys.stderr, errmsg, e print >>sys.stderr, errmsg, e
sys.exit(1) sys.exit(1)
peps.sort(key=attrgetter('number')) peps.sort(key=attrgetter('number'))