Skip to content

Commit f992c21

Browse files
committed
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
1 parent 91a365c commit f992c21

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

ietf/doc/proxy.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,18 @@ def revision_date(self):
5656
e = self.latest_event(type="new_revision")
5757
return e.time.date() if e else None
5858
# helper function
59-
def get_file_type_matches_from(self, glob_path):
59+
def get_file_type_matches_from(self, base_path):
6060
possible_types = [".txt", ".pdf", ".xml", ".ps"]
6161
res = []
62-
for m in glob.glob(glob_path):
63-
i = m.find(".")
64-
if i == -1:
65-
ext = ""
66-
else:
67-
ext = m[i:]
62+
for m in glob.glob(base_path + '.*'):
6863
for t in possible_types:
69-
if t == ext:
64+
if base_path + t == m:
7065
res.append(t)
7166
return ",".join(res)
7267
#file_type = models.CharField(max_length=20)
7368
@property
7469
def file_type(self):
75-
return self.get_file_type_matches_from(os.path.join(settings.INTERNET_DRAFT_PATH, self.name + "-" + self.rev + ".*")) or ".txt"
70+
return self.get_file_type_matches_from(os.path.join(settings.INTERNET_DRAFT_PATH, self.name + "-" + self.rev)) or ".txt"
7671
#txt_page_count = models.IntegerField()
7772
@property
7873
def txt_page_count(self):
@@ -716,7 +711,7 @@ def wg(self):
716711
#file_formats = models.CharField(max_length=20,blank=True,null=True)
717712
@property
718713
def file_formats(self):
719-
return self.get_file_type_matches_from(os.path.join(settings.RFC_PATH, "rfc" + str(self.rfc_number) + ".*")).replace(".", "").replace("txt", "ascii")
714+
return self.get_file_type_matches_from(os.path.join(settings.RFC_PATH, "rfc" + str(self.rfc_number))).replace(".", "").replace("txt", "ascii")
720715

721716
@property
722717
def positions(self):

0 commit comments

Comments
 (0)