Ejemplo n.º 1
0
def mark_task_as_done(task_id):
    """Marks task as done"""
    list_name = folder + default_listname + list_extension
    todo_list = TodoList(list_name)
    removed_text = todo_list.remove(task_id)
    todo_list.save()

    print "Removed '%s' from %s" % (removed_text, default_listname + list_extension)
Ejemplo n.º 2
0
def add_task(task):
    """Adds an item to the default list"""
    list_name = folder + default_listname + list_extension
    
    todo_list = TodoList(list_name)
    todo_list.add(task)
    todo_list.save()
   
    print "Added to '%s' to %s" % (task, default_listname + list_extension)
Ejemplo n.º 3
0
    def command_loop(self):
        """Main command loop for todo list application"""
        
        self.show_banner()


        # This class manages my todo list
        tdlist = TodoList()


        # Current command the user entered
        command = ""

        # Main command loop - ask for the command and execute it. Quit if user enters 'quit'
        while command != "quit":
            command = raw_input("What is your command: ").strip().lower()
            if not command:
                continue
    
            if command == "quit":
               break

            #print "Executing", command
            if command == 'add':
                self.add_command(tdlist)
            else:
                print "Unknown command:", command
            
            if command =='save':
                self.save_command(tdlist)
            else:
                print "Uknown command:", command

        print "Goodbye"
Ejemplo n.º 4
0
def add_new_subtask(item_id, new_item):
    """
    new_item should be item of type Task, Project, Note or
    string, in that case it's assumed that it's task
    """
    if isinstance(new_item, str):
        new_item = TodoList([Task('- ' + new_item)])
    TodoList.items_by_id[item_id].append_subtasks(new_item)
Ejemplo n.º 5
0
class TestTodolist(TestCase):
    
    def setUp(self):
        TestCase.setUp(self)
        self.tl = TodoList("todo.txt")
    
    def test_dateparser(self):
        tests = ["today", "tomorrow", "2012-02-28_17", "21.4.", "17:30"]
        for i in tests:
            assert isinstance(self.tl.to_date(i), datetime.datetime)  
Ejemplo n.º 6
0
def tag_dependand_action(item_id):
    item = TodoList.get_item(item_id)
    if item.has_tag('@web'):
        action.open(item.get_tag_param('@web'))
    if item.has_tag('@file'):
        action.open(item.get_tag_param('@file'))
    if item.has_any_tags(['@download', '@tvseries']):
        action.alfread_search('pb ' + item.get_content())
    if item.has_any_tags(['@search', '@research']):
        action.alfread_search('g ' + item.get_content())
    action.put_to_clipboard(item.get_content())
Ejemplo n.º 7
0
def tag_dependand_action(item_id):
    item = TodoList.get_item(item_id)
    if item.has_tag('@web'):
        action.open(item.get_tag_param('@web'))
    if item.has_tag('@file'):
        action.open(item.get_tag_param('@file'))
    if item.has_any_tags(['@download', '@tvseries']):
        action.alfread_search('pb ' + item.get_content())
    if item.has_any_tags(['@search', '@research']):
        action.alfread_search('g ' + item.get_content())
    action.put_to_clipboard(item.get_content())
Ejemplo n.º 8
0
def archive(tlist, archive_tlist=None):
    """
    moves @done items to first project of title Archive
    assumes that it exsits
    if `archive_tlist` is not specified puts archived items
    to itself
    """
    done = tlist.filter('@done and project != Archive', remove=True)
    done_list = done.deep_copy().flatten()
    if not archive_tlist:
        archive_tlist = tlist
    arch_id = archive_tlist.find_project_id_by_title('Archive')
    TodoList.items_by_id[arch_id].prepend_subtasks(TodoList(done_list))
Ejemplo n.º 9
0
def main():
    def create_error_monitor():
        class _App(App):
            theme_cls = ThemeManager()
            theme_cls.primary_palette = 'BlueGrey'

            def build(self):
                box = BoxLayout()
                box.add_widget(report)
                return box

        app = _App()
        app.run()

    app = None

    try:
        from todolist import TodoList  # основной класс программы

        # Запуск приложения.
        app = TodoList()
        app.run()
    except Exception:
        from kivy.app import App
        from kivy.uix.boxlayout import BoxLayout

        text_error = traceback.format_exc()
        print(text_error)
        traceback.print_exc(
            file=open(os.path.join(directory, 'error.log'), 'w'))

        if app:
            try:
                app.stop()
            except AttributeError:
                app = None

        def callback_report(*args):
            '''Функция отправки баг-репорта.'''

            try:
                txt = six.moves.urllib.parse.quote(
                    report.txt_traceback.text.encode('utf-8'))
                url = 'https://github.com/%s/issues/new?body=' % NICK_NAME_AND_NAME_REPOSITORY + txt
                webbrowser.open(url)
            except Exception:
                sys.exit(1)

        report = BugReporter(callback_report=callback_report,
                             txt_report=text_error,
                             icon_background='data/images/icon.png')
        if app:
            try:
                app.screen.clear_widgets()
                app.screen.add_widget(report)
            except AttributeError:
                create_error_monitor()
        else:
            create_error_monitor()
Ejemplo n.º 10
0
def tag_dependand_action(item_id):
    item = TodoList.get_item(item_id)

    to_open = ('@mail', '@web', '@file')
    for tag in to_open:
        if item.has_tag(tag):
            action.open(item.get_tag_param(tag))

    content = item.get_content()
    if item.has_any_tags(['@download', '@tvseries', '@comics']):
        action.alfred_search('pb ' + content)
    if item.has_any_tags(['@search', '@research']):
        action.alfred_search('g ' + content)
    action.put_to_clipboard(content)
Ejemplo n.º 11
0
        def todolist():
            """parse list"""
            type_on_top = self.lexer.top().type
            new_item = None

            type_to_constructor = {
                'task': Task,
                'project-title': Project,
                'note': Note,
            }

            # depending on type on top of input
            # construct appropriate object
            if type_on_top == 'newline':
                self.lexer.pop()
                new_item = NewLineItem()
            elif type_on_top in type_to_constructor:
                new_item = parse_item(type_to_constructor[type_on_top])
            elif type_on_top == 'indent':  # begining of sublist
                new_item = parse_sublist()
            elif type_on_top in ('dedent', '$'):
                return TodoList()

            return TodoList([new_item]) + todolist()
Ejemplo n.º 12
0
def from_files(paths):
    """
    Constructs todolist from many files,
    content of the file is inserted to project that has
    file name as title

    paths - collection of path or tab separated string
    """
    if isinstance(paths, str):
        paths = paths.split('\t')
    items = []
    for path in paths:
        path = path.rstrip()
        tlist = from_file(path)
        tlist.indent()
        # set file name as project title
        title = os.path.splitext(os.path.basename(path))[0] + ':'
        p = Project(line=title, sub_tasks=tlist)
        p.source = path  # set source to use in `save` function
        items.append(p)
    return TodoList(items)
Ejemplo n.º 13
0
def tag(item_id, tag, param=None):
    TodoList.tag(item_id, tag, param)
Ejemplo n.º 14
0
def do(item_id):
    TodoList.do(item_id)
Ejemplo n.º 15
0
def get_text(item_id):
    return TodoList.get_text(item_id)
Ejemplo n.º 16
0
import json
import curses

from todolist import TodoItem, TodoList
import argutils

args = argutils.get_args()

if args.list:
    # TODO: List
    sys.exit(0)

if args.new:
    # Determine list name. Defaults to filename given.
    name = args.name if args.name else args.new.replace('.json', '')
    todos = TodoList([], name)

    # Decides where file will be saved, locally or globally.
    if args.is_global:
        prefix = os.environ['HOME'] + "/.corc/"
        if not os.path.isdir(prefix):
            os.mkdir(prefix)
    else:
        prefix = "./"

    FILE = prefix + args.new.replace('.json', '') + ".json"

elif args.using:
    # TODO
    pass
else:
Ejemplo n.º 17
0
 def setUp(self):
     TestCase.setUp(self)
     self.tl = TodoList("todo.txt")
Ejemplo n.º 18
0
def tag(item_id, tag, param=None):
    TodoList.tag(item_id, tag, param)
Ejemplo n.º 19
0
def do(item_id):
    TodoList.do(item_id)
Ejemplo n.º 20
0
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

from todolist import TodoList

p = TodoList('Tarefas de Casa')
p.addItem()
p.addItem()
p.addItem()
p.addItem()
p.executarTarefa()
p.tarefasStatus()
p.imprimir()
Ejemplo n.º 21
0
def remove(item_id):
    TodoList.remove(item_id)
Ejemplo n.º 22
0
        result_sentence = todolist.clear_confirmed(intent_message)
        hermes.publish_end_session(intent_message.session_id, result_sentence)

    elif intentname == user_intent("showTodoList"):
        result_sentence = todolist.show()
        hermes.publish_end_session(intent_message.session_id, result_sentence)

    elif intentname == user_intent("sendTodoList"):
        result_sentence = todolist.send()
        hermes.publish_end_session(intent_message.session_id, result_sentence)


def intent_not_recognized_callback(hermes, intent_message):
    configure_message = dialogue.DialogueConfiguration().disable_intent(
        user_intent("confirmTodoList"))
    hermes.configure_dialogue(configure_message)
    todolist.wanted_intents = []
    hermes.publish_end_session({
        'sessionId': intent_message.session_id,
        'text': "Die Tuhdu-Liste wurde nicht gelöscht."
    })


if __name__ == "__main__":
    config = read_configuration_file("config.ini")
    todolist = TodoList(config)
    with Hermes("localhost:1883") as h:
        h.subscribe_intents(intent_callback)
        h.subscribe_intent_not_recognized(intent_not_recognized_callback)
        h.start()
Ejemplo n.º 23
0
def get_content(item_id):
    return TodoList.get_content(item_id)
Ejemplo n.º 24
0
from cli import TodoListCLI
from storage import load
from todolist import TodoList, Todo

todolist = TodoList()

predefined_todos = load()

for todo in predefined_todos:
    todolist.add(todo)

todolist_cli = TodoListCLI(todolist)

if __name__ == "__main__":
    try:
        todolist_cli.run()
    except KeyboardInterrupt:
        pass
Ejemplo n.º 25
0
def remove(item_id):
    TodoList.remove(item_id)
Ejemplo n.º 26
0
def get_content(item_id):
    return TodoList.get_content(item_id)
Ejemplo n.º 27
0
def edit(item_id, new_content):
    TodoList.edit(item_id, new_content.decode('utf-8'))
Ejemplo n.º 28
0
def edit(item_id, new_content):
    TodoList.edit(item_id, new_content)