#NEWLINE# def expand_args( command ) : #NEWLINE# #INDENT# 'Parses command strings and returns a Popen-ready list.' #NEWLINE# if isinstance ( command , ( str , unicode ) ) : #NEWLINE# #INDENT# splitter = shlex . shlex ( command . encode ( 'utf-8' ) ) #NEWLINE# splitter . whitespace = '|' #NEWLINE# splitter . whitespace_split = True #NEWLINE# command = [ ] #NEWLINE# while True : #NEWLINE# #INDENT# token = splitter . get_token ( ) #NEWLINE# if token : #NEWLINE# #INDENT# command . append ( token ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# command = list ( map ( shlex . split , command ) ) #NEWLINE# #UNINDENT# return command