Пример #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)