def rm(event): try: key, match = event.rest.split(" ", 1) except ValueError: return nr = 0 store = Store() for fn in store.all(key): obj = Object().load(fn) if key not in obj: continue if match not in obj[key]: continue obj.deleted = True obj.sync() nr += 1 event.ok(nr)
def restore(event): try: key, match = event.args except ValueError: return nr = 0 store = Store() for fn in store.all(*event.args): obj = Object().load(fn) if key not in obj: continue if match not in obj[key]: continue if "deleted" not in obj: continue obj.deleted = False obj.sync() nr += 1 p.ok(nr)