From 107e1f8b14e3baf7cab3b1ecdf8e3ae0e3b8cafe Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 31 Dec 2009 08:22:12 +0000 Subject: [PATCH] Complain if filename does not match PEP number. --- genpepindex.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/genpepindex.py b/genpepindex.py index 29b444207..f13cb4131 100644 --- a/genpepindex.py +++ b/genpepindex.py @@ -41,10 +41,14 @@ def main(argv): if file_path.startswith("pep-") and file_path.endswith(".txt"): with codecs.open(abs_file_path, 'r', encoding='UTF-8') as pep_file: 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: - errmsg = "Error processing PEP %s, excluding:" % \ - (e.number,) + errmsg = "Error processing PEP %s (%s), excluding:" % \ + (e.number, e.filename) print >>sys.stderr, errmsg, e sys.exit(1) peps.sort(key=attrgetter('number'))