mirror of
https://github.com/topydo/topydo.git
synced 2024-05-20 05:48:35 +00:00
Add auto_delete_whitespace config variable
Make the feature that deletes blank lines on load optional. Defaults to true, to preserve existing behavior.
This commit is contained in:
parent
09438df104
commit
0bf7b8030e
|
@ -240,6 +240,8 @@ Error message and password prompt
|
|||
|
||||
<li>ConfigAutoCreation</li>
|
||||
|
||||
<li>ConfigAutoWhitespace</li>
|
||||
|
||||
<li>ConfigBackupCount</li>
|
||||
|
||||
<li>ConfigColors</li>
|
||||
|
@ -9909,6 +9911,12 @@ Automatically add the creation date to a todo item that is added with the <&l
|
|||
|
||||
The creation date is used to determine the length of a todo item, in case the [[start date|TagStart]] is missing.</pre>
|
||||
</div>
|
||||
<div bag="default" config-default="1" config-description="Automatically remove vertical whitespace on load" config-group="topydo" config-item="auto_delete_whitespace" config-type="Boolean" created="20190107003932467" modified="20190107004209208" revision="0" tags="Configuration" title="ConfigAutoWhitespace" type="text/vnd.tiddlywiki">
|
||||
<pre><<config>>
|
||||
|
||||
Automatically remove any line that does not contain a space when loading the todo list. This has the effect of eliminating space left from previously deleted tasks, and any other blank lines in the document.
|
||||
</pre>
|
||||
</div>
|
||||
<div bag="default" config-default="5" config-description="The number of [[backups|Backups]] to make (0 disables backups)" config-group="topydo" config-item="backup_count" config-type="Integer" created="20160520103135844" modified="20160622123411778" revision="0" tags="Configuration" title="ConfigBackupCount" type="text/vnd.tiddlywiki">
|
||||
<pre><<config>>
|
||||
|
||||
|
@ -10393,6 +10401,24 @@ The background color is the [[progress color|ProgressColors]] of the correspondi
|
|||
|
||||
The <<cmd dep>> command is also Dot aware, which allows you to generate a specific dependency tree.</pre>
|
||||
</div>
|
||||
<div bag="default" created="20160625135840359" draft.of="$:/my/macros/ConfigTable" draft.title="$:/my/macros/ConfigTable" modified="20190107003309761" revision="0" tags="$:/tags/Macro" title="Draft of '$:/my/macros/ConfigTable'" type="text/vnd.tiddlywiki">
|
||||
<pre>\define configTable()
|
||||
<!-- Set variable 'group' to display a table for that configuration group -->
|
||||
<table>
|
||||
<tr><th>Name</th><th>Type</th><th>Default</th><th>Description</th></tr>
|
||||
|
||||
<$list filter="[tag[Configuration]field:config-group[$(group)$]sort[config-item]]" variable="item">
|
||||
<tr>
|
||||
<td><$link to=<<item>>><$transclude tiddler=<<item>> field="config-item"/></$link></td>
|
||||
<td><$transclude tiddler=<<item>> field="config-type"/></td>
|
||||
<td><$transclude tiddler=<<item>> field="config-default"/></td>
|
||||
<td><$transclude tiddler=<<item>> field="config-description"/></td>
|
||||
</tr>
|
||||
</$list>
|
||||
</table>
|
||||
|
||||
\end</pre>
|
||||
</div>
|
||||
<div bag="default" created="20160715052254901" modified="20160715052254901" revision="0" title="Draft of 'CLI'" type="text/vnd.tiddlywiki">
|
||||
<pre></pre>
|
||||
</div>
|
||||
|
|
2
test/data/listload.conf
Normal file
2
test/data/listload.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
[topydo]
|
||||
auto_delete_whitespace = 0
|
2
test/data/listload2.conf
Normal file
2
test/data/listload2.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
[topydo]
|
||||
auto_delete_whitespace = invalid
|
|
@ -509,5 +509,30 @@ class TodoListCleanDependencyTester(TopydoTest):
|
|||
self.assertFalse(self.todolist.todo_by_dep_id('1'))
|
||||
|
||||
|
||||
class TodoLoadTester(TopydoTest):
|
||||
"""Test the auto_delete_whitespace configuration parameter"""
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.todoPath = 'test/data/TodoListTest.txt'
|
||||
self.todofile = TodoFile(self.todoPath)
|
||||
|
||||
def test_load_default(self):
|
||||
todolist = TodoListBase(self.todofile.read())
|
||||
|
||||
self.assertTrue(all([len(todo.source()) != 0 for todo in todolist]))
|
||||
|
||||
def test_load_preserve_ws(self):
|
||||
config("test/data/listload.conf")
|
||||
todolist = TodoListBase(self.todofile.read())
|
||||
|
||||
self.assertTrue(any([len(todo.source()) == 0 for todo in todolist]))
|
||||
|
||||
def test_load_use_default(self):
|
||||
config("test/data/listload2.conf")
|
||||
todolist = TodoListBase(self.todofile.read())
|
||||
|
||||
self.assertTrue(all([len(todo.source()) != 0 for todo in todolist]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -9,6 +9,7 @@ colors = auto
|
|||
identifiers = linenumber
|
||||
identifier_alphabet = 0123456789abcdefghijklmnopqrstuvwxyz
|
||||
backup_count = 5
|
||||
auto_delete_whitespace = 1
|
||||
|
||||
[add]
|
||||
auto_creation_date = 1
|
||||
|
|
|
@ -73,6 +73,7 @@ class _Config:
|
|||
'identifiers': 'linenumber',
|
||||
'identifier_alphabet': '0123456789abcdefghijklmnopqrstuvwxyz',
|
||||
'backup_count': '5',
|
||||
'auto_delete_whitespace': '1',
|
||||
},
|
||||
|
||||
'add': {
|
||||
|
@ -260,6 +261,12 @@ class _Config:
|
|||
except ValueError:
|
||||
return int(self.defaults['topydo']['backup_count'])
|
||||
|
||||
def auto_delete_whitespace(self):
|
||||
try:
|
||||
return self.cp.getboolean('topydo', 'auto_delete_whitespace')
|
||||
except ValueError:
|
||||
return self.defaults['topydo']['auto_delete_whitespace'] == '1'
|
||||
|
||||
def list_limit(self):
|
||||
try:
|
||||
return self.cp.getint('ls', 'list_limit')
|
||||
|
|
|
@ -146,7 +146,9 @@ class TodoListBase(object):
|
|||
return todos[0] if len(todos) else None
|
||||
|
||||
def add_list(self, p_srcs):
|
||||
todos = [Todo(src) for src in p_srcs if re.search(r'\S', src)]
|
||||
todos = [Todo(src) for src in p_srcs]
|
||||
if config().auto_delete_whitespace():
|
||||
todos = [todo for todo in todos if re.search(r'\S', todo.source())]
|
||||
self.add_todos(todos)
|
||||
|
||||
return todos
|
||||
|
|
Loading…
Reference in a new issue