fix issues on namespace of 'colorama' variable

This commit is contained in:
William Minchin 2014-01-02 18:53:16 -07:00
parent afb5c03389
commit 516b01bb18
2 changed files with 4 additions and 5 deletions

View file

@ -168,11 +168,11 @@ class Journal(object):
for tag in self.search_tags:
tagre = re.compile(re.escape(tag), re.IGNORECASE)
pp = re.sub(tagre,
lambda match: util.colorize(match.group(0)),
lambda match: util.colorize(match.group(0), colorama),
pp, re.UNICODE)
else:
pp = re.sub(r"(?u)([{tags}]\w+)".format(tags=self.config['tagsymbols']),
lambda match: util.colorize(match.group(0)),
lambda match: util.colorize(match.group(0), colorama),
pp)
return pp
@ -435,4 +435,3 @@ class DayOne(Journal):
self._deleted_entries = [e for e in self.entries if e.uuid not in edited_uuids]
self.entries[:] = [e for e in self.entries if e.uuid in edited_uuids]
return entries

View file

@ -139,9 +139,9 @@ def get_text_from_editor(config, template=""):
prompt('[Nothing saved to file]')
return raw
def colorize(string):
def colorize(string, colorama=None):
"""Returns the string wrapped in cyan ANSI escape"""
if os.name == "nt" and not colorama:
return string
else:
return u"\033[36m{}\033[39m".format(string)
return u"\033[36m{}\033[39m".format(string)