Commit 3a8e8efa authored by Jacek Sowiński's avatar Jacek Sowiński

Add %I for identifiers padded with spaces

It calculates if actual todo id is shorter than 3 characters and adds
additional space or two to maintain fixed length of this parameter.

Also set %I as default instead of %i to provide compatibility with
tests and.
parent eaf382a0
......@@ -15,7 +15,7 @@ auto_creation_date = 1
hide_tags = id,p,ical
indent = 0
list_limit = -1
list_format = |%i| %{(}p{)} %s
list_format = |%I| %{(}p{)} %s
[tags]
tag_start = t
......
......@@ -69,7 +69,7 @@ class _Config:
'hide_tags': 'id,p,ical',
'indent': '0',
'list_limit': '-1',
'list_format': '|%i| %{(}p{)} %s',
'list_format': '|%I| %c %{(}p{)} %s',
},
'tags': {
......
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 - 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" Ulities for formatting output with "list_format" option."""
def filler(p_str, p_len):
"""
Returns p_str preceded by additional spaces if p_str is shorter than p_len.
"""
to_fill = p_len - len(p_str)
return to_fill*' ' + p_str
......@@ -22,6 +22,7 @@ from six import u
from topydo.lib.Colors import NEUTRAL_COLOR, Colors
from topydo.lib.Config import config
from topydo.lib.ListFormat import filler
class PrettyPrinterFilter(object):
......@@ -150,6 +151,9 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
# todo ID
'i': lambda t: str(self.todolist.number(t)),
# todo ID pre-filled with 1 or 2 spaces if its length is <3
'I': lambda t: filler(str(self.todolist.number(t)), 3),
# list of tags (spaces)
'K': lambda t: ' '.join(['{}:{}'.format(tag, value)
for tag, value in sorted(p_todo.tags())]),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment