Exemple #1
0
def dump(event):
    """ dump objects matching the given criteria. """
    if not event._parsed.rest:
        event.reply("dump <prefix>")
        return
    for obj in storage.selected(event):
        event.reply(obj.nice())
Exemple #2
0
def restore(event):
    """ set deleted=False in selected records. """
    nr = 0
    event.nodel = True
    for obj in storage.selected(event):
        obj.deleted = False
        obj.sync()
        nr += 1
    event.ok(nr)
Exemple #3
0
def find(event):
    """ present a list of objects based on prompt input. """
    if not event._parsed.rest:
        event.reply("find <prefix>")
        return
    nr = 0
    for obj in storage.selected(event):
        nr += 1
        event.display(obj, event._parsed.args, str(nr))
Exemple #4
0
def deleted(event):
    """ show deleted records. """
    if not event._parsed.rest:
        event.reply("deleted <prefix>")
        return
    nr = 0
    event.nodel = True
    for obj in storage.selected(event):
        event.display(obj, event._parsed.args, str(nr))
        nr += 1
Exemple #5
0
def yesterday(event):
    """ show objects added yesterday. """
    if not event._parsed.rest:
        event.reply("yesterday <key>")
        return
    event._parsed.start = to_day(day()) - 24 * 60 * 60
    event._parsed.end = to_day(day())
    nr = 1
    for obj in storage.selected(event):
        event.display(obj, event._parsed.args, str(nr))
        nr += 1
Exemple #6
0
def today(event):
    """ show objects logged for today. """
    if not event._parsed.rest:
        event.reply("today <key>")
        return
    event._parsed.start = to_day(day())
    event._parsed.end = time.time()
    nr = 1
    for obj in storage.selected(event):
        event.display(obj, event._parsed.args, str(nr))
        nr += 1
Exemple #7
0
def week(event):
    """ show last week's logged objects. """
    if not event._parsed.rest:
        event.reply("week <key>")
        return
    event._parsed.start = to_day(day()) - 7 * 24 * 60 * 60
    event._parsed.end = time.time()
    nr = 1
    for obj in storage.selected(event):
        event.display(obj, event._parsed.args, str(nr))
        nr += 1
Exemple #8
0
def rm(event):
    """ set deleted flag on objects. """
    if not event._parsed.index and not event._parsed.want:
        event.reply("rm <key=value> or rm key index=<nr>")
        return
    nr = 0
    for obj in storage.selected(event):
        nr += 1
        obj.deleted = True
        obj.sync()
    event.ok(nr)