Skip to content

Commit 0589d0b

Browse files
committed
Changed a bunch of regexes to use r strings; also miscellaneous smaller fixes.
- Legacy-Id: 16376
1 parent 1225f8a commit 0589d0b

10 files changed

Lines changed: 63 additions & 64 deletions

File tree

ietf/doc/templatetags/ietf_filters.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import datetime
55
import re
66

7-
import types
8-
97
from email.utils import parseaddr
108

119
from django import template
@@ -47,8 +45,8 @@ def parse_email_list(value):
4745
4846
Splitting a string of email addresses should return a list:
4947
50-
>>> unicode(parse_email_list('joe@example.org, fred@example.com'))
51-
u'<a href="mailto:joe@example.org">joe@example.org</a>, <a href="mailto:fred@example.com">fred@example.com</a>'
48+
>>> parse_email_list('joe@example.org, fred@example.com')
49+
'<a href="mailto:joe@example.org">joe@example.org</a>, <a href="mailto:fred@example.com">fred@example.com</a>'
5250
5351
Parsing a non-string should return the input value, rather than fail:
5452
@@ -88,7 +86,7 @@ def strip_email(value):
8886
@register.filter(name='fix_angle_quotes')
8987
def fix_angle_quotes(value):
9088
if "<" in value:
91-
value = re.sub("<([\w\-\.]+@[\w\-\.]+)>", "&lt;\1&gt;", value)
89+
value = re.sub(r"<([\w\-\.]+@[\w\-\.]+)>", "&lt;\1&gt;", value)
9290
return value
9391

9492
# there's an "ahref -> a href" in GEN_UTIL
@@ -213,13 +211,13 @@ def urlize_ietf_docs(string, autoescape=None):
213211
"""
214212
if autoescape and not isinstance(string, SafeData):
215213
string = escape(string)
216-
string = re.sub("(?<!>)(RFC ?)0{0,3}(\d+)", "<a href=\"/doc/rfc\\2/\">\\1\\2</a>", string)
217-
string = re.sub("(?<!>)(BCP ?)0{0,3}(\d+)", "<a href=\"/doc/bcp\\2/\">\\1\\2</a>", string)
218-
string = re.sub("(?<!>)(STD ?)0{0,3}(\d+)", "<a href=\"/doc/std\\2/\">\\1\\2</a>", string)
219-
string = re.sub("(?<!>)(FYI ?)0{0,3}(\d+)", "<a href=\"/doc/fyi\\2/\">\\1\\2</a>", string)
220-
string = re.sub("(?<!>)(draft-[-0-9a-zA-Z._+]+)", "<a href=\"/doc/\\1/\">\\1</a>", string)
221-
string = re.sub("(?<!>)(conflict-review-[-0-9a-zA-Z._+]+)", "<a href=\"/doc/\\1/\">\\1</a>", string)
222-
string = re.sub("(?<!>)(status-change-[-0-9a-zA-Z._+]+)", "<a href=\"/doc/\\1/\">\\1</a>", string)
214+
string = re.sub(r"(?<!>)(RFC ?)0{0,3}(\d+)", "<a href=\"/doc/rfc\\2/\">\\1\\2</a>", string)
215+
string = re.sub(r"(?<!>)(BCP ?)0{0,3}(\d+)", "<a href=\"/doc/bcp\\2/\">\\1\\2</a>", string)
216+
string = re.sub(r"(?<!>)(STD ?)0{0,3}(\d+)", "<a href=\"/doc/std\\2/\">\\1\\2</a>", string)
217+
string = re.sub(r"(?<!>)(FYI ?)0{0,3}(\d+)", "<a href=\"/doc/fyi\\2/\">\\1\\2</a>", string)
218+
string = re.sub(r"(?<!>)(draft-[-0-9a-zA-Z._+]+)", "<a href=\"/doc/\\1/\">\\1</a>", string)
219+
string = re.sub(r"(?<!>)(conflict-review-[-0-9a-zA-Z._+]+)", "<a href=\"/doc/\\1/\">\\1</a>", string)
220+
string = re.sub(r"(?<!>)(status-change-[-0-9a-zA-Z._+]+)", "<a href=\"/doc/\\1/\">\\1</a>", string)
223221
return mark_safe(string)
224222
urlize_ietf_docs = stringfilter(urlize_ietf_docs)
225223

@@ -461,8 +459,8 @@ def capfirst_allcaps(text):
461459
"""Like capfirst, except it doesn't lowercase words in ALL CAPS."""
462460
result = text
463461
i = False
464-
for token in re.split("(\W+)", striptags(text)):
465-
if not re.match("^[A-Z]+$", token):
462+
for token in re.split(r"(\W+)", striptags(text)):
463+
if not re.match(r"^[A-Z]+$", token):
466464
if not i:
467465
result = result.replace(token, token.capitalize())
468466
i = True
@@ -474,8 +472,8 @@ def capfirst_allcaps(text):
474472
def lower_allcaps(text):
475473
"""Like lower, except it doesn't lowercase words in ALL CAPS."""
476474
result = text
477-
for token in re.split("(\W+)", striptags(text)):
478-
if not re.match("^[A-Z]+$", token):
475+
for token in re.split(r"(\W+)", striptags(text)):
476+
if not re.match(r"^[A-Z]+$", token):
479477
result = result.replace(token, token.lower())
480478
return result
481479

@@ -515,7 +513,7 @@ def zaptmp(s):
515513

516514
@register.filter()
517515
def rfcbis(s):
518-
m = re.search('^.*-rfc(\d+)-?bis(-.*)?$', s)
516+
m = re.search(r'^.*-rfc(\d+)-?bis(-.*)?$', s)
519517
return None if m is None else 'rfc' + m.group(1)
520518

521519
@register.filter

ietf/doc/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ def add_markup(path, doc, lines):
829829
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
832-
line = re.sub(r'>(%s)<'%rev, '><b>\g<1></b><', line)
832+
line = re.sub(r'>(%s)<'%rev, r'><b>\g<1></b><', line)
833833
line = re.sub(r'IPR declarations', r'<a class="text-warning" href="%s">IPR declarations</a>'%(ipr_url, ), line)
834834
line = line.replace(r'[txt]', r'[<a href="%s">txt</a>]' % doc.href())
835835
lines[i] = line

ietf/doc/views_doc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def document_main(request, name, rev=None):
623623
def document_html(request, name, rev=None):
624624
if name.startswith('rfc0'):
625625
name = "rfc" + name[3:].lstrip('0')
626-
if name.startswith('review-') and re.search('-\d\d\d\d-\d\d$', name):
626+
if name.startswith('review-') and re.search(r'-\d\d\d\d-\d\d$', name):
627627
name = "%s-%s" % (name, rev)
628628
if rev and not name.startswith('charter-') and re.search('[0-9]{1,2}-[0-9]{2}', rev):
629629
name = "%s-%s" % (name, rev[:-3])
@@ -658,7 +658,7 @@ def document_html(request, name, rev=None):
658658
return render(request, "doc/document_html.html", {"doc":doc, "top":top, "navbar_mode":"navbar-static-top", })
659659

660660
def check_doc_email_aliases():
661-
pattern = re.compile('^expand-(.*?)(\..*?)?@.*? +(.*)$')
661+
pattern = re.compile(r'^expand-(.*?)(\..*?)?@.*? +(.*)$')
662662
good_count = 0
663663
tot_count = 0
664664
with open(settings.DRAFT_VIRTUAL_PATH,"r") as virtual_file:
@@ -673,9 +673,9 @@ def check_doc_email_aliases():
673673

674674
def get_doc_email_aliases(name):
675675
if name:
676-
pattern = re.compile('^expand-(%s)(\..*?)?@.*? +(.*)$'%name)
676+
pattern = re.compile(r'^expand-(%s)(\..*?)?@.*? +(.*)$'%name)
677677
else:
678-
pattern = re.compile('^expand-(.*?)(\..*?)?@.*? +(.*)$')
678+
pattern = re.compile(r'^expand-(.*?)(\..*?)?@.*? +(.*)$')
679679
aliases = []
680680
with open(settings.DRAFT_VIRTUAL_PATH,"r") as virtual_file:
681681
for line in virtual_file.readlines():

ietf/person/name.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def initials(name):
6767
given += " "+middle
6868
# Don't use non-word characters as initials.
6969
# Example: The Bulgarian transcribed name "'Rnest Balkanska" should not have an initial of "'".
70-
given = re.sub('[^ .\w]', '', given)
70+
given = re.sub(r'[^ .\w]', '', given)
7171
initials = " ".join([ n[0].upper()+'.' for n in given.split() ])
7272
return initials
7373

ietf/redirects/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def redirect(request, path="", script=""):
3030
continue
3131
if fc[0] in rparam:
3232
remove_args.append(fc[0])
33-
num = re.match('(\d+)', rparam[fc[0]])
33+
num = re.match(r'(\d+)', rparam[fc[0]])
3434
if (num and int(num.group(1))) or (num is None):
3535
cmd = flag
3636
break
@@ -64,8 +64,8 @@ def redirect(request, path="", script=""):
6464
# contains non-ASCII characters. The old scripts didn't support
6565
# non-ASCII characters anyway, so there's no need to handle
6666
# them fully correctly in these redirects.
67-
url += str(rest % rparam)
68-
url += "/"
67+
(rest % rparam).encode('ascii')
68+
url += (rest % rparam) + "/"
6969
except:
7070
# rest had something in it that request didn't have, so just
7171
# redirect to the root of the tool.

ietf/sync/rfceditor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def parse_queue(response):
5656
events.expandNode(node)
5757
node.normalize()
5858
draft_name = get_child_text(node, "draft").strip()
59-
draft_name = re.sub("(-\d\d)?(.txt){1,2}$", "", draft_name)
59+
draft_name = re.sub(r"(-\d\d)?(.txt){1,2}$", "", draft_name)
6060
date_received = get_child_text(node, "date-received")
6161

6262
state = ""
@@ -306,7 +306,7 @@ def extract_doc_list(parentNode, tagName):
306306
abstract = get_child_text(abstract, "p")
307307

308308
draft = get_child_text(node, "draft")
309-
if draft and re.search("-\d\d$", draft):
309+
if draft and re.search(r"-\d\d$", draft):
310310
draft = draft[0:-3]
311311

312312
if len(node.getElementsByTagName("errata-url")) > 0:

ietf/utils/draft.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def _parse_draftname(self):
191191
name, __ = base.split(".", 1)
192192
else:
193193
name = base
194-
revmatch = re.search("\d\d$", name)
194+
revmatch = re.search(r"\d\d$", name)
195195
if revmatch:
196196
filename = name[:-3]
197197
revision = name[-2:]
@@ -243,36 +243,36 @@ def begpage(pages, page, newpage, line=None):
243243
for line in self.rawlines:
244244
linecount += 1
245245
line = line.rstrip()
246-
if re.search("\[?page [0-9ivx]+\]?[ \t\f]*$", line, re.I):
246+
if re.search(r"\[?page [0-9ivx]+\]?[ \t\f]*$", line, re.I):
247247
pages, page, newpage = endpage(pages, page, newpage, line)
248248
continue
249-
if re.search("\f", line, re.I):
249+
if re.search(r"\f", line, re.I):
250250
pages, page, newpage = begpage(pages, page, newpage)
251251
continue
252-
if re.search("^ *Internet.Draft.+ .+[12][0-9][0-9][0-9] *$", line, re.I):
252+
if re.search(r"^ *Internet.Draft.+ .+[12][0-9][0-9][0-9] *$", line, re.I):
253253
pages, page, newpage = begpage(pages, page, newpage, line)
254254
continue
255255
# if re.search("^ *Internet.Draft +", line, re.I):
256256
# newpage = True
257257
# continue
258-
if re.search("^ *Draft.+[12][0-9][0-9][0-9] *$", line, re.I):
258+
if re.search(r"^ *Draft.+[12][0-9][0-9][0-9] *$", line, re.I):
259259
pages, page, newpage = begpage(pages, page, newpage, line)
260260
continue
261-
if re.search("^RFC[ -]?[0-9]+.*( +)[12][0-9][0-9][0-9]$", line, re.I):
261+
if re.search(r"^RFC[ -]?[0-9]+.*( +)[12][0-9][0-9][0-9]$", line, re.I):
262262
pages, page, newpage = begpage(pages, page, newpage, line)
263263
continue
264-
if re.search("^draft-[-a-z0-9_.]+.*[0-9][0-9][0-9][0-9]$", line, re.I):
264+
if re.search(r"^draft-[-a-z0-9_.]+.*[0-9][0-9][0-9][0-9]$", line, re.I):
265265
pages, page, newpage = endpage(pages, page, newpage, line)
266266
continue
267-
if linecount > 15 and re.search(".{58,}(Jan|Feb|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|Sep|Oct|Nov|Dec) (19[89][0-9]|20[0-9][0-9]) *$", line, re.I):
267+
if linecount > 15 and re.search(r".{58,}(Jan|Feb|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|Sep|Oct|Nov|Dec) (19[89][0-9]|20[0-9][0-9]) *$", line, re.I):
268268
pages, page, newpage = begpage(pages, page, newpage, line)
269269
continue
270-
if newpage and re.search("^ *draft-[-a-z0-9_.]+ *$", line, re.I):
270+
if newpage and re.search(r"^ *draft-[-a-z0-9_.]+ *$", line, re.I):
271271
pages, page, newpage = begpage(pages, page, newpage, line)
272272
continue
273-
if re.search("^[^ \t]+", line):
273+
if re.search(r"^[^ \t]+", line):
274274
sentence = True
275-
if re.search("[^ \t]", line):
275+
if re.search(r"[^ \t]", line):
276276
if newpage:
277277
# 36 is a somewhat arbitrary count for a 'short' line
278278
shortthis = len(line.strip()) < 36 # 36 is a somewhat arbitrary count for a 'short' line
@@ -300,7 +300,7 @@ def begpage(pages, page, newpage, line=None):
300300
# ----------------------------------------------------------------------
301301
def get_pagecount(self):
302302
if self._pagecount == None:
303-
label_pages = len(re.findall("\[page [0-9ixldv]+\]", self.text, re.I))
303+
label_pages = len(re.findall(r"\[page [0-9ixldv]+\]", self.text, re.I))
304304
count_pages = len(self.pages)
305305
if label_pages > count_pages/2:
306306
self._pagecount = label_pages
@@ -343,7 +343,7 @@ def get_formal_languages(self):
343343
def get_status(self):
344344
if self._status == None:
345345
for line in self.lines[:10]:
346-
status_match = re.search("^\s*Intended [Ss]tatus:\s*(.*?) ", line)
346+
status_match = re.search(r"^\s*Intended [Ss]tatus:\s*(.*?) ", line)
347347
if status_match:
348348
self._status = status_match.group(1)
349349
break
@@ -416,8 +416,8 @@ def get_creation_date(self):
416416
def get_abstract(self):
417417
if self._abstract:
418418
return self._abstract
419-
abstract_re = re.compile('^(\s*)abstract', re.I)
420-
header_re = re.compile("^(\s*)([0-9]+\.? |Appendix|Status of|Table of|Full Copyright|Copyright|Intellectual Property|Acknowled|Author|Index|Disclaimer).*", re.I)
419+
abstract_re = re.compile(r'^(\s*)abstract', re.I)
420+
header_re = re.compile(r"^(\s*)([0-9]+\.? |Appendix|Status of|Table of|Full Copyright|Copyright|Intellectual Property|Acknowled|Author|Index|Disclaimer).*", re.I)
421421
begin = False
422422
abstract = []
423423
abstract_indent = 0
@@ -446,7 +446,7 @@ def get_abstract(self):
446446

447447

448448
def _check_abstract_indent(self, abstract, indent):
449-
indentation_re = re.compile('^(\s)*')
449+
indentation_re = re.compile(r'^(\s)*')
450450
indent_lines = []
451451
for line in abstract.split('\n'):
452452
if line:
@@ -807,7 +807,7 @@ def dotexp(s):
807807
_debug( "Cut: '%s'" % form[beg:end])
808808
author_match = re.search(authpat, columns[col].strip()).group(1)
809809
_debug( "AuthMatch: '%s'" % (author_match,))
810-
if re.search('\(.*\)$', author_match.strip()):
810+
if re.search(r'\(.*\)$', author_match.strip()):
811811
author_match = author_match.rsplit('(',1)[0].strip()
812812
if author_match in companies_seen:
813813
companies[i] = authors[i]
@@ -887,7 +887,7 @@ def dotexp(s):
887887
# for a in authors:
888888
# if a and a not in companies_seen:
889889
# _debug("Search for: %s"%(r"(^|\W)"+re.sub("\.? ", ".* ", a)+"(\W|$)"))
890-
authmatch = [ a for a in authors[i+1:] if a and not a.lower() in companies_seen and (re.search((r"(?i)(^|\W)"+re.sub("[. ]+", ".*", a)+"(\W|$)"), line.strip()) or acronym_match(a, line.strip()) )]
890+
authmatch = [ a for a in authors[i+1:] if a and not a.lower() in companies_seen and (re.search((r"(?i)(^|\W)"+re.sub(r"[. ]+", ".*", a)+r"(\W|$)"), line.strip()) or acronym_match(a, line.strip()) )]
891891

892892
if authmatch:
893893
_debug(" ? Other author or company ? : %s" % authmatch)
@@ -915,9 +915,9 @@ def columnify(l):
915915
column = l.replace('\t', 8 * ' ')[max(0, beg - 1):end].strip()
916916
except:
917917
column = l
918-
column = re.sub(" *(?:\(at\)| <at> | at ) *", "@", column)
919-
column = re.sub(" *(?:\(dot\)| <dot> | dot ) *", ".", column)
920-
column = re.sub("&cisco.com", "@cisco.com", column)
918+
column = re.sub(r" *(?:\(at\)| <at> | at ) *", "@", column)
919+
column = re.sub(r" *(?:\(dot\)| <dot> | dot ) *", ".", column)
920+
column = re.sub(r"&cisco.com", "@cisco.com", column)
921921
column = column.replace("\xa0", " ")
922922
return column
923923

@@ -1003,13 +1003,13 @@ def columnify(l):
10031003
def get_title(self):
10041004
if self._title:
10051005
return self._title
1006-
match = re.search('(?:\n\s*\n\s*)((.+\n){0,2}(.+\n*))(\s+<?draft-\S+\s*\n)\s*\n', self.pages[0])
1006+
match = re.search(r'(?:\n\s*\n\s*)((.+\n){0,2}(.+\n*))(\s+<?draft-\S+\s*\n)\s*\n', self.pages[0])
10071007
if not match:
1008-
match = re.search('(?:\n\s*\n\s*)<?draft-\S+\s*\n*((.+\n){1,3})\s*\n', self.pages[0])
1008+
match = re.search(r'(?:\n\s*\n\s*)<?draft-\S+\s*\n*((.+\n){1,3})\s*\n', self.pages[0])
10091009
if not match:
1010-
match = re.search('(?:\n\s*\n\s*)((.+\n){0,2}(.+\n*))(\s*\n){2}', self.pages[0])
1010+
match = re.search(r'(?:\n\s*\n\s*)((.+\n){0,2}(.+\n*))(\s*\n){2}', self.pages[0])
10111011
if not match:
1012-
match = re.search('(?i)(.+\n|.+\n.+\n)(\s*status of this memo\s*\n)', self.pages[0])
1012+
match = re.search(r'(?i)(.+\n|.+\n.+\n)(\s*status of this memo\s*\n)', self.pages[0])
10131013
if match:
10141014
title = match.group(1)
10151015
title = title.strip()
@@ -1147,10 +1147,10 @@ def old_get_refs( self ):
11471147
para += " "
11481148
para += line
11491149
refs += [ para ]
1150-
rfc_match = re.search("(?i)rfc ?\d+", para)
1150+
rfc_match = re.search(r"(?i)rfc ?\d+", para)
11511151
if rfc_match:
11521152
rfcrefs += [ rfc_match.group(0).replace(" ","").lower() ]
1153-
draft_match = re.search("draft-[a-z0-9-]+", para)
1153+
draft_match = re.search(r"draft-[a-z0-9-]+", para)
11541154
if draft_match:
11551155
draft = draft_match.group(0).lower()
11561156
if not draft in draftrefs:
@@ -1185,7 +1185,7 @@ def getmeta(fn):
11851185
if not os.path.exists(filename):
11861186
fn = filename
11871187
while not "-00." in fn:
1188-
revmatch = re.search("-(\d\d)\.", fn)
1188+
revmatch = re.search(r"-(\d\d)\.", fn)
11891189
if revmatch:
11901190
rev = revmatch.group(1)
11911191
prev = "%02d" % (int(rev)-1)
@@ -1312,7 +1312,7 @@ def _main(outfile=sys.stdout):
13121312
# Option processing
13131313
# ----------------------------------------------------------------------
13141314
options = ""
1315-
for line in re.findall("\n +(if|elif) +opt in \[(.+)\]:\s+#(.+)\n", open(sys.argv[0]).read()):
1315+
for line in re.findall(r"\n +(if|elif) +opt in \[(.+)\]:\s+#(.+)\n", open(sys.argv[0]).read()):
13161316
if not options:
13171317
options += "OPTIONS\n"
13181318
options += " %-16s %s\n" % (line[1].replace('"', ''), line[2])

ietf/utils/draft_search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Copyright The IETF Trust 2007, All Rights Reserved
1+
# Copyright The IETF Trust 2007-2019, All Rights Reserved
22
import re
33

44
def normalize_draftname(string):
55
string = string.strip()
6-
string = re.sub("\.txt$","",string)
7-
string = re.sub("-\d\d$","",string)
6+
string = re.sub(r"\.txt$","",string)
7+
string = re.sub(r"-\d\d$","",string)
88
return string

ietf/utils/markup_txt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def markup(content, width=None):
7474
# expand tabs + escape
7575
content = escape(content.expandtabs())
7676

77-
content = re.sub("\n(.+\[Page \d+\])\n\f\n(.+)\n", """\n<span class="m_ftr">\g<1></span>\n<span class="m_hdr">\g<2></span>\n""", content)
78-
content = re.sub("\n(.+\[Page \d+\])\n\s*$", """\n<span class="m_ftr">\g<1></span>\n""", content)
77+
content = re.sub(r"\n(.+\[Page \d+\])\n\f\n(.+)\n", r"""\n<span class="m_ftr">\g<1></span>\n<span class="m_hdr">\g<2></span>\n""", content)
78+
content = re.sub(r"\n(.+\[Page \d+\])\n\s*$", r"""\n<span class="m_ftr">\g<1></span>\n""", content)
7979
# remove remaining FFs (to be valid XHTML)
8080
content = content.replace("\f","\n")
8181

82-
content = re.sub("\n\n([0-9]+\\.|[A-Z]\\.[0-9]|Appendix|Status of|Abstract|Table of|Full Copyright|Copyright|Intellectual Property|Acknowled|Author|Index)(.*)(?=\n\n)", """\n\n<span class="m_h">\g<1>\g<2></span>""", content)
82+
content = re.sub(r"\n\n([0-9]+\\.|[A-Z]\\.[0-9]|Appendix|Status of|Abstract|Table of|Full Copyright|Copyright|Intellectual Property|Acknowled|Author|Index)(.*)(?=\n\n)", r"""\n\n<span class="m_h">\g<1>\g<2></span>""", content)
8383

8484
return "<pre>" + content + "</pre>\n"

ietf/utils/pdf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright The IETF Trust 2015-2019, All Rights Reserved
12
import re
23

34
def pdf_pages(filename):
@@ -7,7 +8,7 @@ def pdf_pages(filename):
78
except IOError:
89
return 0
910
for line in infile:
10-
m = re.match('\] /Count ([0-9]+)',line)
11+
m = re.match(r'\] /Count ([0-9]+)',line)
1112
if m:
1213
return int(m.group(1))
1314
return 0

0 commit comments

Comments
 (0)