check-config: use named groups in regexp
In preparation for making this regexp a bit more complicated.
--- a/contrib/check-config.py Thu Jun 15 10:36:23 2017 -0700
+++ b/contrib/check-config.py Thu Jun 15 10:38:19 2017 -0700
@@ -16,12 +16,12 @@
configre = re.compile(r'''
# Function call
- ui\.config(|int|bool|list)\(
+ ui\.config(?P<ctype>|int|bool|list)\(
# First argument.
- ['"](\S+)['"],\s*
+ ['"](?P<section>\S+)['"],\s*
# Second argument
- ['"](\S+)['"](,\s+
- (?:default=)?(\S+?))?
+ ['"](?P<option>\S+)['"](,\s+
+ (?:default=)?(?P<default>\S+?))?
\)''', re.VERBOSE | re.MULTILINE)
configpartialre = (r"""ui\.config""")
@@ -81,11 +81,11 @@
line = carryover + l
m = configre.search(line)
if m:
- ctype = m.group(1)
+ ctype = m.group('ctype')
if not ctype:
ctype = 'str'
- name = m.group(2) + "." + m.group(3)
- default = m.group(5)
+ name = m.group('section') + "." + m.group('option')
+ default = m.group('default')
if default in (None, 'False', 'None', '0', '[]', '""', "''"):
default = ''
if re.match('[a-z.]+$', default):