Exemplo n.º 1
0
def params_filter(params,
                  delimiter='&',
                  charset='utf-8',
                  excludes=['sign', 'sign_type']):
    if six.PY3:
        ks = sorted(params)
    else:
        ks = params.keys()
        ks.sort()
    newparams = {}
    prestr = ''
    if params.get('input_charset', None):
        charset = params['input_charset']
    for k in ks:
        v = params[k]
        if k not in excludes and v != '':
            newparams[k] = v
            if six.PY3:
                k = smart_unicode(k)
                v = smart_unicode(v)
            prestr += '%s=%s%s' % (k, v, delimiter)
    prestr = prestr[:-1]
    return newparams, prestr
Exemplo n.º 2
0
def params_encoding(params, charset='utf-8'):
    newparams = {}
    for k, v in params.items():
        newparams[k] = smart_unicode(v)
    return newparams
Exemplo n.º 3
0
def params_encoding(params, charset='utf-8'):
    newparams = {}
    for k, v in params.items():
        newparams[k] = smart_unicode(v)
    return newparams