Source

aodag.tasks / aodag / tasks / commands.py

import sys
import os
from . import apis

def list_tasks(args):
    filename = args.config.get('tasks', 'file')

    if not os.path.exists(filename):
        print("{0} does'nt exists".format(filename))
        sys.exit(1)

    filters = []
    if args.state == 'new':
        filters.append(apis.is_new_task)
    if args.state == 'active':
        filters.append(apis.is_active_task)
    if args.state == 'finished':
        filters.append(apis.is_finished_task)

    with open(filename, "rb") as f:
        tasks = apis.load_tasks(f)
        for task in (t for t in tasks if all(apis.filter_many(filters, t))):
            print(apis.format_task(task))

def add_task(args):
    filename = args.config.get('tasks', 'file')

    if os.path.exists(filename):
        with open(filename, "rb") as f:
            tasks = apis.load_tasks(f)
    else:
        tasks = []

    task = apis.input_task()
    apis.add_task(tasks, task)

    with open(filename, 'wb') as f:
        apis.save_tasks(tasks, f)

def finish_task(args):
    print("finish task")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.