Commit 6b204b4b authored by Bram Schoenmakers's avatar Bram Schoenmakers

Fixed some pylint errors.

parent 0611a867
...@@ -14,7 +14,7 @@ ...@@ -14,7 +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/>.
""" Ulities for formatting output with "list_format" option.""" """ Utilities for formatting output with "list_format" option."""
import arrow import arrow
import re import re
...@@ -37,6 +37,7 @@ def filler(p_str, p_len): ...@@ -37,6 +37,7 @@ def filler(p_str, p_len):
return to_fill*' ' + p_str return to_fill*' ' + p_str
def humanize_date(p_datetime): def humanize_date(p_datetime):
""" Returns a relative date string from a datetime object. """
now = arrow.now() now = arrow.now()
date = now.replace(day=p_datetime.day, month=p_datetime.month, year=p_datetime.year) date = now.replace(day=p_datetime.day, month=p_datetime.month, year=p_datetime.year)
return date.humanize() return date.humanize()
...@@ -56,11 +57,10 @@ def humanize_dates(p_due=None, p_start=None, p_creation=None): ...@@ -56,11 +57,10 @@ def humanize_dates(p_due=None, p_start=None, p_creation=None):
dates_list.append('due ' + humanize_date(p_due)) dates_list.append('due ' + humanize_date(p_due))
if p_start: if p_start:
now = arrow.now().date() now = arrow.now().date()
start = humanize_date(p_start) dates_list.append('{} {}'.format(
if p_start <= now: 'started' if p_start <= now else 'starts',
dates_list.append('started ' + start) humanize_date(p_start)
else: ))
dates_list.append('starts ' + start)
return ', '.join(dates_list) return ', '.join(dates_list)
...@@ -133,7 +133,8 @@ class ListFormatParser(object): ...@@ -133,7 +133,8 @@ class ListFormatParser(object):
# list of tags (spaces) without hidden ones and due: and t: # list of tags (spaces) without hidden ones and due: and t:
'k': lambda t: ' '.join([u('{}:{}').format(tag, value) 'k': lambda t: ' '.join([u('{}:{}').format(tag, value)
for tag, value in sorted(t.tags()) if for tag, value in sorted(t.tags()) if
tag not in config().hidden_tags() + [config().tag_start(), config().tag_due()]]), tag not in config().hidden_tags() +
[config().tag_start(), config().tag_due()]]),
# list of all tags (spaces) # list of all tags (spaces)
'K': lambda t: ' '.join([u('{}:{}').format(tag, value) 'K': lambda t: ' '.join([u('{}:{}').format(tag, value)
...@@ -243,14 +244,14 @@ class ListFormatParser(object): ...@@ -243,14 +244,14 @@ class ListFormatParser(object):
attribute. attribute.
""" """
parsed_list = [] parsed_list = []
repl_S = None repl_trunc = None
for substr, placeholder, getter in self.format_list: for substr, placeholder, getter in self.format_list:
repl = getter(p_todo) if getter else '' repl = getter(p_todo) if getter else ''
pattern = MAIN_PATTERN.format(ph=placeholder) pattern = MAIN_PATTERN.format(ph=placeholder)
if placeholder == 'S': if placeholder == 'S':
repl_S = repl repl_trunc = repl
if repl == '': if repl == '':
substr = re.sub(pattern, '', substr) substr = re.sub(pattern, '', substr)
...@@ -264,7 +265,7 @@ class ListFormatParser(object): ...@@ -264,7 +265,7 @@ class ListFormatParser(object):
parsed_str = remove_redundant_spaces(parsed_str) parsed_str = remove_redundant_spaces(parsed_str)
if self.one_line and len(parsed_str) >= self.line_width: if self.one_line and len(parsed_str) >= self.line_width:
parsed_str = self.truncate(parsed_str, repl_S) parsed_str = self.truncate(parsed_str, repl_trunc)
if re.search('.*\t', parsed_str): if re.search('.*\t', parsed_str):
parsed_str = self.right_align(parsed_str) parsed_str = self.right_align(parsed_str)
......
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