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
13d2a633
Commit
13d2a633
authored
Jul 22, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:bram85/topydo
parents
013fe700
45bcd4a9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
3 deletions
+33
-3
test/test_revert_command.py
test/test_revert_command.py
+14
-0
topydo/lib/ChangeSet.py
topydo/lib/ChangeSet.py
+4
-1
topydo/ui/CLIApplicationBase.py
topydo/ui/CLIApplicationBase.py
+15
-2
No files found.
test/test_revert_command.py
View file @
13d2a633
...
@@ -284,6 +284,20 @@ class RevertCommandTest(CommandTest):
...
@@ -284,6 +284,20 @@ class RevertCommandTest(CommandTest):
self
.
assertEqual
(
result
,
[])
self
.
assertEqual
(
result
,
[])
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_revert07
(
self
):
""" Test backup when no archive file is set """
backup
=
ChangeSet
(
self
.
todolist
,
None
,
[
'add One'
])
backup
.
timestamp
=
'1'
command1
=
AddCommand
([
"One"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command1
.
execute
()
backup
.
save
(
self
.
todolist
)
changesets
=
list
(
backup
.
backup_dict
.
keys
())
changesets
.
remove
(
'index'
)
self
.
assertEqual
(
len
(
changesets
),
1
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_backup_config01
(
self
):
def
test_backup_config01
(
self
):
config
(
p_overrides
=
{(
'topydo'
,
'backup_count'
):
'1'
})
config
(
p_overrides
=
{(
'topydo'
,
'backup_count'
):
'1'
})
...
...
topydo/lib/ChangeSet.py
View file @
13d2a633
...
@@ -99,7 +99,10 @@ class ChangeSet(object):
...
@@ -99,7 +99,10 @@ class ChangeSet(object):
current_hash
=
hash_todolist
(
p_todolist
)
current_hash
=
hash_todolist
(
p_todolist
)
list_todo
=
(
self
.
todolist
.
print_todos
()
+
'
\
n
'
).
splitlines
(
True
)
list_todo
=
(
self
.
todolist
.
print_todos
()
+
'
\
n
'
).
splitlines
(
True
)
try
:
list_archive
=
(
self
.
archive
.
print_todos
()
+
'
\
n
'
).
splitlines
(
True
)
list_archive
=
(
self
.
archive
.
print_todos
()
+
'
\
n
'
).
splitlines
(
True
)
except
AttributeError
:
list_archive
=
[]
self
.
backup_dict
[
self
.
timestamp
]
=
(
list_todo
,
list_archive
,
self
.
call
)
self
.
backup_dict
[
self
.
timestamp
]
=
(
list_todo
,
list_archive
,
self
.
call
)
...
...
topydo/ui/CLIApplicationBase.py
View file @
13d2a633
...
@@ -150,6 +150,17 @@ from topydo.lib import TodoListBase
...
@@ -150,6 +150,17 @@ from topydo.lib import TodoListBase
from
topydo.lib.Utils
import
escape_ansi
from
topydo.lib.Utils
import
escape_ansi
def
_retrieve_archive
():
"""
Returns a tuple with archive content: the first element is a TodoListBase
and the second element is a TodoFile.
"""
archive_file
=
TodoFile
.
TodoFile
(
config
().
archive
())
archive
=
TodoListBase
.
TodoListBase
(
archive_file
.
read
())
return
(
archive
,
archive_file
)
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
...
@@ -211,8 +222,7 @@ class CLIApplicationBase(object):
...
@@ -211,8 +222,7 @@ class CLIApplicationBase(object):
This means that all completed tasks are moved to the archive file
This means that all completed tasks are moved to the archive file
(defaults to done.txt).
(defaults to done.txt).
"""
"""
archive_file
=
TodoFile
.
TodoFile
(
config
().
archive
())
archive
,
archive_file
=
_retrieve_archive
()
archive
=
TodoListBase
.
TodoListBase
(
archive_file
.
read
())
if
self
.
backup
:
if
self
.
backup
:
self
.
backup
.
add_archive
(
archive
)
self
.
backup
.
add_archive
(
archive
)
...
@@ -275,6 +285,9 @@ class CLIApplicationBase(object):
...
@@ -275,6 +285,9 @@ class CLIApplicationBase(object):
# (i.e. explicitly left empty in the configuration
# (i.e. explicitly left empty in the configuration
if
self
.
do_archive
and
config
().
archive
():
if
self
.
do_archive
and
config
().
archive
():
self
.
_archive
()
self
.
_archive
()
elif
config
().
archive
()
and
self
.
backup
:
archive
=
_retrieve_archive
()[
0
]
self
.
backup
.
add_archive
(
archive
)
if
config
().
keep_sorted
():
if
config
().
keep_sorted
():
from
topydo.commands.SortCommand
import
SortCommand
from
topydo.commands.SortCommand
import
SortCommand
...
...
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