comparison contrib/check-config.py @ 41541:595a67a301ee

check-config: use raw strings for regular expressions This avoids SyntaxWarning on Python 3.8 for invalid \ escapes. Differential Revision: https://phab.mercurial-scm.org/D5826
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 04 Feb 2019 09:34:11 -0800
parents 5519697b71b3
children 2372284d9457
comparison
equal deleted inserted replaced
41540:17a6e063c886 41541:595a67a301ee
23 # Second argument 23 # Second argument
24 ['"](?P<option>\S+)['"](,\s+ 24 ['"](?P<option>\S+)['"](,\s+
25 (?:default=)?(?P<default>\S+?))? 25 (?:default=)?(?P<default>\S+?))?
26 \)''', re.VERBOSE | re.MULTILINE) 26 \)''', re.VERBOSE | re.MULTILINE)
27 27
28 configwithre = re.compile(b''' 28 configwithre = re.compile(br'''
29 ui\.config(?P<ctype>with)\( 29 ui\.config(?P<ctype>with)\(
30 # First argument is callback function. This doesn't parse robustly 30 # First argument is callback function. This doesn't parse robustly
31 # if it is e.g. a function call. 31 # if it is e.g. a function call.
32 [^,]+,\s* 32 [^,]+,\s*
33 ['"](?P<section>\S+)['"],\s* 33 ['"](?P<section>\S+)['"],\s*
59 linenum = 0 59 linenum = 0
60 for l in open(f, 'rb'): 60 for l in open(f, 'rb'):
61 linenum += 1 61 linenum += 1
62 62
63 # check topic-like bits 63 # check topic-like bits
64 m = re.match(b'\s*``(\S+)``', l) 64 m = re.match(br'\s*``(\S+)``', l)
65 if m: 65 if m:
66 prevname = m.group(1) 66 prevname = m.group(1)
67 if re.match(b'^\s*-+$', l): 67 if re.match(br'^\s*-+$', l):
68 sect = prevname 68 sect = prevname
69 prevname = b'' 69 prevname = b''
70 70
71 if sect and prevname: 71 if sect and prevname:
72 name = sect + b'.' + prevname 72 name = sect + b'.' + prevname