def dummy(paper, force, pattern): paper_name = get_paper(paper) paper = activepapers.storage.ActivePaper(paper_name, 'r') deps = paper.dependency_graph() pattern = process_patterns(pattern) if not pattern: return names = set() for item in paper.iter_items(): if any(p.match(item.name[1:]) for p in pattern): names.add(item.name) paper.close() if not names: return names = sorted(names) if not force: for name in names: sys.stdout.write(name + '\n') while True: reply = raw_input("Replace by dummy datasets? (y/n) ") if reply in "yn": break if reply == 'n': return paper = activepapers.storage.ActivePaper(paper_name, 'r+') for name in names: try: paper.replace_by_dummy(name) except: sys.stderr.write("Can't replace %s by dummy\n" % name) raise paper.close()
def dummy(paper, force, pattern): paper_name = get_paper(paper) paper = activepapers.storage.ActivePaper(paper_name, 'r') deps = paper.dependency_graph() pattern = process_patterns(pattern) if not pattern: return names = set() for item in paper.iter_items(): if any(p.match(item.name[1:]) for p in pattern): names.add(item.name) paper.close() if not names: return names = sorted(names) if not force: for name in names: sys.stdout.write(name + '\n') while True: reply = raw_input("Replace by dummy datasets? (y/n) ") if reply in "yn": break if reply == 'n': return paper = activepapers.storage.ActivePaper(paper_name, 'r+') for name in names: try: paper.replace_by_dummy(name) except: sys.stderr.write("Can't replace %s by dummy\n" % name) raise paper.close()
def rm(paper, force, pattern): paper_name = get_paper(paper) paper = activepapers.storage.ActivePaper(paper_name, 'r') deps = paper.dependency_graph() pattern = process_patterns(pattern) if not pattern: return names = set() for item in it.chain(paper.iter_items(), paper.iter_groups()): if any(p.match(item.name[1:]) for p in pattern): names.add(item.name) paper.close() if not names: return while True: new_names = set() for name in names: for dep in deps[name]: new_names.add(dep) if new_names - names: names |= new_names else: break names = sorted(names) if not force: for name in names: sys.stdout.write(name + '\n') while True: reply = raw_input("Delete ? (y/n) ") if reply in "yn": break if reply == 'n': return paper = activepapers.storage.ActivePaper(paper_name, 'r+') most_recent_group = None for name in names: if most_recent_group and name.startswith(most_recent_group): continue if isinstance(paper.file[name], h5py.Group): most_recent_group = name try: del paper.file[name] except: sys.stderr.write("Can't delete %s\n" % name) paper.close()
def rm(paper, force, pattern): paper_name = get_paper(paper) paper = activepapers.storage.ActivePaper(paper_name, 'r') deps = paper.dependency_graph() pattern = process_patterns(pattern) if not pattern: return names = set() for item in it.chain(paper.iter_items(), paper.iter_groups()): if any(p.match(item.name[1:]) for p in pattern): names.add(item.name) paper.close() if not names: return while True: new_names = set() for name in names: for dep in deps[name]: new_names.add(dep) if new_names - names: names |= new_names else: break names = sorted(names) if not force: for name in names: sys.stdout.write(name + '\n') while True: reply = raw_input("Delete ? (y/n) ") if reply in "yn": break if reply == 'n': return paper = activepapers.storage.ActivePaper(paper_name, 'r+') most_recent_group = None for name in names: if most_recent_group and name.startswith(most_recent_group): continue if isinstance(paper.file[name], h5py.Group): most_recent_group = name try: del paper.file[name] except: sys.stderr.write("Can't delete %s\n" % name) paper.close()