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
076e9852
Commit
076e9852
authored
Apr 25, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new sort field for length of a todo item
parent
181b2743
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
0 deletions
+29
-0
test/data/SorterTest14-result.txt
test/data/SorterTest14-result.txt
+8
-0
test/data/SorterTest14.txt
test/data/SorterTest14.txt
+8
-0
test/test_sorter.py
test/test_sorter.py
+11
-0
topydo/lib/Sorter.py
topydo/lib/Sorter.py
+2
-0
No files found.
test/data/SorterTest14-result.txt
0 → 100644
View file @
076e9852
1 No length (zero)
2016-04-25 2 No length (zero)
3 Length of 0 days t:2016-04-25 due:2016-04-25
4 Length of 0 days t:2016-04-25 due:2016-04-25
5 Length of 0 days tomorrow t:2016-04-26 due:2016-04-26
2016-04-25 1 Length of 1 day with creation due:2016-04-26
2 Length of 1 day t:2016-04-25 due:2016-04-26
2016-04-25 Length of 2 days with creation due:2016-04-27
test/data/SorterTest14.txt
0 → 100644
View file @
076e9852
4 Length of 0 days t:2016-04-25 due:2016-04-25
2016-04-25 2 No length (zero)
3 Length of 0 days t:2016-04-25 due:2016-04-25
5 Length of 0 days tomorrow t:2016-04-26 due:2016-04-26
2 Length of 1 day t:2016-04-25 due:2016-04-26
2016-04-25 Length of 2 days with creation due:2016-04-27
2016-04-25 1 Length of 1 day with creation due:2016-04-26
1 No length (zero)
test/test_sorter.py
View file @
076e9852
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
freezegun
import
freeze_time
import
unittest
import
unittest
from
test.facilities
import
(
load_file
,
load_file_to_todolist
,
print_view
,
from
test.facilities
import
(
load_file
,
load_file_to_todolist
,
print_view
,
...
@@ -23,6 +24,7 @@ from topydo.lib.Config import config
...
@@ -23,6 +24,7 @@ from topydo.lib.Config import config
from
topydo.lib.Sorter
import
Sorter
from
topydo.lib.Sorter
import
Sorter
@
freeze_time
(
"2016, 04, 25"
)
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
):
"""
"""
...
@@ -189,5 +191,14 @@ class SorterTest(TopydoTest):
...
@@ -189,5 +191,14 @@ class SorterTest(TopydoTest):
'test/data/SorterTest13-result-context.txt'
,
sorter
)
'test/data/SorterTest13-result-context.txt'
,
sorter
)
def
test_sort18
(
self
):
"""
Check sorting by length.
"""
sorter
=
Sorter
(
'length,text'
)
self
.
sort_file
(
'test/data/SorterTest14.txt'
,
'test/data/SorterTest14-result.txt'
,
sorter
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
topydo/lib/Sorter.py
View file @
076e9852
...
@@ -52,6 +52,8 @@ def get_field_function(p_field):
...
@@ -52,6 +52,8 @@ def get_field_function(p_field):
result
=
importance
result
=
importance
elif
p_field
==
'importance-avg'
or
p_field
==
'importance-average'
:
elif
p_field
==
'importance-avg'
or
p_field
==
'importance-average'
:
result
=
average_importance
result
=
average_importance
elif
p_field
==
'length'
:
result
=
lambda
a
:
a
.
length
()
elif
p_field
==
'project'
or
p_field
==
'projects'
:
elif
p_field
==
'project'
or
p_field
==
'projects'
:
result
=
lambda
a
:
sorted
([
c
.
lower
()
for
c
in
a
.
projects
()])
result
=
lambda
a
:
sorted
([
c
.
lower
()
for
c
in
a
.
projects
()])
elif
p_field
==
'text'
:
elif
p_field
==
'text'
:
...
...
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