# HG changeset patch # User Steve Losh # Date 1476030827 0 # Node ID 1d79df25277b7b65f5a5ab6a3d1ec7a1514d2666 # Parent 27d8f89d64c398d9a7a63207d16ef361c3a00bfb# Parent bc7821308e0bedefbd5009ab0a92babe4c828960 Merge. diff -r bc7821308e0b -r 1d79df25277b t.py --- 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))