From 70fbc6c0604553bdba27c140470ce2330a6c8e1c Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 7 Dec 2010 17:54:41 +0000 Subject: [PATCH] Change the code used to expire IDs and clean up the ID repository so as to not remove the draft signature files (with a .txt.p7s extension). Fixes #567. - Legacy-Id: 2696 --- ietf/idrfc/expire.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ietf/idrfc/expire.py b/ietf/idrfc/expire.py index a98b484bd..bfa5b76b2 100644 --- a/ietf/idrfc/expire.py +++ b/ietf/idrfc/expire.py @@ -56,6 +56,7 @@ def expire_id(doc): shutil.move(src, dst) move_file("%s-%s.txt" % (doc.filename, doc.revision_display())) + move_file("%s-%s.txt.p7s" % (doc.filename, doc.revision_display())) move_file("%s-%s.ps" % (doc.filename, doc.revision_display())) move_file("%s-%s.pdf" % (doc.filename, doc.revision_display())) @@ -88,10 +89,29 @@ def clean_up_id_files(): pattern = os.path.join(settings.INTERNET_DRAFT_PATH, "draft-*.*") files = [] - filename_re = re.compile('^(.*)-(\d+)$') + filename_re = re.compile('^(.*)-(\d\d)$') + + def splitext(fn): + """ + Split the pathname path into a pair (root, ext) such that root + ext + == path, and ext is empty or begins with a period and contains all + periods in the last path component. + + This differs from os.path.splitext in the number of periods in the ext + parts when the final path component containt more than one period. + """ + s = fn.rfind("/") + if s == -1: + s = 0 + i = fn[s:].find(".") + if i == -1: + return fn, '' + else: + return fn[:s+i], fn[s+i:] + for path in glob.glob(pattern): basename = os.path.basename(path) - stem, ext = os.path.splitext(basename) + stem, ext = splitext(basename) match = filename_re.search(stem) if not match: filename, revision = ("UNKNOWN", "00")