--- a/t.py Sun Oct 02 12:56:52 2016 +0000
+++ b/t.py Sun Oct 09 16:33:47 2016 +0000
@@ -39,7 +39,7 @@
Currently SHA1 hashing is used. It should be plenty for our purposes.
"""
- return hashlib.sha1(text).hexdigest()
+ return hashlib.sha1(text.encode('utf-8')).hexdigest()
def _task_from_taskline(taskline):
"""Parse a taskline (from a task file) and return a task.
@@ -160,13 +160,13 @@
If no tasks match the prefix an UnknownPrefix exception will be raised.
"""
- matched = filter(lambda tid: tid.startswith(prefix), self.tasks.keys())
+ matched = [tid for tid in self.tasks.keys() if tid.startswith(prefix)]
if len(matched) == 1:
return self.tasks[matched[0]]
elif len(matched) == 0:
raise UnknownPrefix(prefix)
else:
- matched = filter(lambda tid: tid == prefix, self.tasks.keys())
+ matched = [tid for tid in self.tasks.keys() if tid == prefix]
if len(matched) == 1:
return self.tasks[matched[0]]
else:
@@ -229,7 +229,7 @@
for _, task in sorted(tasks.items()):
if grep.lower() in task['text'].lower():
p = '%s - ' % task[label].ljust(plen) if not quiet else ''
- print p + task['text']
+ print (p + task['text'])
def write(self, delete_if_empty=False):
"""Flush the finished and unfinished tasks to the files on disk."""
@@ -316,9 +316,11 @@
kind = 'tasks' if not options.done else 'done'
td.print_list(kind=kind, verbose=options.verbose, quiet=options.quiet,
grep=options.grep)
- except AmbiguousPrefix, e:
+ except AmbiguousPrefix:
+ e = sys.exc_info()[1]
sys.stderr.write('The ID "%s" matches more than one task.\n' % e.prefix)
- except UnknownPrefix, e:
+ except UnknownPrefix:
+ e = sys.exc_info()[1]
sys.stderr.write('The ID "%s" does not match any task.\n' % e.prefix)
except BadFile, e:
sys.stderr.write('%s - %s\n' % (e.problem, e.path))