import os import os.path as osp import datetime from util import no_parents,get_drives def build(after,*starts): if isinstance(after,datetime.datetime): after = after.timestamp() var_unsubbed = map(osp.expandvars,starts) abs_paths = map(osp.abspath,var_unsubbed) starts = list(no_parents(abs_paths)) ret = [] for path in starts: for root,dirs,files in os.walk(path,topdown=True): try: dirs[:] = list(filter( lambda p: osp.getmtime(osp.join(root,p)) > after, dirs )) ret += [osp.join(root,file) for file in files] except: print('Error',root,sep= ': ') return ret def build_ext(ext,paths): ret = {} for path in paths: if path.endswith(ext): name = osp.basename(path) try: ret[name].append(path) except KeyError: ret[name] = [path] return ret