def parse(args,boolargs=None,nonstringargs=None,needsescape=None,notsplit=None): if boolargs==None: boolargs=[] if nonstringargs==None: nonstringargs=dict() if needsescape==None: needsescape=[] if notsplit==None: notsplit=[] listargs, keyargs= parametrize(*[unquote(unistr(a)) for a in args],**{'escapelists':needsescape,'notsplit':notsplit}) keyargsdict=translate(keyargs,boolargs,nonstringargs) return listargs, keyargsdict
def unescape(arg): arg=unistr(arg) q=arg.split("'") qlist=[] for qi in q: l=qi.split('\n') llist=[] for li in l: if li.endswith('\\'): llist+=[eval("'%s'" %(li.replace('\\','\\\\'))).replace('\\\\','\\') ] else: llist+=[eval("'%s'" %(li)) ] qlist+=['\n'.join(llist)] return "'".join(qlist)
def unescape(arg): arg = unistr(arg) q = arg.split("'") qlist = [] for qi in q: l = qi.split('\n') llist = [] for li in l: if li.endswith('\\'): llist += [ eval("'%s'" % (li.replace('\\', '\\\\'))).replace( '\\\\', '\\') ] else: llist += [eval("'%s'" % (li))] qlist += ['\n'.join(llist)] return "'".join(qlist)
def parse(args, boolargs=None, nonstringargs=None, needsescape=None, notsplit=None): if boolargs == None: boolargs = [] if nonstringargs == None: nonstringargs = dict() if needsescape == None: needsescape = [] if notsplit == None: notsplit = [] listargs, keyargs = parametrize( *[unquote(unistr(a)) for a in args], **{ 'escapelists': needsescape, 'notsplit': notsplit }) keyargsdict = translate(keyargs, boolargs, nonstringargs) return listargs, keyargsdict