Exemple #1
0
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
Exemple #2
0
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)
Exemple #3
0
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)
Exemple #4
0
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