Slightly reformat due

This commit is contained in:
Adam Goldsmith 2018-01-22 13:33:38 -05:00
parent d74c2878ba
commit 2105f48ebb
1 changed files with 5 additions and 6 deletions

11
due.py
View File

@ -19,7 +19,7 @@ class todo_item:
def __init__(self, text):
self.text = text
try:
self.full_tag = re.findall("[^ ]+:\\d\\d\\d\\d-\\d\\d-\\d\\d", text)[0].strip()
self.full_tag = re.findall("[^ ]+:\\d{4}-\\d{2}-\\d{2}", text)[0].strip()
self.tag = self.full_tag.split(":")
self.date = datetime.strptime(self.tag[1], "%Y-%m-%d")
except IndexError:
@ -34,16 +34,15 @@ class todo_item:
def fancy_print(self, relative=False):
if self.date < datetime.today():
#if the date has already passed, wrap with bold/unbold escapes
fancy_text = self.text.replace(self.full_tag,
'\033[1m' + self.full_tag + '\033[22m')
fancy_text = self.text.replace(
self.full_tag, '\033[1m' + self.full_tag + '\033[22m')
else:
fancy_text = self.text
if relative:
difference = (self.date - datetime.now()).days + 1
fancy_text = fancy_text.replace(self.full_tag,
"{}:{} days".format(self.tag[0],
difference))
fancy_text = fancy_text.replace(
self.full_tag, "{}:{} days".format(self.tag[0], difference))
return fancy_text