def get_parens(line,retlevel=<NUM_LIT:0>,retblevel=<NUM_LIT:0>):
if len(line) == <NUM_LIT:0>: return line<EOL>parenstr = '<STR_LIT>'<EOL>level = <NUM_LIT:0><EOL>blevel = <NUM_LIT:0><EOL>for char in line:<EOL><INDENT>if char == '<STR_LIT:(>':<EOL><INDENT>level += <NUM_LIT:1><EOL><DEDENT>elif char == '<STR_LIT:)>':<EOL><INDENT>level -= <NUM_LIT:1><EOL><DEDENT>elif char == '<STR_LIT:[>':<EOL><INDENT>blevel += <NUM_LIT:1><EOL><DEDENT>elif char == '<STR_LIT:]>':<EOL><INDENT>blevel -= <NUM_LIT:1><EOL><DEDENT>elif (char.isalpha() or char == '<STR_LIT:_>' or char == '<STR_LIT::>' or char == '<STR_LIT:U+002C>' <EOL>or char == '<STR_LIT:U+0020>') and level == retlevel and blevel == retblevel:<EOL><INDENT>return parenstr<EOL><DEDENT>parenstr = parenstr + char<EOL><DEDENT>if level == retlevel and blevel == retblevel: return parenstr    <EOL>raise Exception("<STR_LIT>".format(line))<EOL>
By default akes a string starting with an open parenthesis and returns the portion
of the string going to the corresponding close parenthesis. If retlevel != 0 then
will return when that level (for parentheses) is reached. Same for retblevel.