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
...
@@ -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
)
test/TestAddCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestAppendCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestArchiveCommand.py
View file @
cd41fdef
...
@@ -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"
)
...
...
test/TestColors.py
View file @
cd41fdef
...
@@ -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'
})
...
...
test/TestCommand.py
View file @
cd41fdef
...
@@ -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
)
...
...
test/TestConfig.py
View file @
cd41fdef
...
@@ -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'
)
...
...
test/TestDeleteCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestDepCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestDepriCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestDoCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestEditCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestFilter.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestGraph.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestImportance.py
View file @
cd41fdef
...
@@ -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"
)
...
...
test/TestJsonPrinter.py
View file @
cd41fdef
...
@@ -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
...
...
test/TestListCommand.py
View file @
cd41fdef
...
@@ -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
...
...
test/TestListContextCommand.py
View file @
cd41fdef
...
@@ -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"
)
...
...
test/TestListProjectCommand.py
View file @
cd41fdef
...
@@ -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"
)
...
...
test/TestPostponeCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestPriorityCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestRecurrence.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestRelativeDate.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestSortCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestSorter.py
View file @
cd41fdef
...
@@ -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
):
"""
"""
...
...
test/TestTagCommand.py
View file @
cd41fdef
...
@@ -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
()
...
...
test/TestTodo.py
View file @
cd41fdef
...
@@ -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"
)
...
...
test/TestTodoBase.py
View file @
cd41fdef
...
@@ -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"
)
...
...
test/TestTodoFile.py
View file @
cd41fdef
...
@@ -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'
)
...
...
test/TestTodoList.py
View file @
cd41fdef
...
@@ -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()
...
...
test/TestTopydo.py
View file @
cd41fdef
...
@@ -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
):
"""
"""
...
...
test/TestView.py
View file @
cd41fdef
...
@@ -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. """
...
...
topydo/Commands.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/cli/CLI.py
View file @
cd41fdef
...
@@ -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
()
...
...
topydo/cli/CLIApplicationBase.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/cli/Prompt.py
View file @
cd41fdef
...
@@ -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
()
...
...
topydo/cli/TopydoCompleter.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/cli/UILoader.py
View file @
cd41fdef
...
@@ -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
:
...
...
topydo/commands/AddCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/AppendCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/ArchiveCommand.py
View file @
cd41fdef
...
@@ -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
):
"""
"""
...
...
topydo/commands/DeleteCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/DepCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/DepriCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/DoCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/EditCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/ExitCommand.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/commands/ListCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/ListContextCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/ListProjectCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/PostponeCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/PriorityCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/SortCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/commands/TagCommand.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/lib/Colors.py
View file @
cd41fdef
...
@@ -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
()
...
...
topydo/lib/Command.py
View file @
cd41fdef
...
@@ -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
,
...
...
topydo/lib/Config.py
View file @
cd41fdef
...
@@ -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.
...
...
topydo/lib/DCommand.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/ExpressionCommand.py
View file @
cd41fdef
...
@@ -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.
...
...
topydo/lib/Filter.py
View file @
cd41fdef
...
@@ -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)
...
...
topydo/lib/Graph.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/HashListValues.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/IcalPrinter.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/Importance.py
View file @
cd41fdef
...
@@ -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
)
...
...
topydo/lib/JsonPrinter.py
View file @
cd41fdef
...
@@ -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.
...
...
topydo/lib/MultiCommand.py
View file @
cd41fdef
...
@@ -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.
...
...
topydo/lib/PrettyPrinter.py
View file @
cd41fdef
...
@@ -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. """
...
...
topydo/lib/PrettyPrinterFilter.py
View file @
cd41fdef
...
@@ -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):
...
...
topydo/lib/Recurrence.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/RelativeDate.py
View file @
cd41fdef
...
@@ -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.
...
...
topydo/lib/Sorter.py
View file @
cd41fdef
...
@@ -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.
...
...
topydo/lib/Todo.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/TodoBase.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/TodoFile.py
View file @
cd41fdef
...
@@ -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
...
...
topydo/lib/TodoList.py
View file @
cd41fdef
...
@@ -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,
...
...
topydo/lib/TodoListBase.py
View file @
cd41fdef
...
@@ -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,
...
...
topydo/lib/TodoParser.py
View file @
cd41fdef
...
@@ -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.
...
...
topydo/lib/Utils.py
View file @
cd41fdef
...
@@ -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
)
...
...
topydo/lib/View.py
View file @
cd41fdef
...
@@ -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
...
...
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