diff --git a/src/utils/str.py b/src/utils/str.py index 274d81d24..8ce149142 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher -# Copyright (c) 2008, James Vega +# Copyright (c) 2008-2009, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -112,36 +112,42 @@ def quoted(s): """Returns a quoted s.""" return '"%s"' % s -def _getSep(s): +_openers = '{[(<' +_closers = '}])>' +def _getSep(s, allowBraces=False): if len(s) < 2: raise ValueError, 'string given to _getSep is too short: %r' % s + if allowBraces: + braces = _closers + else: + braces = _openers + _closers if s.startswith('m') or s.startswith('s'): separator = s[1] else: separator = s[0] - if separator.isalnum() or separator in '{}[]()<>': + if separator.isalnum() or separator in braces: raise ValueError, \ 'Invalid separator: separator must not be alphanumeric or in ' \ - '"{}[]()<>"' + '"%s"' % braces return separator -def _getSplitterRe(s): - separator = _getSep(s) - return re.compile(r'(?