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