예제 #1
0
파일: db.py 프로젝트: bthate/meds
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)
예제 #2
0
파일: db.py 프로젝트: bthate/meds
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)