changeset 32847:e5a6a540ae63

check-config: use compiled regexp And split the regexp across multiple lines to make it easier to read.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 15 Jun 2017 10:36:23 -0700
parents 7c11869cf23a
children 485b8e87e244
files contrib/check-config.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-config.py	Thu Jun 15 10:46:39 2017 -0700
+++ b/contrib/check-config.py	Thu Jun 15 10:36:23 2017 -0700
@@ -14,8 +14,16 @@
 foundopts = {}
 documented = {}
 
-configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"],\s*"""
-            r"""['"](\S+)['"](,\s+(?:default=)?(\S+?))?\)""")
+configre = re.compile(r'''
+    # Function call
+    ui\.config(|int|bool|list)\(
+        # First argument.
+        ['"](\S+)['"],\s*
+        # Second argument
+        ['"](\S+)['"](,\s+
+        (?:default=)?(\S+?))?
+    \)''', re.VERBOSE | re.MULTILINE)
+
 configpartialre = (r"""ui\.config""")
 
 def main(args):
@@ -71,7 +79,7 @@
 
             # look for code-like bits
             line = carryover + l
-            m = re.search(configre, line, re.MULTILINE)
+            m = configre.search(line)
             if m:
                 ctype = m.group(1)
                 if not ctype: