Skip to content

Commit 2b1f238

Browse files
committed
Changed regex strings to raw strings and fixed a sort comparison int/str issue.
- Legacy-Id: 16333
1 parent e27a06c commit 2b1f238

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

ietf/doc/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def get_search_cache_key(params):
767767
from ietf.doc.views_search import SearchForm
768768
fields = set(SearchForm.base_fields) - set(['sort',])
769769
kwargs = dict([ (k,v) for (k,v) in list(params.items()) if k in fields ])
770-
key = "doc:document:search:" + hashlib.sha512(json.dumps(kwargs, sort_keys=True)).hexdigest()
770+
key = "doc:document:search:" + hashlib.sha512(json.dumps(kwargs, sort_keys=True).encode()).hexdigest()
771771
return key
772772

773773
def label_wrap(label, items, joiner=',', max=50):
@@ -817,21 +817,21 @@ def add_markup(path, doc, lines):
817817
ipr_url = "%s?submit=draft&id=%s" % (urlreverse('ietf.ipr.views.search'), name)
818818
for i, line in enumerate(lines):
819819
# add draft links
820-
line = re.sub(r'\b(draft-[-a-z0-9]+)\b', '<a href="%s/\g<1>">\g<1></a>'%(path, ), line)
820+
line = re.sub(r'\b(draft-[-a-z0-9]+)\b', r'<a href="%s/\g<1>">\g<1></a>'%(path, ), line)
821821
# add rfcXXXX to RFC links
822-
line = re.sub(r' (rfc[0-9]+)\b', ' <a href="%s/\g<1>">\g<1></a>'%(path, ), line)
822+
line = re.sub(r' (rfc[0-9]+)\b', r' <a href="%s/\g<1>">\g<1></a>'%(path, ), line)
823823
# add XXXX to RFC links
824-
line = re.sub(r' ([0-9]{3,5})\b', ' <a href="%s/rfc\g<1>">\g<1></a>'%(path, ), line)
824+
line = re.sub(r' ([0-9]{3,5})\b', r' <a href="%s/rfc\g<1>">\g<1></a>'%(path, ), line)
825825
# add draft revision links
826-
line = re.sub(r' ([0-9]{2})\b', ' <a href="%s/%s-\g<1>">\g<1></a>'%(path, name, ), line)
826+
line = re.sub(r' ([0-9]{2})\b', r' <a href="%s/%s-\g<1>">\g<1></a>'%(path, name, ), line)
827827
if rfcnum:
828828
# add errata link
829-
line = re.sub(r'Errata exist', '<a class="text-warning" href="%s">Errata exist</a>'%(errata_url, ), line)
829+
line = re.sub(r'Errata exist', r'<a class="text-warning" href="%s">Errata exist</a>'%(errata_url, ), line)
830830
if is_hst or not rfcnum:
831831
# make current draft rev bold
832832
line = re.sub(r'>(%s)<'%rev, '><b>\g<1></b><', line)
833-
line = re.sub(r'IPR declarations', '<a class="text-warning" href="%s">IPR declarations</a>'%(ipr_url, ), line)
834-
line = line.replace(r'[txt]', '[<a href="%s">txt</a>]' % doc.href())
833+
line = re.sub(r'IPR declarations', r'<a class="text-warning" href="%s">IPR declarations</a>'%(ipr_url, ), line)
834+
line = line.replace(r'[txt]', r'[<a href="%s">txt</a>]' % doc.href())
835835
lines[i] = line
836836
return lines
837837
#

ietf/doc/views_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def cached_redirect(cache_key, url):
265265
return HttpResponseRedirect(url)
266266

267267
# chop away extension
268-
extension_split = re.search("^(.+)\.(txt|ps|pdf)$", n)
268+
extension_split = re.search(r"^(.+)\.(txt|ps|pdf)$", n)
269269
if extension_split:
270270
n = extension_split.group(1)
271271

@@ -494,7 +494,7 @@ def index_all_drafts(request):
494494

495495
if name.startswith("rfc"):
496496
name = name.upper()
497-
sort_key = -int(name[3:])
497+
sort_key = '%09d' % (100000000-int(name[3:]))
498498

499499
names.append((name, sort_key))
500500

ietf/group/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def get_description(self):
192192
text = self.charter.text()
193193
# split into paragraphs and grab the first non-empty one
194194
if text:
195-
desc = [ p for p in re.split('\r?\n\s*\r?\n\s*', text) if p.strip() ][0]
195+
desc = [ p for p in re.split(r'\r?\n\s*\r?\n\s*', text) if p.strip() ][0]
196196
return desc
197197

198198

0 commit comments

Comments
 (0)