[Cvsshell-devel] CVS: cvsshell/src basic_cmds.py,1.10,1.11 utils.py,1.4,1.5
Status: Beta
Brought to you by:
stefanheimann
From: Stefan H. <ste...@us...> - 2002-03-08 11:32:19
|
Update of /cvsroot/cvsshell/cvsshell/src In directory usw-pr-cvs1:/tmp/cvs-serv27240/src Modified Files: basic_cmds.py utils.py Log Message: splitquotes is now called splitquoted and works also for single quotes Index: basic_cmds.py =================================================================== RCS file: /cvsroot/cvsshell/cvsshell/src/basic_cmds.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** basic_cmds.py 8 Mar 2002 11:12:29 -0000 1.10 --- basic_cmds.py 8 Mar 2002 11:32:16 -0000 1.11 *************** *** 468,472 **** cvsGlobOpts = 'HQqrwlntvb:T:e:d:fz:as:' s = cvsGlobOpts+cvsCmdOpts+cmdOpts ! (opts, rest) = getopt.getopt(utils.splitquotes(args), s) cvsGlobOptstr = cvsCmdOptstr = '' cmdOptDict = {} --- 468,472 ---- cvsGlobOpts = 'HQqrwlntvb:T:e:d:fz:as:' s = cvsGlobOpts+cvsCmdOpts+cmdOpts ! (opts, rest) = getopt.getopt(utils.splitquoted(args), s) cvsGlobOptstr = cvsCmdOptstr = '' cmdOptDict = {} Index: utils.py =================================================================== RCS file: /cvsroot/cvsshell/cvsshell/src/utils.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** utils.py 8 Mar 2002 11:12:29 -0000 1.4 --- utils.py 8 Mar 2002 11:32:16 -0000 1.5 *************** *** 136,147 **** ! _splitRE = re.compile(r'("(?:[^"\\]+|\\.)*"|\S+)') ! def splitquotes(str): """Splits str on whitespace except when a quoted string is encountered. # Example: splitquotes('foo "foo \"bar\""') => ['foo','"foo \"bar\""'] """ res = [] ! for x in _splitRE.split(str): x = x.strip() if x: res.append(x) # not only whitespace --- 136,149 ---- ! def splitquoted(str): """Splits str on whitespace except when a quoted string is encountered. # Example: splitquotes('foo "foo \"bar\""') => ['foo','"foo \"bar\""'] """ + doubleQ = r'"(?:[^"\\]+|\\.)*"' + singleQ = r"'(?:[^'\\]+|\\.)*'" + splitRE = re.compile(r'(%s|%s|\S+)' % (doubleQ, singleQ)) res = [] ! for x in splitRE.split(str): x = x.strip() if x: res.append(x) # not only whitespace |