Exemple #1
0
 def test_the_brace_pattern(self):
     func = re.compile(build_brace_pattern(5) + "$", re.VERBOSE).match
     for test, result in self.tests:
         if result:
             self.assertTrue(func(test))
         else:
             self.assertFalse(func(test))
Exemple #2
0
def _parse_arglist(argstr):
    # The following is a split re. The string is broken into pieces which are
    # between the recognized strings. Because the re has groups, both the
    # strings and the separators are returned, where the strings are not
    # interesting at all: They are just the commata.
    key = "_parse_arglist"
    if key not in _cache:
        regex = build_brace_pattern(level=3, separators=",")
        _cache[key] = re.compile(regex, flags=re.VERBOSE)
    split = _cache[key].split
    # Note: this list is interspersed with "," and surrounded by ""
    return [x.strip() for x in split(argstr) if x.strip() not in ("", ",")]