def __fill_progress(self,fs,progs): if not progs: return 0 tb = 0 for f in fs: if f[3]: # dir, has some children bd = self.__fill_progress(f[3],progs) f[5] = format_utils.format_progress((bd/f[2])*100) else: # file, update own prog and add to total bd = f[2]*progs[f[1]] f[5] = format_utils.format_progress(progs[f[1]]*100) tb += bd return tb
def __fill_progress(self, fs, progs): if not progs: return 0 tb = 0 for f in fs: if f[3]: # dir, has some children bd = self.__fill_progress(f[3], progs) f[5] = format_utils.format_progress((bd / f[2]) * 100) else: # file, update own prog and add to total bd = f[2] * progs[f[1]] f[5] = format_utils.format_progress(progs[f[1]] * 100) tb += bd return tb
def build_file_list(self, file_tuples,prog,prio): ret = [] retdict = {} diridx = maxint for f in file_tuples: cur = ret ps = f["path"].split("/") fin = ps[-1] for p in ps: if not cur or p != cur[-1][0]: cl = [] if p == fin: ent = [p,f["index"],f["size"],cl,False, format_utils.format_progress(prog[f["index"]]*100), prio[f["index"]]] retdict[f["index"]] = ent else: ent = [p,diridx,-1,cl,False,0,-1] retdict[diridx] = ent diridx-=1 cur.append(ent) cur = cl else: cur = cur[-1][3] self.__build_sizes(ret) self.__fill_progress(ret,prog) return (ret,retdict)
def build_file_list(self, file_tuples, prog, prio): ret = [] retdict = {} diridx = maxint for f in file_tuples: cur = ret ps = f["path"].split("/") fin = ps[-1] for p in ps: if not cur or p != cur[-1][0]: cl = [] if p == fin: ent = [ p, f["index"], f["size"], cl, False, format_utils.format_progress(prog[f["index"]] * 100), prio[f["index"]] ] retdict[f["index"]] = ent else: ent = [p, diridx, -1, cl, False, 0, -1] retdict[diridx] = ent diridx -= 1 cur.append(ent) cur = cl else: cur = cur[-1][3] self.__build_sizes(ret) self.__fill_progress(ret, prog) return (ret, retdict)