changeset 32848:485b8e87e244

check-config: use named groups in regexp In preparation for making this regexp a bit more complicated.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 15 Jun 2017 10:38:19 -0700
parents e5a6a540ae63
children e9fc5550be46
files contrib/check-config.py
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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):