예제 #1
0
파일: commands.py 프로젝트: smilliken/mut
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])
예제 #2
0
파일: commands.py 프로젝트: smilliken/mut
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])
예제 #3
0
파일: commands.py 프로젝트: smilliken/mut
def edit(id):
    with DBConn() as c:
        description, = c.execute("SELECT description FROM task WHERE id = ?;", (id,)).fetchone()
        filename = "/tmp/.mut_edit_%s" % id
        with open(filename, "w") as fp:
            fp.write(description)
        subprocess.call("${EDITOR:-nano} %s" % filename, shell=True)
        with open(filename, "r") as fp:
            description = fp.read().strip()
        c.execute("UPDATE task SET description = ? WHERE id = ?;", (description, id))
        print_tasks(c, [id])
예제 #4
0
파일: commands.py 프로젝트: smilliken/mut
def ls(tags=None, neg_tags=None):
    with DBConn() as c:
        query = """
            SELECT id
            FROM task
            WHERE 1=1
        """
        params = []
        for tag, include in [(tag, True) for tag in tags] + [(tag, False) for tag in neg_tags]:
            query += """
                AND ? %s IN (SELECT tag.tag FROM tag WHERE tag.task_id = task.id)
            """ % (
                "" if include else "NOT"
            )
            params.append(tag)
        query += "ORDER BY priority ASC, id ASC;"
        task_ids = [id for id, in c.execute(query, params).fetchall()]
        print_tasks(c, task_ids)
예제 #5
0
def lis(args):
    if len(args) == 2:
        return print_tasks(query_date(date.today()).split("\n")[:-1])
    else:
        atributes = {
            "-d": list_with_date,
            "-w":list_last_week,
            "-lw":list_last_week,
        }
        return atributes.get(args[2], "wrong attribute. check help for help...")(args)
예제 #6
0
파일: commands.py 프로젝트: smilliken/mut
def stop(id):
    with DBConn() as c:
        rm_tag(c, "started", id)
        print_tasks(c, [id])
예제 #7
0
파일: commands.py 프로젝트: smilliken/mut
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])
예제 #8
0
def print_ndone_tasks():
    ndone_tasks = query_done("n").split("\n")[:-1]
    x = {}
    x = print_tasks(tasks=ndone_tasks, task_id_dict=x)
    return x