# HG changeset patch # User Steve Losh # Date 1251324778 14400 # Node ID 90526072108a60b91189c4e1534835d3e9582168 # Parent b92ebe6d7e77c31b3864fda7851e1453d26f7144 Rearrange the class methods. diff -r b92ebe6d7e77 -r 90526072108a t.py --- a/t.py Wed Aug 26 18:12:24 2009 -0400 +++ b/t.py Wed Aug 26 18:12:58 2009 -0400 @@ -90,21 +90,6 @@ id = _hash(text) self.tasks[id] = {'id': id, 'text': text} - def write(self): - """Flush the finished and unfinished tasks to the files on disk.""" - filemap = (('tasks', self.name), ('done', '.%s.done' % self.name)) - for kind, filename in filemap: - path = os.path.join(os.path.expanduser(self.taskdir), filename) - if os.path.isdir(path): - raise InvalidTaskfile - with open(path, 'w') as tfile: - tasks = getattr(self, kind).values() - tasks.sort(key=operator.itemgetter('id')) - for task in tasks: - meta = [m for m in task.items() if m[0] != 'text'] - meta_str = ', '.join('%s:%s' % m for m in meta) - tfile.write('%s | %s\n' % (task['text'], meta_str)) - def print_list(self, kind='tasks', verbose=False): """Print out a nicely formatted list of unfinished tasks.""" tasks = dict(getattr(self, kind).items()) @@ -134,6 +119,21 @@ """Remove all finished tasks.""" self.done = {} + def write(self): + """Flush the finished and unfinished tasks to the files on disk.""" + filemap = (('tasks', self.name), ('done', '.%s.done' % self.name)) + for kind, filename in filemap: + path = os.path.join(os.path.expanduser(self.taskdir), filename) + if os.path.isdir(path): + raise InvalidTaskfile + with open(path, 'w') as tfile: + tasks = getattr(self, kind).values() + tasks.sort(key=operator.itemgetter('id')) + for task in tasks: + meta = [m for m in task.items() if m[0] != 'text'] + meta_str = ', '.join('%s:%s' % m for m in meta) + tfile.write('%s | %s\n' % (task['text'], meta_str)) + def build_parser(): parser = OptionParser()