def finish(id): with DBConn() as c: c.execute("UPDATE task SET finished = ? WHERE id = ?;", (datetime.datetime.utcnow(), id)) rm_tag(c, "started", id) rm_tag(c, "open", id) add_tag(c, "closed", id) print_tasks(c, [id])
def mod(id, priority=None, tags=None, neg_tags=None): with DBConn() as c: if priority or priority == 0: c.execute("UPDATE task SET priority = ? WHERE id = ?", (priority, id)) for tag in tags or []: add_tag(c, tag, id) for tag in neg_tags or []: rm_tag(c, tag, id)
def add(description, priority=None, tags=None): with DBConn() as c: id = c.execute( "INSERT INTO task VALUES (null, ?, ?, ?, NULL, NULL);", (description, priority, datetime.datetime.utcnow()) ).lastrowid for tag in tags + ["open"]: add_tag(c, tag, id) print_tasks(c, [id])
def start(id): with DBConn() as c: c.execute("UPDATE task SET started = ? WHERE id = ?;", (datetime.datetime.utcnow(), id)) add_tag(c, "started", id) print_tasks(c, [id])