From f992c2192517b54e60ed0ea2c8ca4b800c5c5083 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Thu, 15 Mar 2012 11:34:45 +0000 Subject: [PATCH] Fix file globbing try to match against full known file names rather than trying to extract an extension which may be buggy with I-Ds with periods in the name, as per suggestion from Henrik. - Legacy-Id: 4086 --- ietf/doc/proxy.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/ietf/doc/proxy.py b/ietf/doc/proxy.py index f197f2efb..f9f0e4a07 100644 --- a/ietf/doc/proxy.py +++ b/ietf/doc/proxy.py @@ -56,23 +56,18 @@ class InternetDraft(Document): e = self.latest_event(type="new_revision") return e.time.date() if e else None # helper function - def get_file_type_matches_from(self, glob_path): + def get_file_type_matches_from(self, base_path): possible_types = [".txt", ".pdf", ".xml", ".ps"] res = [] - for m in glob.glob(glob_path): - i = m.find(".") - if i == -1: - ext = "" - else: - ext = m[i:] + for m in glob.glob(base_path + '.*'): for t in possible_types: - if t == ext: + if base_path + t == m: res.append(t) return ",".join(res) #file_type = models.CharField(max_length=20) @property def file_type(self): - return self.get_file_type_matches_from(os.path.join(settings.INTERNET_DRAFT_PATH, self.name + "-" + self.rev + ".*")) or ".txt" + return self.get_file_type_matches_from(os.path.join(settings.INTERNET_DRAFT_PATH, self.name + "-" + self.rev)) or ".txt" #txt_page_count = models.IntegerField() @property def txt_page_count(self): @@ -716,7 +711,7 @@ class InternetDraft(Document): #file_formats = models.CharField(max_length=20,blank=True,null=True) @property def file_formats(self): - return self.get_file_type_matches_from(os.path.join(settings.RFC_PATH, "rfc" + str(self.rfc_number) + ".*")).replace(".", "").replace("txt", "ascii") + return self.get_file_type_matches_from(os.path.join(settings.RFC_PATH, "rfc" + str(self.rfc_number))).replace(".", "").replace("txt", "ascii") @property def positions(self):