def update_index(eggs_dir, patches_dir, force=False): index_path = join(patches_dir, 'index.json') if force or not isfile(index_path): index = {} else: index = json.load(open(index_path)) new_index = {} for patch_fn in os.listdir(patches_dir): if not fn_pat.match(patch_fn): continue src_fn, dst_fn = split(patch_fn) dst_path = join(eggs_dir, dst_fn) dst_size = getsize(dst_path) if dst_size < 131072: continue patch_path = join(patches_dir, patch_fn) if dst_size < getsize(patch_path) * 2: continue info = index.get(patch_fn) if info and getmtime(patch_path) == info['mtime']: new_index[patch_fn] = info continue info = info_file(patch_path) info.update(zdiff.info(patch_path)) info['name'] = patch_fn.split('-')[0].lower() new_index[patch_fn] = info with open(index_path, 'w') as f: json.dump(new_index, f, indent=2, sort_keys=True)
def up_to_date(patch_fn): patch_path = join(patches_dir, patch_fn) if not isfile(patch_path): return False info = zdiff.info(patch_path) for t in 'dst', 'src': if getmtime(join(eggs_dir, info[t])) != info[t + '_mtime']: return False return True