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
cb403037
Commit
cb403037
authored
Nov 12, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pretty printer filter for adding indent.
parent
6f8e873c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
2 deletions
+24
-2
bin/topydo.conf
bin/topydo.conf
+1
-0
test/ListCommandTest.py
test/ListCommandTest.py
+10
-0
topydo/lib/Config.py
topydo/lib/Config.py
+7
-0
topydo/lib/ListCommand.py
topydo/lib/ListCommand.py
+3
-2
topydo/lib/PrettyPrinter.py
topydo/lib/PrettyPrinter.py
+3
-0
No files found.
bin/topydo.conf
View file @
cb403037
...
@@ -8,6 +8,7 @@ colors = 1
...
@@ -8,6 +8,7 @@ colors = 1
highlight_projects_contexts
=
1
highlight_projects_contexts
=
1
[
ls
]
[
ls
]
indent
=
0
list_limit
= -
1
list_limit
= -
1
[
tags
]
[
tags
]
...
...
test/ListCommandTest.py
View file @
cb403037
...
@@ -127,6 +127,16 @@ class ListCommandTest(CommandTest.CommandTest):
...
@@ -127,6 +127,16 @@ class ListCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
" 1 (C) Foo @Context2 Not@Context +Project1 Not+Project
\
n
3 (C) Baz @Context1 +Project1 key:value id:1
\
n
4 (C) Drink beer @ home
\
n
5 (C) 13 + 29 = 42
\
n
"
)
self
.
assertEquals
(
self
.
output
,
" 1 (C) Foo @Context2 Not@Context +Project1 Not+Project
\
n
3 (C) Baz @Context1 +Project1 key:value id:1
\
n
4 (C) Drink beer @ home
\
n
5 (C) 13 + 29 = 42
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list14
(
self
):
config
(
"data/listcommand2.conf"
)
command
=
ListCommand
.
ListCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
" 1 (C) Foo @Context2 Not@Context +Project1 Not+Project
\
n
4 (C) Drink beer @ home
\
n
5 (C) 13 + 29 = 42
\
n
2 (D) Bar @Context1 +Project2 p:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_help
(
self
):
def
test_help
(
self
):
command
=
ListCommand
.
ListCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
.
ListCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
...
...
topydo/lib/Config.py
View file @
cb403037
...
@@ -38,6 +38,7 @@ class _Config:
...
@@ -38,6 +38,7 @@ class _Config:
'archive_filename'
:
'done.txt'
,
'archive_filename'
:
'done.txt'
,
# ls
# ls
'indent'
:
0
,
'list_limit'
:
'-1'
,
'list_limit'
:
'-1'
,
# tags
# tags
...
@@ -95,6 +96,12 @@ class _Config:
...
@@ -95,6 +96,12 @@ class _Config:
except
ValueError
:
except
ValueError
:
return
int
(
self
.
defaults
[
'list_limit'
])
return
int
(
self
.
defaults
[
'list_limit'
])
def
list_indent
(
self
):
try
:
return
self
.
cp
.
getint
(
'ls'
,
'indent'
)
except
ValueError
:
return
int
(
self
.
defaults
[
'indent'
])
def
sort_string
(
self
):
def
sort_string
(
self
):
return
self
.
cp
.
get
(
'sort'
,
'sort_string'
)
return
self
.
cp
.
get
(
'sort'
,
'sort_string'
)
...
...
topydo/lib/ListCommand.py
View file @
cb403037
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
import
Command
import
Command
from
Config
import
config
from
Config
import
config
import
Filter
import
Filter
from
PrettyPrinter
import
pp_indent
import
Sorter
import
Sorter
class
ListCommand
(
Command
.
Command
):
class
ListCommand
(
Command
.
Command
):
...
@@ -40,7 +41,6 @@ class ListCommand(Command.Command):
...
@@ -40,7 +41,6 @@ class ListCommand(Command.Command):
self
.
args
=
args
self
.
args
=
args
def
_filters
(
self
):
def
_filters
(
self
):
filters
=
[]
filters
=
[]
...
@@ -74,7 +74,8 @@ class ListCommand(Command.Command):
...
@@ -74,7 +74,8 @@ class ListCommand(Command.Command):
sorter
=
Sorter
.
Sorter
(
self
.
sort_expression
)
sorter
=
Sorter
.
Sorter
(
self
.
sort_expression
)
filters
=
self
.
_filters
()
filters
=
self
.
_filters
()
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
())
pp_filters
=
[
pp_indent
(
config
().
list_indent
())]
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
(
pp_filters
))
def
usage
(
self
):
def
usage
(
self
):
return
"""Synopsis: ls [-x] [-s <sort_expression>] [expression]"""
return
"""Synopsis: ls [-x] [-s <sort_expression>] [expression]"""
...
...
topydo/lib/PrettyPrinter.py
View file @
cb403037
...
@@ -53,6 +53,9 @@ def pp_color(p_todo_str, p_todo):
...
@@ -53,6 +53,9 @@ def pp_color(p_todo_str, p_todo):
return
p_todo_str
return
p_todo_str
def
pp_indent
(
p_indent
=
0
):
return
lambda
s
,
t
:
' '
*
p_indent
+
s
def
pretty_print
(
p_todo
,
p_filters
=
[]):
def
pretty_print
(
p_todo
,
p_filters
=
[]):
"""
"""
Given a todo item, pretty print it and return a list of formatted strings.
Given a todo item, pretty print it and return a list of formatted strings.
...
...
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