예제 #1
0
 def save_ckl(cls, ckl, myDir):
     '''
     '''
     if (os.path.exists(myDir)):
         content = read_file_content(fn=myDir, op='r+')
         arr = json.loads(content)
         arr.extend(ckl)
         arr = elel.cond_select_all(arr, cond_func=cond_persistant)
         arr = elel.cond_remove_all(arr, cond_func=cond_expired)
         arr = sort_ckl(arr)
         write_to_file(fn=myDir, content=json.dumps(arr), op='w+')
     else:
         arr = ckl
         arr = elel.cond_select_all(arr, cond_func=cond_persistant)
         arr = elel.cond_remove_all(arr, cond_func=cond_expired)
         write_to_file(fn=myDir, content=json.dumps(arr), op='w+')
예제 #2
0
 def loads(self, myDir):
     if (os.path.exists(myDir)):
         content = read_file_content(fn=myDir, op='r+')
         arr = json.loads(content)
         arr = elel.cond_select_all(arr, cond_func=cond_persistant)
         arr = elel.cond_remove_all(arr, cond_func=cond_expired)
     else:
         arr = []
     self.cktl.extend(arr)
예제 #3
0
def creat_usage_from_code(cd):
    root = ast.parse(cd)
    d = wfsdig(root)
    body = d['body']
    funcs = elel.cond_select_all(d['body'],cond_func=lambda ele:ele['_type'] == 'FunctionDef')
    kl = elel.mapv(funcs,lambda func:func['name'])
    vl = elel.mapv(funcs,lambda func:[func['body'][0]['value']['s']])
    usage = creat_rst(kl,vl)
    return(usage)
예제 #4
0
def get_raw_script_dict(ic,coding='gb2312'):
    rslt = nvbody.show_resp_body(ic,'script',coding=coding,only_print=False)
    arr = xlt.ltdict_to_list(rslt)
    arr = elel.array_map(arr,lambda ele:ele['result'])
    arr = elel.cond_select_all(arr,cond_func=lambda ele:(ele!= None))
    arr = elel.cond_select_all(arr,cond_func=lambda ele:("new Array" in ele))
    arr = elel.array_map(arr,lambda ele:ele.replace('\n','').replace('\r','').replace('\t',''))
    arr = elel.array_map(arr,lambda ele:ele.replace('var','').replace('new Array','').replace('(',"").replace(")","").replace(";",""))
    arr.pop(-1)
    arr = elel.array_map(arr,lambda ele:ele.split("="))
    d = {}
    for each in arr:
        k = each[0].strip("\x20")
        v = each[1].strip("\x20")
        v = convert_token_in_quote(v)
        v = v.split(",")
        v = elel.array_map(v,html.unescape)
        d[k] = v
    return(d)
예제 #5
0
 def remove_non_persistant(self):
     '''
         should only save persistant-flag setted Cookie into jar
     '''
     self.cks = elel.cond_select_all(self.cks, cond_func=cond_persistant)
     self.cks = sort_ckl(arr)