Commit cd41fdef authored by MinchinWeb's avatar MinchinWeb

Fix PEP8 E302

expected 2 blank lines, found 1 (above module level defined classes and
functions)
parent 08ff4806
...@@ -19,6 +19,7 @@ from topydo.lib.Todo import Todo ...@@ -19,6 +19,7 @@ from topydo.lib.Todo import Todo
from topydo.lib.TodoFile import TodoFile from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
def load_file(p_filename): def load_file(p_filename):
""" """
Loads a todo file from the given filename and returns a list of todos. Loads a todo file from the given filename and returns a list of todos.
...@@ -26,6 +27,7 @@ def load_file(p_filename): ...@@ -26,6 +27,7 @@ def load_file(p_filename):
todolist = load_file_to_raw_list(p_filename) todolist = load_file_to_raw_list(p_filename)
return [Todo(src) for src in todolist] return [Todo(src) for src in todolist]
def load_file_to_raw_list(p_filename): def load_file_to_raw_list(p_filename):
""" """
Loads a todo file from the given filename and returns a list of todo Loads a todo file from the given filename and returns a list of todo
...@@ -34,6 +36,7 @@ def load_file_to_raw_list(p_filename): ...@@ -34,6 +36,7 @@ def load_file_to_raw_list(p_filename):
todofile = TodoFile(p_filename) todofile = TodoFile(p_filename)
return todofile.read() return todofile.read()
def load_file_to_todolist(p_filename): def load_file_to_todolist(p_filename):
""" """
Loads a todo file to a TodoList instance. Loads a todo file to a TodoList instance.
...@@ -41,10 +44,12 @@ def load_file_to_todolist(p_filename): ...@@ -41,10 +44,12 @@ def load_file_to_todolist(p_filename):
todolist = load_file_to_raw_list(p_filename) todolist = load_file_to_raw_list(p_filename)
return TodoList(todolist) return TodoList(todolist)
def todolist_to_string(p_list): def todolist_to_string(p_list):
""" Converts a todo list to a single string. """ """ Converts a todo list to a single string. """
return '\n'.join([t.source() for t in p_list]) return '\n'.join([t.source() for t in p_list])
def print_view(p_view): def print_view(p_view):
printer = PrettyPrinter() printer = PrettyPrinter()
return printer.print_list(p_view.todos) return printer.print_list(p_view.todos)
...@@ -33,6 +33,7 @@ from test.TestCommand import CommandTest ...@@ -33,6 +33,7 @@ from test.TestCommand import CommandTest
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib import TodoList from topydo.lib import TodoList
class AddCommandTest(CommandTest): class AddCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(AddCommandTest, self).setUp() super(AddCommandTest, self).setUp()
......
...@@ -20,6 +20,7 @@ from topydo.commands.AppendCommand import AppendCommand ...@@ -20,6 +20,7 @@ from topydo.commands.AppendCommand import AppendCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class AppendCommandTest(CommandTest): class AppendCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(AppendCommandTest, self).setUp() super(AppendCommandTest, self).setUp()
......
...@@ -21,6 +21,7 @@ from test.TestCommand import CommandTest ...@@ -21,6 +21,7 @@ from test.TestCommand import CommandTest
from test.Facilities import load_file_to_todolist from test.Facilities import load_file_to_todolist
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class ArchiveCommandTest(CommandTest): class ArchiveCommandTest(CommandTest):
def test_archive(self): def test_archive(self):
todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt") todolist = load_file_to_todolist("test/data/ArchiveCommandTest.txt")
......
...@@ -21,6 +21,7 @@ from topydo.lib.Colors import Colors, NEUTRAL_COLOR ...@@ -21,6 +21,7 @@ from topydo.lib.Colors import Colors, NEUTRAL_COLOR
from topydo.lib.Config import config from topydo.lib.Config import config
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class ColorsTest(TopydoTest): class ColorsTest(TopydoTest):
def test_project_color1(self): def test_project_color1(self):
config(p_overrides={('colorscheme', 'project_color'): '2'}) config(p_overrides={('colorscheme', 'project_color'): '2'})
......
...@@ -19,6 +19,7 @@ import unittest ...@@ -19,6 +19,7 @@ import unittest
from topydo.lib.Utils import escape_ansi from topydo.lib.Utils import escape_ansi
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class CommandTest(TopydoTest): class CommandTest(TopydoTest):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(CommandTest, self).__init__(*args, **kwargs) super(CommandTest, self).__init__(*args, **kwargs)
......
...@@ -19,6 +19,7 @@ import unittest ...@@ -19,6 +19,7 @@ import unittest
from topydo.lib.Config import config from topydo.lib.Config import config
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class ConfigTest(TopydoTest): class ConfigTest(TopydoTest):
def test_config1(self): def test_config1(self):
self.assertEqual(config("test/data/config1").default_command(), 'do') self.assertEqual(config("test/data/config1").default_command(), 'do')
......
...@@ -23,12 +23,15 @@ from topydo.commands.DeleteCommand import DeleteCommand ...@@ -23,12 +23,15 @@ from topydo.commands.DeleteCommand import DeleteCommand
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
def _yes_prompt(self): def _yes_prompt(self):
return "y" return "y"
def _no_prompt(self): def _no_prompt(self):
return "n" return "n"
class DeleteCommandTest(CommandTest): class DeleteCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(DeleteCommandTest, self).setUp() super(DeleteCommandTest, self).setUp()
......
...@@ -20,6 +20,7 @@ from topydo.commands.DepCommand import DepCommand ...@@ -20,6 +20,7 @@ from topydo.commands.DepCommand import DepCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class DepCommandTest(CommandTest): class DepCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(DepCommandTest, self).setUp() super(DepCommandTest, self).setUp()
......
...@@ -21,6 +21,7 @@ from topydo.commands.DepriCommand import DepriCommand ...@@ -21,6 +21,7 @@ from topydo.commands.DepriCommand import DepriCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class DepriCommandTest(CommandTest): class DepriCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(DepriCommandTest, self).setUp() super(DepriCommandTest, self).setUp()
......
...@@ -22,12 +22,15 @@ from topydo.commands.DoCommand import DoCommand ...@@ -22,12 +22,15 @@ from topydo.commands.DoCommand import DoCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
def _yes_prompt(self): def _yes_prompt(self):
return "y" return "y"
def _no_prompt(self): def _no_prompt(self):
return "n" return "n"
class DoCommandTest(CommandTest): class DoCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(DoCommandTest, self).setUp() super(DoCommandTest, self).setUp()
......
...@@ -32,6 +32,7 @@ from topydo.lib.TodoList import TodoList ...@@ -32,6 +32,7 @@ from topydo.lib.TodoList import TodoList
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from topydo.lib.Config import config from topydo.lib.Config import config
class EditCommandTest(CommandTest): class EditCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(EditCommandTest, self).setUp() super(EditCommandTest, self).setUp()
......
...@@ -24,6 +24,7 @@ from test.Facilities import load_file, todolist_to_string, load_file_to_todolist ...@@ -24,6 +24,7 @@ from test.Facilities import load_file, todolist_to_string, load_file_to_todolist
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class FilterTest(TopydoTest): class FilterTest(TopydoTest):
def test_filter03(self): def test_filter03(self):
todo = Todo("(C) Relevant") todo = Todo("(C) Relevant")
...@@ -295,6 +296,7 @@ class FilterTest(TopydoTest): ...@@ -295,6 +296,7 @@ class FilterTest(TopydoTest):
self.assertEqual(todolist_to_string(filtered_todos), self.assertEqual(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
class OrdinalTagFilterTest(TopydoTest): class OrdinalTagFilterTest(TopydoTest):
def setUp(self): def setUp(self):
super(OrdinalTagFilterTest, self).setUp() super(OrdinalTagFilterTest, self).setUp()
...@@ -374,6 +376,7 @@ class OrdinalTagFilterTest(TopydoTest): ...@@ -374,6 +376,7 @@ class OrdinalTagFilterTest(TopydoTest):
self.assertEqual(len(result), 1) self.assertEqual(len(result), 1)
self.assertEqual(result[0].source(), self.todo3) self.assertEqual(result[0].source(), self.todo3)
class PriorityFilterTest(TopydoTest): class PriorityFilterTest(TopydoTest):
def setUp(self): def setUp(self):
super(PriorityFilterTest, self).setUp() super(PriorityFilterTest, self).setUp()
......
...@@ -19,6 +19,7 @@ import unittest ...@@ -19,6 +19,7 @@ import unittest
from topydo.lib.Graph import DirectedGraph from topydo.lib.Graph import DirectedGraph
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class GraphTest(TopydoTest): class GraphTest(TopydoTest):
def setUp(self): def setUp(self):
super(GraphTest, self).setUp() super(GraphTest, self).setUp()
......
...@@ -22,6 +22,7 @@ from topydo.lib.Importance import importance ...@@ -22,6 +22,7 @@ from topydo.lib.Importance import importance
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class ImportanceTest(TopydoTest): class ImportanceTest(TopydoTest):
def test_importance1(self): def test_importance1(self):
todo = Todo("Foo") todo = Todo("Foo")
......
...@@ -18,6 +18,7 @@ from topydo.lib.JsonPrinter import JsonPrinter ...@@ -18,6 +18,7 @@ from topydo.lib.JsonPrinter import JsonPrinter
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class JsonPrinterTest(TopydoTest): class JsonPrinterTest(TopydoTest):
""" """
Tests the functionality of printing a single todo item. Printing a list is Tests the functionality of printing a single todo item. Printing a list is
......
...@@ -24,6 +24,7 @@ from topydo.commands.ListCommand import ListCommand ...@@ -24,6 +24,7 @@ from topydo.commands.ListCommand import ListCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from test.Facilities import load_file_to_todolist from test.Facilities import load_file_to_todolist
class ListCommandTest(CommandTest): class ListCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(ListCommandTest, self).setUp() super(ListCommandTest, self).setUp()
...@@ -217,6 +218,7 @@ class ListCommandTest(CommandTest): ...@@ -217,6 +218,7 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.output, "") self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n") self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
class ListCommandUnicodeTest(CommandTest): class ListCommandUnicodeTest(CommandTest):
def setUp(self): def setUp(self):
super(ListCommandUnicodeTest, self).setUp() super(ListCommandUnicodeTest, self).setUp()
...@@ -233,6 +235,7 @@ class ListCommandUnicodeTest(CommandTest): ...@@ -233,6 +235,7 @@ class ListCommandUnicodeTest(CommandTest):
self.assertEqual(self.output, expected) self.assertEqual(self.output, expected)
class ListCommandJsonTest(CommandTest): class ListCommandJsonTest(CommandTest):
def test_json(self): def test_json(self):
todolist = load_file_to_todolist("test/data/ListCommandTest.txt") todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
...@@ -264,6 +267,7 @@ class ListCommandJsonTest(CommandTest): ...@@ -264,6 +267,7 @@ class ListCommandJsonTest(CommandTest):
self.assertEqual(self.output, jsontext) self.assertEqual(self.output, jsontext)
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def replace_ical_tags(p_text): def replace_ical_tags(p_text):
# replace identifiers with dots, since they're random. # replace identifiers with dots, since they're random.
result = re.sub(r'\bical:....\b', 'ical:....', p_text) result = re.sub(r'\bical:....\b', 'ical:....', p_text)
...@@ -271,6 +275,7 @@ def replace_ical_tags(p_text): ...@@ -271,6 +275,7 @@ def replace_ical_tags(p_text):
return result return result
class ListCommandIcalTest(CommandTest): class ListCommandIcalTest(CommandTest):
def setUp(self): def setUp(self):
self.maxDiff = None self.maxDiff = None
......
...@@ -20,6 +20,7 @@ from topydo.commands.ListContextCommand import ListContextCommand ...@@ -20,6 +20,7 @@ from topydo.commands.ListContextCommand import ListContextCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from test.Facilities import load_file_to_todolist from test.Facilities import load_file_to_todolist
class ListContextCommandTest(CommandTest): class ListContextCommandTest(CommandTest):
def test_contexts1(self): def test_contexts1(self):
todolist = load_file_to_todolist("test/data/TodoListTest.txt") todolist = load_file_to_todolist("test/data/TodoListTest.txt")
......
...@@ -20,6 +20,7 @@ from topydo.commands.ListProjectCommand import ListProjectCommand ...@@ -20,6 +20,7 @@ from topydo.commands.ListProjectCommand import ListProjectCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from test.Facilities import load_file_to_todolist from test.Facilities import load_file_to_todolist
class ListProjectCommandTest(CommandTest): class ListProjectCommandTest(CommandTest):
def test_projects1(self): def test_projects1(self):
todolist = load_file_to_todolist("test/data/TodoListTest.txt") todolist = load_file_to_todolist("test/data/TodoListTest.txt")
......
...@@ -22,6 +22,7 @@ from topydo.commands.PostponeCommand import PostponeCommand ...@@ -22,6 +22,7 @@ from topydo.commands.PostponeCommand import PostponeCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class PostponeCommandTest(CommandTest): class PostponeCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(PostponeCommandTest, self).setUp() super(PostponeCommandTest, self).setUp()
......
...@@ -21,6 +21,7 @@ from topydo.commands.PriorityCommand import PriorityCommand ...@@ -21,6 +21,7 @@ from topydo.commands.PriorityCommand import PriorityCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class PriorityCommandTest(CommandTest): class PriorityCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(PriorityCommandTest, self).setUp() super(PriorityCommandTest, self).setUp()
......
...@@ -22,6 +22,7 @@ from topydo.lib.Recurrence import advance_recurring_todo, NoRecurrenceException ...@@ -22,6 +22,7 @@ from topydo.lib.Recurrence import advance_recurring_todo, NoRecurrenceException
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class RecurrenceTest(TopydoTest): class RecurrenceTest(TopydoTest):
def setUp(self): def setUp(self):
super(RecurrenceTest, self).setUp() super(RecurrenceTest, self).setUp()
......
...@@ -20,6 +20,7 @@ import unittest ...@@ -20,6 +20,7 @@ import unittest
from topydo.lib.RelativeDate import relative_date_to_date from topydo.lib.RelativeDate import relative_date_to_date
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class RelativeDateTester(TopydoTest): class RelativeDateTester(TopydoTest):
def setUp(self): def setUp(self):
super(RelativeDateTester, self).setUp() super(RelativeDateTester, self).setUp()
......
...@@ -21,6 +21,7 @@ from topydo.commands.SortCommand import SortCommand ...@@ -21,6 +21,7 @@ from topydo.commands.SortCommand import SortCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from test.Facilities import load_file_to_todolist from test.Facilities import load_file_to_todolist
class SortCommandTest(CommandTest): class SortCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(SortCommandTest, self).setUp() super(SortCommandTest, self).setUp()
......
...@@ -22,6 +22,7 @@ from topydo.lib.Sorter import Sorter ...@@ -22,6 +22,7 @@ from topydo.lib.Sorter import Sorter
from test.Facilities import load_file, todolist_to_string, load_file_to_todolist, print_view from test.Facilities import load_file, todolist_to_string, load_file_to_todolist, print_view
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class SorterTest(TopydoTest): class SorterTest(TopydoTest):
def sort_file(self, p_filename, p_filename_ref, p_sorter): def sort_file(self, p_filename, p_filename_ref, p_sorter):
""" """
......
...@@ -20,6 +20,7 @@ from topydo.commands.TagCommand import TagCommand ...@@ -20,6 +20,7 @@ from topydo.commands.TagCommand import TagCommand
from test.TestCommand import CommandTest from test.TestCommand import CommandTest
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
class TagCommandTest(CommandTest): class TagCommandTest(CommandTest):
def setUp(self): def setUp(self):
super(TagCommandTest, self).setUp() super(TagCommandTest, self).setUp()
......
...@@ -20,14 +20,17 @@ import unittest ...@@ -20,14 +20,17 @@ import unittest
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
def today_date(): def today_date():
today = date.today() today = date.today()
return today.isoformat() return today.isoformat()
def tomorrow_date(): def tomorrow_date():
tomorrow = date.today() + timedelta(days=1) tomorrow = date.today() + timedelta(days=1)
return tomorrow.isoformat() return tomorrow.isoformat()
class TodoTest(TopydoTest): class TodoTest(TopydoTest):
def test_due_date1(self): def test_due_date1(self):
todo = Todo("(C) Foo due:2014-06-09") todo = Todo("(C) Foo due:2014-06-09")
......
...@@ -23,6 +23,7 @@ import unittest ...@@ -23,6 +23,7 @@ import unittest
from topydo.lib.TodoBase import TodoBase from topydo.lib.TodoBase import TodoBase
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class TodoBaseTester(TopydoTest): class TodoBaseTester(TopydoTest):
def test_parse_tag(self): def test_parse_tag(self):
todo = TodoBase("(C) Test foo:bar foo:baz foo_:baz_ blah:zah:haz") todo = TodoBase("(C) Test foo:bar foo:baz foo_:baz_ blah:zah:haz")
......
...@@ -20,6 +20,7 @@ import unittest ...@@ -20,6 +20,7 @@ import unittest
from test.Facilities import load_file from test.Facilities import load_file
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class TodoFileTest(TopydoTest): class TodoFileTest(TopydoTest):
def test_empty_file(self): def test_empty_file(self):
todofile = load_file('test/data/TodoFileTest1.txt') todofile = load_file('test/data/TodoFileTest1.txt')
......
...@@ -27,6 +27,7 @@ from topydo.lib.TodoList import TodoList ...@@ -27,6 +27,7 @@ from topydo.lib.TodoList import TodoList
from topydo.lib.TodoListBase import TodoListBase from topydo.lib.TodoListBase import TodoListBase
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class TodoListTester(TopydoTest): class TodoListTester(TopydoTest):
def setUp(self): def setUp(self):
super(TodoListTester, self).setUp() super(TodoListTester, self).setUp()
...@@ -224,6 +225,7 @@ class TodoListTester(TopydoTest): ...@@ -224,6 +225,7 @@ class TodoListTester(TopydoTest):
self.assertNotEqual(self.todolist.number(todo), 't5c') self.assertNotEqual(self.todolist.number(todo), 't5c')
class TodoListDependencyTester(TopydoTest): class TodoListDependencyTester(TopydoTest):
def setUp(self): def setUp(self):
super(TodoListDependencyTester, self).setUp() super(TodoListDependencyTester, self).setUp()
...@@ -361,6 +363,7 @@ class TodoListDependencyTester(TopydoTest): ...@@ -361,6 +363,7 @@ class TodoListDependencyTester(TopydoTest):
self.assertTrue(todolist.todo_by_dep_id('1')) self.assertTrue(todolist.todo_by_dep_id('1'))
self.assertFalse(todolist.todo_by_dep_id('2')) self.assertFalse(todolist.todo_by_dep_id('2'))
class TodoListCleanDependencyTester(TopydoTest): class TodoListCleanDependencyTester(TopydoTest):
def setUp(self): def setUp(self):
super(TodoListCleanDependencyTester, self).setUp() super(TodoListCleanDependencyTester, self).setUp()
......
...@@ -18,6 +18,7 @@ import unittest ...@@ -18,6 +18,7 @@ import unittest
from topydo.lib.Config import config from topydo.lib.Config import config
class TopydoTest(unittest.TestCase): class TopydoTest(unittest.TestCase):
def tearDown(self): def tearDown(self):
""" """
......
...@@ -23,6 +23,7 @@ from topydo.lib.TodoFile import TodoFile ...@@ -23,6 +23,7 @@ from topydo.lib.TodoFile import TodoFile
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
from test.TestTopydo import TopydoTest from test.TestTopydo import TopydoTest
class ViewTest(TopydoTest): class ViewTest(TopydoTest):
def test_view(self): def test_view(self):
""" Check filters and printer for views. """ """ Check filters and printer for views. """
......
...@@ -52,6 +52,7 @@ _SUBCOMMAND_MAP = { ...@@ -52,6 +52,7 @@ _SUBCOMMAND_MAP = {
'tag': 'TagCommand', 'tag': 'TagCommand',
} }
def get_subcommand(p_args): def get_subcommand(p_args):
""" """
Retrieves the to-be executed Command and returns a tuple Retrieves the to-be executed Command and returns a tuple
......
...@@ -34,6 +34,7 @@ except ConfigError as config_error: ...@@ -34,6 +34,7 @@ except ConfigError as config_error:
from topydo.Commands import get_subcommand from topydo.Commands import get_subcommand
from topydo.lib import TodoList from topydo.lib import TodoList
class CLIApplication(CLIApplicationBase): class CLIApplication(CLIApplicationBase):
""" """
Class that represents the (original) Command Line Interface of Topydo. Class that represents the (original) Command Line Interface of Topydo.
...@@ -58,6 +59,7 @@ class CLIApplication(CLIApplicationBase): ...@@ -58,6 +59,7 @@ class CLIApplication(CLIApplicationBase):
else: else:
self._post_execute() self._post_execute()
def main(): def main():
""" Main entry point of the CLI. """ """ Main entry point of the CLI. """
CLIApplication().run() CLIApplication().run()
......
...@@ -26,6 +26,7 @@ from six.moves import input ...@@ -26,6 +26,7 @@ from six.moves import input
MAIN_OPTS = "ac:d:ht:v" MAIN_OPTS = "ac:d:ht:v"
def usage(): def usage():
""" Prints the command-line usage of topydo. """ """ Prints the command-line usage of topydo. """
...@@ -61,6 +62,7 @@ Available commands: ...@@ -61,6 +62,7 @@ Available commands:
Run `topydo help <subcommand>` for command-specific help. Run `topydo help <subcommand>` for command-specific help.
""") """)
def write(p_file, p_string): def write(p_file, p_string):
""" """
Write p_string to file p_file, trailed by a newline character. Write p_string to file p_file, trailed by a newline character.
...@@ -73,11 +75,13 @@ def write(p_file, p_string): ...@@ -73,11 +75,13 @@ def write(p_file, p_string):
if p_string: if p_string:
p_file.write(p_string + "\n") p_file.write(p_string + "\n")
def error(p_string): def error(p_string):
""" Writes an error on the standard error. """ """ Writes an error on the standard error. """
write(sys.stderr, p_string) write(sys.stderr, p_string)
def version(): def version():
""" Print the current version and exit. """ """ Print the current version and exit. """
from topydo.lib.Version import VERSION, LICENSE from topydo.lib.Version import VERSION, LICENSE
...@@ -103,6 +107,7 @@ from topydo.lib import TodoList ...@@ -103,6 +107,7 @@ from topydo.lib import TodoList
from topydo.lib import TodoListBase from topydo.lib import TodoListBase
from topydo.lib.Utils import escape_ansi from topydo.lib.Utils import escape_ansi
class CLIApplicationBase(object): class CLIApplicationBase(object):
""" """
Base class for a Command Line Interfaces (CLI) for topydo. Examples are the Base class for a Command Line Interfaces (CLI) for topydo. Examples are the
......
...@@ -39,6 +39,7 @@ from topydo.Commands import get_subcommand ...@@ -39,6 +39,7 @@ from topydo.Commands import get_subcommand
from topydo.lib import TodoFile from topydo.lib import TodoFile
from topydo.lib import TodoList from topydo.lib import TodoList
def _todotxt_mtime(): def _todotxt_mtime():
""" """
Returns the mtime for the configured todo.txt file. Returns the mtime for the configured todo.txt file.
...@@ -49,6 +50,7 @@ def _todotxt_mtime(): ...@@ -49,6 +50,7 @@ def _todotxt_mtime():
# file not found # file not found
return None return None
class PromptApplication(CLIApplicationBase): class PromptApplication(CLIApplicationBase):
""" """
This class implements a variant of topydo's CLI showing a shell and This class implements a variant of topydo's CLI showing a shell and
...@@ -112,6 +114,7 @@ class PromptApplication(CLIApplicationBase): ...@@ -112,6 +114,7 @@ class PromptApplication(CLIApplicationBase):
except TypeError: except TypeError:
usage() usage()
def main(): def main():
""" Main entry point of the prompt interface. """ """ Main entry point of the prompt interface. """
PromptApplication().run() PromptApplication().run()
......
...@@ -28,6 +28,7 @@ from topydo.lib.Config import config ...@@ -28,6 +28,7 @@ from topydo.lib.Config import config
from topydo.Commands import _SUBCOMMAND_MAP from topydo.Commands import _SUBCOMMAND_MAP
from topydo.lib.RelativeDate import relative_date_to_date from topydo.lib.RelativeDate import relative_date_to_date
def _subcommands(p_word_before_cursor): def _subcommands(p_word_before_cursor):
""" Generator for subcommand name completion. """ """ Generator for subcommand name completion. """
subcommands = [sc for sc in sorted(_SUBCOMMAND_MAP.keys()) if subcommands = [sc for sc in sorted(_SUBCOMMAND_MAP.keys()) if
...@@ -35,6 +36,7 @@ def _subcommands(p_word_before_cursor): ...@@ -35,6 +36,7 @@ def _subcommands(p_word_before_cursor):
for command in subcommands: for command in subcommands:
yield Completion(command, -len(p_word_before_cursor)) yield Completion(command, -len(p_word_before_cursor))
def _dates(p_word_before_cursor): def _dates(p_word_before_cursor):
""" Generator for date completion. """ """ Generator for date completion. """
def _date_suggestions(): def _date_suggestions():
...@@ -79,6 +81,7 @@ def _dates(p_word_before_cursor): ...@@ -79,6 +81,7 @@ def _dates(p_word_before_cursor):
yield Completion(reldate, -len(value), display_meta=to_absolute(reldate)) yield Completion(reldate, -len(value), display_meta=to_absolute(reldate))
class TopydoCompleter(Completer): class TopydoCompleter(Completer):
""" """
Completer class that completes projects, contexts, dates and Completer class that completes projects, contexts, dates and
......
...@@ -25,6 +25,7 @@ if "win32" in sys.platform: ...@@ -25,6 +25,7 @@ if "win32" in sys.platform:
import colorama import colorama
colorama.init() colorama.init()
def main(): def main():
""" Main entry point of the CLI. """ """ Main entry point of the CLI. """
try: try:
......
...@@ -28,6 +28,7 @@ from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers ...@@ -28,6 +28,7 @@ from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
from topydo.lib.RelativeDate import relative_date_to_date from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
class AddCommand(Command): class AddCommand(Command):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -18,6 +18,7 @@ from topydo.lib.Command import Command, InvalidCommandArgument ...@@ -18,6 +18,7 @@ from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
class AppendCommand(Command): class AppendCommand(Command):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
from topydo.lib.Command import Command from topydo.lib.Command import Command
class ArchiveCommand(Command): class ArchiveCommand(Command):
def __init__(self, p_todolist, p_archive_list): def __init__(self, p_todolist, p_archive_list):
""" """
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
from topydo.lib.DCommand import DCommand from topydo.lib.DCommand import DCommand
class DeleteCommand(DCommand): class DeleteCommand(DCommand):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -22,6 +22,7 @@ from topydo.lib.Sorter import Sorter ...@@ -22,6 +22,7 @@ from topydo.lib.Sorter import Sorter
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.View import View from topydo.lib.View import View
class DepCommand(Command): class DepCommand(Command):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
from topydo.lib.MultiCommand import MultiCommand from topydo.lib.MultiCommand import MultiCommand
from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
class DepriCommand(MultiCommand): class DepriCommand(MultiCommand):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -22,6 +22,7 @@ from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers ...@@ -22,6 +22,7 @@ from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
from topydo.lib.Recurrence import advance_recurring_todo, NoRecurrenceException from topydo.lib.Recurrence import advance_recurring_todo, NoRecurrenceException
from topydo.lib.Utils import date_string_to_date from topydo.lib.Utils import date_string_to_date
class DoCommand(DCommand): class DoCommand(DCommand):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -34,6 +34,7 @@ DEFAULT_EDITOR = 'vi' ...@@ -34,6 +34,7 @@ DEFAULT_EDITOR = 'vi'
# cannot use super() inside the class itself # cannot use super() inside the class itself
BASE_TODOLIST = lambda tl: super(TodoList, tl) BASE_TODOLIST = lambda tl: super(TodoList, tl)
class EditCommand(MultiCommand): class EditCommand(MultiCommand):
def __init__(self, p_args, p_todolist, p_output, p_error, p_input): def __init__(self, p_args, p_todolist, p_output, p_error, p_input):
super(EditCommand, self).__init__(p_args, p_todolist, p_output, super(EditCommand, self).__init__(p_args, p_todolist, p_output,
......
...@@ -18,6 +18,7 @@ import sys ...@@ -18,6 +18,7 @@ import sys
from topydo.lib.Command import Command from topydo.lib.Command import Command
class ExitCommand(Command): class ExitCommand(Command):
""" """
A command that exits topydo. Used for the 'exit' and 'quit' subcommands on A command that exits topydo. Used for the 'exit' and 'quit' subcommands on
......
...@@ -24,6 +24,7 @@ from topydo.lib.PrettyPrinterFilter import ( ...@@ -24,6 +24,7 @@ from topydo.lib.PrettyPrinterFilter import (
from topydo.lib.IcalPrinter import IcalPrinter from topydo.lib.IcalPrinter import IcalPrinter
from topydo.lib.JsonPrinter import JsonPrinter from topydo.lib.JsonPrinter import JsonPrinter
class ListCommand(ExpressionCommand): class ListCommand(ExpressionCommand):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
from topydo.lib.Command import Command from topydo.lib.Command import Command
class ListContextCommand(Command): class ListContextCommand(Command):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
from topydo.lib.Command import Command from topydo.lib.Command import Command
class ListProjectCommand(Command): class ListProjectCommand(Command):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -22,6 +22,7 @@ from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers ...@@ -22,6 +22,7 @@ from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
from topydo.lib.RelativeDate import relative_date_to_date from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.Utils import date_string_to_date from topydo.lib.Utils import date_string_to_date
class PostponeCommand(MultiCommand): class PostponeCommand(MultiCommand):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -20,6 +20,7 @@ from topydo.lib.MultiCommand import MultiCommand ...@@ -20,6 +20,7 @@ from topydo.lib.MultiCommand import MultiCommand
from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
from topydo.lib.Utils import is_valid_priority from topydo.lib.Utils import is_valid_priority
class PriorityCommand(MultiCommand): class PriorityCommand(MultiCommand):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -18,6 +18,7 @@ from topydo.lib.Command import Command, InvalidCommandArgument ...@@ -18,6 +18,7 @@ from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.Sorter import Sorter from topydo.lib.Sorter import Sorter
class SortCommand(Command): class SortCommand(Command):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -18,6 +18,7 @@ from topydo.lib.Command import Command, InvalidCommandArgument ...@@ -18,6 +18,7 @@ from topydo.lib.Command import Command, InvalidCommandArgument
from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
class TagCommand(Command): class TagCommand(Command):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -20,6 +20,7 @@ from topydo.lib.Config import config ...@@ -20,6 +20,7 @@ from topydo.lib.Config import config
NEUTRAL_COLOR = '\033[0m' NEUTRAL_COLOR = '\033[0m'
class Colors(object): class Colors(object):
def __init__(self): def __init__(self):
self.priority_colors = config().priority_colors() self.priority_colors = config().priority_colors()
......
...@@ -18,9 +18,11 @@ import getopt ...@@ -18,9 +18,11 @@ import getopt
from topydo.lib.PrettyPrinter import PrettyPrinter from topydo.lib.PrettyPrinter import PrettyPrinter
class InvalidCommandArgument(Exception): class InvalidCommandArgument(Exception):
pass pass
class Command(object): class Command(object):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
......
...@@ -18,6 +18,7 @@ import os ...@@ -18,6 +18,7 @@ import os
from six.moves import configparser from six.moves import configparser
class ConfigError(Exception): class ConfigError(Exception):
def __init__(self, p_text): def __init__(self, p_text):
self.text = p_text self.text = p_text
...@@ -25,6 +26,7 @@ class ConfigError(Exception): ...@@ -25,6 +26,7 @@ class ConfigError(Exception):
def __str__(self): def __str__(self):
return self.text return self.text
class _Config: class _Config:
def __init__(self, p_path=None, p_overrides=None): def __init__(self, p_path=None, p_overrides=None):
""" """
...@@ -252,6 +254,7 @@ class _Config: ...@@ -252,6 +254,7 @@ class _Config:
except ValueError: except ValueError:
return self.defaults['auto_creation_date'] == '1' return self.defaults['auto_creation_date'] == '1'
def config(p_path=None, p_overrides=None): def config(p_path=None, p_overrides=None):
""" """
Retrieve the config instance. Retrieve the config instance.
......
...@@ -20,6 +20,7 @@ from topydo.lib.MultiCommand import MultiCommand ...@@ -20,6 +20,7 @@ from topydo.lib.MultiCommand import MultiCommand
from topydo.lib.PrettyPrinter import PrettyPrinter from topydo.lib.PrettyPrinter import PrettyPrinter
from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
class DCommand(MultiCommand): class DCommand(MultiCommand):
""" """
A common class for the 'do' and 'del' operations, because they're quite A common class for the 'do' and 'del' operations, because they're quite
......
...@@ -22,6 +22,7 @@ from topydo.lib import Filter ...@@ -22,6 +22,7 @@ from topydo.lib import Filter
from topydo.lib.Sorter import Sorter from topydo.lib.Sorter import Sorter
from topydo.lib.View import View from topydo.lib.View import View
class ExpressionCommand(Command): class ExpressionCommand(Command):
""" """
A common class for commands operating on todos selected by expressions. A common class for commands operating on todos selected by expressions.
......
...@@ -19,6 +19,7 @@ import re ...@@ -19,6 +19,7 @@ import re
from topydo.lib.RelativeDate import relative_date_to_date from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.Utils import date_string_to_date from topydo.lib.Utils import date_string_to_date
class Filter(object): class Filter(object):
def filter(self, p_todos): def filter(self, p_todos):
""" """
...@@ -31,6 +32,7 @@ class Filter(object): ...@@ -31,6 +32,7 @@ class Filter(object):
def match(self, _): def match(self, _):
raise NotImplementedError raise NotImplementedError
class NegationFilter(Filter): class NegationFilter(Filter):
def __init__(self, p_filter): def __init__(self, p_filter):
self._filter = p_filter self._filter = p_filter
...@@ -38,6 +40,7 @@ class NegationFilter(Filter): ...@@ -38,6 +40,7 @@ class NegationFilter(Filter):
def match(self, p_todo): def match(self, p_todo):
return not self._filter.match(p_todo) return not self._filter.match(p_todo)
class AndFilter(Filter): class AndFilter(Filter):
def __init__(self, p_filter1, p_filter2): def __init__(self, p_filter1, p_filter2):
self._filter1 = p_filter1 self._filter1 = p_filter1
...@@ -46,6 +49,7 @@ class AndFilter(Filter): ...@@ -46,6 +49,7 @@ class AndFilter(Filter):
def match(self, p_todo): def match(self, p_todo):
return self._filter1.match(p_todo) and self._filter2.match(p_todo) return self._filter1.match(p_todo) and self._filter2.match(p_todo)
class OrFilter(Filter): class OrFilter(Filter):
def __init__(self, p_filter1, p_filter2): def __init__(self, p_filter1, p_filter2):
self._filter1 = p_filter1 self._filter1 = p_filter1
...@@ -54,6 +58,7 @@ class OrFilter(Filter): ...@@ -54,6 +58,7 @@ class OrFilter(Filter):
def match(self, p_todo): def match(self, p_todo):
return self._filter1.match(p_todo) or self._filter2.match(p_todo) return self._filter1.match(p_todo) or self._filter2.match(p_todo)
class GrepFilter(Filter): class GrepFilter(Filter):
""" Matches when the todo text contains a text. """ """ Matches when the todo text contains a text. """
...@@ -80,6 +85,7 @@ class GrepFilter(Filter): ...@@ -80,6 +85,7 @@ class GrepFilter(Filter):
return string.find(expr) != -1 return string.find(expr) != -1
class RelevanceFilter(Filter): class RelevanceFilter(Filter):
""" """
Matches when the todo is relevant, i.e.: Matches when the todo is relevant, i.e.:
...@@ -99,6 +105,7 @@ class RelevanceFilter(Filter): ...@@ -99,6 +105,7 @@ class RelevanceFilter(Filter):
return p_todo.is_active() and is_due return p_todo.is_active() and is_due
class DependencyFilter(Filter): class DependencyFilter(Filter):
""" Matches when a todo has no unfinished child tasks. """ """ Matches when a todo has no unfinished child tasks. """
def __init__(self, p_todolist): def __init__(self, p_todolist):
...@@ -120,6 +127,7 @@ class DependencyFilter(Filter): ...@@ -120,6 +127,7 @@ class DependencyFilter(Filter):
return not uncompleted return not uncompleted
class InstanceFilter(Filter): class InstanceFilter(Filter):
def __init__(self, p_todos): def __init__(self, p_todos):
""" """
...@@ -143,6 +151,7 @@ class InstanceFilter(Filter): ...@@ -143,6 +151,7 @@ class InstanceFilter(Filter):
except ValueError: except ValueError:
return False return False
class LimitFilter(Filter): class LimitFilter(Filter):
def __init__(self, p_limit): def __init__(self, p_limit):
super(LimitFilter, self).__init__() super(LimitFilter, self).__init__()
...@@ -153,6 +162,7 @@ class LimitFilter(Filter): ...@@ -153,6 +162,7 @@ class LimitFilter(Filter):
OPERATOR_MATCH = r"(?P<operator><=?|=|>=?|!)?" OPERATOR_MATCH = r"(?P<operator><=?|=|>=?|!)?"
class OrdinalFilter(Filter): class OrdinalFilter(Filter):
""" """
Base class for ordinal filters. Base class for ordinal filters.
...@@ -193,6 +203,7 @@ class OrdinalFilter(Filter): ...@@ -193,6 +203,7 @@ class OrdinalFilter(Filter):
ORDINAL_TAG_MATCH = r"(?P<key>[^:]*):" + OPERATOR_MATCH + r"(?P<value>\S+)" ORDINAL_TAG_MATCH = r"(?P<key>[^:]*):" + OPERATOR_MATCH + r"(?P<value>\S+)"
class OrdinalTagFilter(OrdinalFilter): class OrdinalTagFilter(OrdinalFilter):
def __init__(self, p_expression): def __init__(self, p_expression):
super(OrdinalTagFilter, self).__init__(p_expression, ORDINAL_TAG_MATCH) super(OrdinalTagFilter, self).__init__(p_expression, ORDINAL_TAG_MATCH)
...@@ -235,6 +246,7 @@ class OrdinalTagFilter(OrdinalFilter): ...@@ -235,6 +246,7 @@ class OrdinalTagFilter(OrdinalFilter):
PRIORITY_MATCH = r"\(" + OPERATOR_MATCH + r"(?P<value>[A-Z]{1})\)" PRIORITY_MATCH = r"\(" + OPERATOR_MATCH + r"(?P<value>[A-Z]{1})\)"
class PriorityFilter(OrdinalFilter): class PriorityFilter(OrdinalFilter):
def __init__(self, p_expression): def __init__(self, p_expression):
super(PriorityFilter, self).__init__(p_expression, PRIORITY_MATCH) super(PriorityFilter, self).__init__(p_expression, PRIORITY_MATCH)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
""" Contains the class for a directed graph. """ """ Contains the class for a directed graph. """
class DirectedGraph(object): class DirectedGraph(object):
""" """
Represents a simple directed graph, used for tracking todo Represents a simple directed graph, used for tracking todo
......
...@@ -27,6 +27,7 @@ _TABLE_SIZES = { ...@@ -27,6 +27,7 @@ _TABLE_SIZES = {
4: 1679609 # largest prime under zzzz_36 4: 1679609 # largest prime under zzzz_36
} }
def _to_base36(p_value): def _to_base36(p_value):
""" """
Converts integer to base36 string. Converts integer to base36 string.
...@@ -43,6 +44,7 @@ def _to_base36(p_value): ...@@ -43,6 +44,7 @@ def _to_base36(p_value):
return base36 or alphabet[0] return base36 or alphabet[0]
def hash_list_values(p_list, p_key=lambda i: i): def hash_list_values(p_list, p_key=lambda i: i):
""" """
Calculates a unique value for each item in the list, these can be used as Calculates a unique value for each item in the list, these can be used as
......
...@@ -25,6 +25,7 @@ import string ...@@ -25,6 +25,7 @@ import string
from topydo.lib.PrettyPrinter import Printer from topydo.lib.PrettyPrinter import Printer
def _convert_priority(p_priority): def _convert_priority(p_priority):
""" """
Converts todo.txt priority to an iCalendar priority (RFC 2445). Converts todo.txt priority to an iCalendar priority (RFC 2445).
...@@ -55,6 +56,7 @@ def _convert_priority(p_priority): ...@@ -55,6 +56,7 @@ def _convert_priority(p_priority):
return result return result
class IcalPrinter(Printer): class IcalPrinter(Printer):
""" """
A printer that converts a list of Todo items to a string in iCalendar A printer that converts a list of Todo items to a string in iCalendar
......
...@@ -29,6 +29,7 @@ from topydo.lib.Config import config ...@@ -29,6 +29,7 @@ from topydo.lib.Config import config
IMPORTANCE_VALUE = {'A': 3, 'B': 2, 'C': 1} IMPORTANCE_VALUE = {'A': 3, 'B': 2, 'C': 1}
def is_due_next_monday(p_todo): def is_due_next_monday(p_todo):
""" Returns True when the given task is due next Monday. """ """ Returns True when the given task is due next Monday. """
today = date.today() today = date.today()
...@@ -37,6 +38,7 @@ def is_due_next_monday(p_todo): ...@@ -37,6 +38,7 @@ def is_due_next_monday(p_todo):
return due and due.weekday() == 0 and today.weekday() >= 4 and \ return due and due.weekday() == 0 and today.weekday() >= 4 and \
p_todo.days_till_due() p_todo.days_till_due()
def importance(p_todo, p_ignore_weekend=config().ignore_weekends()): def importance(p_todo, p_ignore_weekend=config().ignore_weekends()):
""" """
Calculates the importance of the given task. Calculates the importance of the given task.
...@@ -74,6 +76,7 @@ def importance(p_todo, p_ignore_weekend=config().ignore_weekends()): ...@@ -74,6 +76,7 @@ def importance(p_todo, p_ignore_weekend=config().ignore_weekends()):
return result if not p_todo.is_completed() else 0 return result if not p_todo.is_completed() else 0
def average_importance(p_todo, p_ignore_weekend=config().ignore_weekends()): def average_importance(p_todo, p_ignore_weekend=config().ignore_weekends()):
own_importance = importance(p_todo, p_ignore_weekend) own_importance = importance(p_todo, p_ignore_weekend)
......
...@@ -23,6 +23,7 @@ import json ...@@ -23,6 +23,7 @@ import json
from topydo.lib.PrettyPrinter import Printer from topydo.lib.PrettyPrinter import Printer
def _convert_todo(p_todo): def _convert_todo(p_todo):
""" Converts a Todo instance to a dictionary. """ """ Converts a Todo instance to a dictionary. """
creation_date = p_todo.creation_date() creation_date = p_todo.creation_date()
...@@ -44,6 +45,7 @@ def _convert_todo(p_todo): ...@@ -44,6 +45,7 @@ def _convert_todo(p_todo):
return result return result
class JsonPrinter(Printer): class JsonPrinter(Printer):
""" """
A printer that converts a list of Todo items to a string in JSON format. A printer that converts a list of Todo items to a string in JSON format.
......
...@@ -19,6 +19,7 @@ from six import u ...@@ -19,6 +19,7 @@ from six import u
from topydo.lib.ExpressionCommand import ExpressionCommand from topydo.lib.ExpressionCommand import ExpressionCommand
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
class MultiCommand(ExpressionCommand): class MultiCommand(ExpressionCommand):
""" """
A common class for operations that can work with multiple todo IDs. A common class for operations that can work with multiple todo IDs.
......
...@@ -19,6 +19,7 @@ from topydo.lib.PrettyPrinterFilter import ( ...@@ -19,6 +19,7 @@ from topydo.lib.PrettyPrinterFilter import (
PrettyPrinterNumbers PrettyPrinterNumbers
) )
class Printer(object): class Printer(object):
""" """
An abstract class that turns todo items into strings. An abstract class that turns todo items into strings.
...@@ -35,6 +36,7 @@ class Printer(object): ...@@ -35,6 +36,7 @@ class Printer(object):
""" """
return "\n".join([self.print_todo(todo) for todo in p_todos]) return "\n".join([self.print_todo(todo) for todo in p_todos])
class PrettyPrinter(Printer): class PrettyPrinter(Printer):
""" """
Prints todo items on a single line, decorated by the filters passed by Prints todo items on a single line, decorated by the filters passed by
...@@ -68,6 +70,7 @@ class PrettyPrinter(Printer): ...@@ -68,6 +70,7 @@ class PrettyPrinter(Printer):
return todo_str return todo_str
def pretty_printer_factory(p_todolist, p_additional_filters=None): def pretty_printer_factory(p_todolist, p_additional_filters=None):
""" Returns a pretty printer suitable for the ls and dep subcommands. """ """ Returns a pretty printer suitable for the ls and dep subcommands. """
......
...@@ -22,6 +22,7 @@ from six import u ...@@ -22,6 +22,7 @@ from six import u
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.Colors import Colors, NEUTRAL_COLOR from topydo.lib.Colors import Colors, NEUTRAL_COLOR
class PrettyPrinterFilter(object): class PrettyPrinterFilter(object):
""" """
Base class for a pretty printer filter. Base class for a pretty printer filter.
...@@ -35,6 +36,7 @@ class PrettyPrinterFilter(object): ...@@ -35,6 +36,7 @@ class PrettyPrinterFilter(object):
""" """
raise NotImplementedError raise NotImplementedError
class PrettyPrinterColorFilter(PrettyPrinterFilter): class PrettyPrinterColorFilter(PrettyPrinterFilter):
""" """
Adds colors to the todo string by inserting ANSI codes. Adds colors to the todo string by inserting ANSI codes.
...@@ -84,6 +86,7 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter): ...@@ -84,6 +86,7 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter):
return p_todo_str return p_todo_str
class PrettyPrinterIndentFilter(PrettyPrinterFilter): class PrettyPrinterIndentFilter(PrettyPrinterFilter):
""" Adds indentation to the todo item. """ """ Adds indentation to the todo item. """
def __init__(self, p_indent=0): def __init__(self, p_indent=0):
...@@ -94,6 +97,7 @@ class PrettyPrinterIndentFilter(PrettyPrinterFilter): ...@@ -94,6 +97,7 @@ class PrettyPrinterIndentFilter(PrettyPrinterFilter):
""" Applies the indentation. """ """ Applies the indentation. """
return ' ' * self.indent + p_todo_str return ' ' * self.indent + p_todo_str
class PrettyPrinterNumbers(PrettyPrinterFilter): class PrettyPrinterNumbers(PrettyPrinterFilter):
""" Prepends the todo's number, retrieved from the todolist. """ """ Prepends the todo's number, retrieved from the todolist. """
def __init__(self, p_todolist): def __init__(self, p_todolist):
...@@ -104,6 +108,7 @@ class PrettyPrinterNumbers(PrettyPrinterFilter): ...@@ -104,6 +108,7 @@ class PrettyPrinterNumbers(PrettyPrinterFilter):
""" Prepends the number to the todo string. """ """ Prepends the number to the todo string. """
return u("|{:>3}| {}").format(self.todolist.number(p_todo), p_todo_str) return u("|{:>3}| {}").format(self.todolist.number(p_todo), p_todo_str)
class PrettyPrinterHideTagFilter(PrettyPrinterFilter): class PrettyPrinterHideTagFilter(PrettyPrinterFilter):
""" Removes all occurences of the given tags from the text. """ """ Removes all occurences of the given tags from the text. """
def __init__(self, p_hidden_tags): def __init__(self, p_hidden_tags):
......
...@@ -22,9 +22,11 @@ from topydo.lib.Config import config ...@@ -22,9 +22,11 @@ from topydo.lib.Config import config
from topydo.lib.RelativeDate import relative_date_to_date from topydo.lib.RelativeDate import relative_date_to_date
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
class NoRecurrenceException(Exception): class NoRecurrenceException(Exception):
pass pass
def advance_recurring_todo(p_todo, p_offset=None, p_strict=False): def advance_recurring_todo(p_todo, p_offset=None, p_strict=False):
""" """
Given a Todo item, return a new instance of a Todo item with the dates Given a Todo item, return a new instance of a Todo item with the dates
......
...@@ -20,6 +20,7 @@ from datetime import date, timedelta ...@@ -20,6 +20,7 @@ from datetime import date, timedelta
import calendar import calendar
import re import re
def _add_months(p_sourcedate, p_months): def _add_months(p_sourcedate, p_months):
""" """
Adds a number of months to the source date. Adds a number of months to the source date.
...@@ -35,6 +36,7 @@ def _add_months(p_sourcedate, p_months): ...@@ -35,6 +36,7 @@ def _add_months(p_sourcedate, p_months):
return date(year, month, day) return date(year, month, day)
def _convert_pattern(p_length, p_periodunit, p_offset=None): def _convert_pattern(p_length, p_periodunit, p_offset=None):
""" """
Converts a pattern in the form [0-9][dwmy] and returns a date from the Converts a pattern in the form [0-9][dwmy] and returns a date from the
...@@ -56,6 +58,7 @@ def _convert_pattern(p_length, p_periodunit, p_offset=None): ...@@ -56,6 +58,7 @@ def _convert_pattern(p_length, p_periodunit, p_offset=None):
return result return result
def _convert_weekday_pattern(p_weekday): def _convert_weekday_pattern(p_weekday):
""" """
Converts a weekday name to an absolute date. Converts a weekday name to an absolute date.
...@@ -81,6 +84,7 @@ def _convert_weekday_pattern(p_weekday): ...@@ -81,6 +84,7 @@ def _convert_weekday_pattern(p_weekday):
shift = (target_day - day) % 7 shift = (target_day - day) % 7
return date.today() + timedelta(shift) return date.today() + timedelta(shift)
def relative_date_to_date(p_date, p_offset=None): def relative_date_to_date(p_date, p_offset=None):
""" """
Transforms a relative date into a date object. Transforms a relative date into a date object.
......
...@@ -21,10 +21,12 @@ import re ...@@ -21,10 +21,12 @@ import re
from topydo.lib.Importance import importance, average_importance from topydo.lib.Importance import importance, average_importance
def is_priority_field(p_field): def is_priority_field(p_field):
""" Returns True when the field name denotes the priority. """ """ Returns True when the field name denotes the priority. """
return p_field.startswith('prio') return p_field.startswith('prio')
def get_field_function(p_field): def get_field_function(p_field):
""" """
Given a property (string) of a todo, return a function that attempts to Given a property (string) of a todo, return a function that attempts to
...@@ -59,6 +61,7 @@ def get_field_function(p_field): ...@@ -59,6 +61,7 @@ def get_field_function(p_field):
return result return result
class Sorter(object): class Sorter(object):
""" """
This class sorts a todo list. This class sorts a todo list.
......
...@@ -24,6 +24,7 @@ from topydo.lib.Config import config ...@@ -24,6 +24,7 @@ from topydo.lib.Config import config
from topydo.lib.TodoBase import TodoBase from topydo.lib.TodoBase import TodoBase
from topydo.lib.Utils import date_string_to_date from topydo.lib.Utils import date_string_to_date
class Todo(TodoBase): class Todo(TodoBase):
""" """
This class adds common functionality with respect to dates to the Todo This class adds common functionality with respect to dates to the Todo
......
...@@ -25,6 +25,7 @@ from six import u ...@@ -25,6 +25,7 @@ from six import u
from topydo.lib.TodoParser import parse_line from topydo.lib.TodoParser import parse_line
from topydo.lib.Utils import is_valid_priority from topydo.lib.Utils import is_valid_priority
class TodoBase(object): class TodoBase(object):
""" """
This class represents a single todo item in a todo.txt file. It maintains This class represents a single todo item in a todo.txt file. It maintains
......
...@@ -20,6 +20,7 @@ This module deals with todo.txt files. ...@@ -20,6 +20,7 @@ This module deals with todo.txt files.
import codecs import codecs
class TodoFile(object): class TodoFile(object):
""" """
This class represents a todo.txt file, which can be read from or written This class represents a todo.txt file, which can be read from or written
......
...@@ -22,6 +22,7 @@ from topydo.lib.Config import config ...@@ -22,6 +22,7 @@ from topydo.lib.Config import config
from topydo.lib.Graph import DirectedGraph from topydo.lib.Graph import DirectedGraph
from topydo.lib.TodoListBase import TodoListBase from topydo.lib.TodoListBase import TodoListBase
class TodoList(TodoListBase): class TodoList(TodoListBase):
""" """
Provides operations for a todo list, such as adding items, removing them, Provides operations for a todo list, such as adding items, removing them,
......
...@@ -29,9 +29,11 @@ from topydo.lib.PrettyPrinter import PrettyPrinter ...@@ -29,9 +29,11 @@ from topydo.lib.PrettyPrinter import PrettyPrinter
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from topydo.lib.View import View from topydo.lib.View import View
class InvalidTodoException(Exception): class InvalidTodoException(Exception):
pass pass
class TodoListBase(object): class TodoListBase(object):
""" """
Provides operations for a todo list, such as adding items, removing them, Provides operations for a todo list, such as adding items, removing them,
......
...@@ -37,6 +37,7 @@ _TAG_MATCH = re.compile('(?P<key>[^:]+):(?P<value>.+)') ...@@ -37,6 +37,7 @@ _TAG_MATCH = re.compile('(?P<key>[^:]+):(?P<value>.+)')
_PROJECT_MATCH = re.compile(r'\+(\S*\w)') _PROJECT_MATCH = re.compile(r'\+(\S*\w)')
_CONTEXT_MATCH = re.compile(r'@(\S*\w)') _CONTEXT_MATCH = re.compile(r'@(\S*\w)')
def parse_line(p_string): def parse_line(p_string):
""" """
Parses a single line as can be encountered in a todo.txt file. Parses a single line as can be encountered in a todo.txt file.
......
...@@ -21,6 +21,7 @@ Various utility functions. ...@@ -21,6 +21,7 @@ Various utility functions.
from datetime import date from datetime import date
import re import re
def date_string_to_date(p_date): def date_string_to_date(p_date):
""" """
Given a date in YYYY-MM-DD, returns a Python date object. Returns None Given a date in YYYY-MM-DD, returns a Python date object. Returns None
...@@ -41,9 +42,11 @@ def date_string_to_date(p_date): ...@@ -41,9 +42,11 @@ def date_string_to_date(p_date):
return result return result
def is_valid_priority(p_priority): def is_valid_priority(p_priority):
return p_priority != None and re.match(r'^[A-Z]$', p_priority) != None return p_priority != None and re.match(r'^[A-Z]$', p_priority) != None
def escape_ansi(p_string): def escape_ansi(p_string):
return escape_ansi.pattern.sub('', p_string) return escape_ansi.pattern.sub('', p_string)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
""" A view is a list of todos, sorted and filtered. """ """ A view is a list of todos, sorted and filtered. """
class View(object): class View(object):
""" """
A view is instantiated by a todo list, usually obtained from a todo.txt A view is instantiated by a todo list, usually obtained from a todo.txt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment