コード例 #1
0
ファイル: mytodo.py プロジェクト: itchyporcupine/MyToDo
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)
コード例 #2
0
ファイル: mytodo.py プロジェクト: itchyporcupine/MyToDo
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)
コード例 #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"
コード例 #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)
コード例 #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)  
コード例 #6
0
ファイル: main.py プロジェクト: BenziAhamed/todo
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())
コード例 #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())
コード例 #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))
コード例 #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()
コード例 #10
0
ファイル: main.py プロジェクト: anaderi/TodoFlow
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)
コード例 #11
0
ファイル: todolist_parser.py プロジェクト: ttscoff/TodoFlow
        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()
コード例 #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)
コード例 #13
0
def tag(item_id, tag, param=None):
    TodoList.tag(item_id, tag, param)
コード例 #14
0
def do(item_id):
    TodoList.do(item_id)
コード例 #15
0
ファイル: main.py プロジェクト: anaderi/TodoFlow
def get_text(item_id):
    return TodoList.get_text(item_id)
コード例 #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:
コード例 #17
0
 def setUp(self):
     TestCase.setUp(self)
     self.tl = TodoList("todo.txt")
コード例 #18
0
ファイル: main.py プロジェクト: anaderi/TodoFlow
def tag(item_id, tag, param=None):
    TodoList.tag(item_id, tag, param)
コード例 #19
0
ファイル: main.py プロジェクト: anaderi/TodoFlow
def do(item_id):
    TodoList.do(item_id)
コード例 #20
0
ファイル: main.py プロジェクト: stefanicarol/lpc
# 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()
コード例 #21
0
def remove(item_id):
    TodoList.remove(item_id)
コード例 #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()
コード例 #23
0
def get_content(item_id):
    return TodoList.get_content(item_id)
コード例 #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
コード例 #25
0
ファイル: main.py プロジェクト: anaderi/TodoFlow
def remove(item_id):
    TodoList.remove(item_id)
コード例 #26
0
ファイル: main.py プロジェクト: anaderi/TodoFlow
def get_content(item_id):
    return TodoList.get_content(item_id)
コード例 #27
0
ファイル: main.py プロジェクト: anaderi/TodoFlow
def edit(item_id, new_content):
    TodoList.edit(item_id, new_content.decode('utf-8'))
コード例 #28
0
ファイル: main.py プロジェクト: mwermuth/TodoFlow
def edit(item_id, new_content):
    TodoList.edit(item_id, new_content)