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
d7ff4f48
Commit
d7ff4f48
authored
Nov 22, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to identify tasks based on their UID.
parent
947ec5ae
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
2 deletions
+54
-2
bin/topydo.conf
bin/topydo.conf
+1
-0
test/SortCommandTest.py
test/SortCommandTest.py
+16
-0
test/TodoListTest.py
test/TodoListTest.py
+18
-0
test/data/todolist-uid.conf
test/data/todolist-uid.conf
+2
-0
topydo/lib/Config.py
topydo/lib/Config.py
+4
-0
topydo/lib/TodoListBase.py
topydo/lib/TodoListBase.py
+13
-2
No files found.
bin/topydo.conf
View file @
d7ff4f48
...
...
@@ -6,6 +6,7 @@ default_command = ls
;
archive_filename
=
done
.
txt
colors
=
1
highlight_projects_contexts
=
1
identifiers
=
linenumber
;
or
:
text
[
ls
]
indent
=
0
...
...
test/SortCommandTest.py
View file @
d7ff4f48
...
...
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
CommandTest
from
Config
import
config
import
SortCommand
import
TestFacilities
...
...
@@ -22,6 +23,10 @@ class SortCommandTest(CommandTest.CommandTest):
def
setUp
(
self
):
self
.
todolist
=
TestFacilities
.
load_file_to_todolist
(
"data/SorterTest1.txt"
)
def
tearDown
(
self
):
# restore to the default configuration in case a custom one was set
config
(
""
)
def
test_sort1
(
self
):
""" Alphabetically sorted """
command
=
SortCommand
.
SortCommand
([
"text"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
...
...
@@ -35,6 +40,17 @@ class SortCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
str
(
self
.
todolist
),
"(A) Foo
\
n
2014-06-14 Last
\
n
First"
)
def
test_sort3
(
self
):
""" Check that order does not influence the UID of a todo. """
config
(
"data/todolist-uid.conf"
)
todo1
=
self
.
todolist
.
todo
(
'tpi'
)
command
=
SortCommand
.
SortCommand
([
"text"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
todo2
=
self
.
todolist
.
todo
(
'tpi'
)
self
.
assertEquals
(
todo1
.
source
(),
todo2
.
source
())
def
test_help
(
self
):
command
=
SortCommand
.
SortCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
test/TodoListTest.py
View file @
d7ff4f48
...
...
@@ -19,6 +19,7 @@
import
re
import
unittest
from
Config
import
config
import
Todo
import
TodoFile
from
TodoListBase
import
InvalidTodoException
...
...
@@ -32,6 +33,10 @@ class TodoListTester(unittest.TestCase):
self.text = ''.join(lines)
self.todolist = TodoList.TodoList(lines)
def tearDown(self):
# restore to the default configuration in case a custom one was set
config("")
def test_contexts(self):
self.assertEquals(set(['
Context1
', '
Context2
']),
\
self.todolist.contexts())
...
...
@@ -191,6 +196,19 @@ class TodoListTester(unittest.TestCase):
self
.
assertTrue
(
todo
)
self
.
assertEquals
(
todo
.
source
(),
"(D) Bar @Context1 +Project2"
)
def
test_uid1
(
self
):
config
(
"data/todolist-uid.conf"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
'6iu'
).
source
(),
"(C) Foo @Context2 Not@Context +Project1 Not+Project"
)
def
test_uid2
(
self
):
""" Changing the priority should not change the identifier. """
config
(
"data/todolist-uid.conf"
)
todo
=
self
.
todolist
.
todo
(
'6iu'
)
self
.
todolist
.
set_priority
(
todo
,
'B'
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
'6iu'
).
source
(),
"(B) Foo @Context2 Not@Context +Project1 Not+Project"
)
class
TodoListDependencyTester
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
todolist
=
TodoList
.
TodoList
([])
...
...
test/data/todolist-uid.conf
0 → 100644
View file @
d7ff4f48
[
topydo
]
identifiers
=
text
topydo/lib/Config.py
View file @
d7ff4f48
...
...
@@ -36,6 +36,7 @@ class _Config:
'highlight_projects_contexts'
:
'1'
,
'filename'
:
'todo.txt'
,
'archive_filename'
:
'done.txt'
,
'identifiers'
:
'linenumber'
,
# ls
'indent'
:
0
,
...
...
@@ -93,6 +94,9 @@ class _Config:
def
archive
(
self
):
return
self
.
cp
.
get
(
'topydo'
,
'archive_filename'
)
def
identifiers
(
self
):
return
self
.
cp
.
get
(
'topydo'
,
'identifiers'
)
def
list_limit
(
self
):
try
:
return
self
.
cp
.
getint
(
'ls'
,
'list_limit'
)
...
...
topydo/lib/TodoListBase.py
View file @
d7ff4f48
...
...
@@ -21,6 +21,7 @@ A list of todo items.
from
datetime
import
date
import
re
from
Config
import
config
import
Filter
from
HashListValues
import
hash_list_values
from
PrettyPrinter
import
pretty_print_list
...
...
@@ -56,13 +57,23 @@ class TodoListBase(object):
The _todos list has the same order as in the backend store (usually
a todo.txt file. The user refers to the first task as number 1, so use
index 0, etc.
Alternative ways to identify a todo is using a hashed version based on
the todo's text, or a regexp that matches the todo's source. The regexp
match is a fallback.
Returns None when the todo couldn't be found.
"""
result
=
None
try
:
if
config
().
identifiers
()
==
'text'
:
result
=
self
.
_id_todo_map
[
p_identifier
]
else
:
result
=
self
.
_todos
[
int
(
p_identifier
)
-
1
]
except
IndexError
:
raise
InvalidTodoException
except
(
TypeError
,
ValueError
):
except
(
TypeError
,
ValueError
,
KeyError
):
result
=
self
.
todo_by_regexp
(
p_identifier
)
return
result
...
...
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