906a8111a48a

Formatting and whitespace.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 26 Aug 2009 17:30:07 -0400
parents 0b4ae60b9015
children 712ea48e6ee3
branches/tags (none)
files t.py

Changes

--- a/t.py	Wed Aug 26 17:28:25 2009 -0400
+++ b/t.py	Wed Aug 26 17:30:07 2009 -0400
@@ -15,13 +15,13 @@
 
 def _task_from_taskline(taskline):
     """Parse a taskline (from a task file) and return a task.
-
+    
     A taskline should be in the format:
-
+    
         summary text ... | meta1:meta1_value,meta2:meta2_value,...
-
+    
     The task returned will be a dictionary such as:
-
+    
         { 'id': <hash id>,
           'text': <summary text>,
            ... other metadata ... }
@@ -36,10 +36,10 @@
 
 def _prefixes(ids):
     """return a mapping of ids to prefixes
-
+    
     Each prefix will be the shortest possible substring of the ID that
     can uniquely identify it among the given group of IDs.
-
+    
     """
     
     prefixes = {}
@@ -71,7 +71,7 @@
     def add_task(self, text):
         id = _hash(text)
         self.tasks[id] = {'id': id, 'text': text}
-
+    
     def write(self):
         filemap = (('tasks', self.name), ('done', '.%s.done' % self.name))
         for kind, filename in filemap:
@@ -102,10 +102,10 @@
             self.done[task['id']] = task
         else:
             raise AmbiguousPrefix
-
+    
     def delete_finished(self):
         self.done = {}
-
+    
 
 def build_parser():
     parser = OptionParser()
@@ -128,20 +128,21 @@
                       help="print more detailed output (full task ids, etc)")
     return parser
 
-(options, args) = build_parser().parse_args()
-
-td = TaskDict(options.name)
-text = ' '.join(args)
+if __name__ == '__main__':
+    (options, args) = build_parser().parse_args()
+    
+    td = TaskDict(options.name)
+    text = ' '.join(args)
+    
+    if options.finish:
+        td.finish_task(options.finish)
+        td.write()
+    elif options.delete_finished:
+        td.delete_finished()
+        td.write()
+    elif text:
+        td.add_task(text)
+        td.write()
+    else:
+        td.print_list(verbose=options.verbose)
 
-if options.finish:
-    td.finish_task(options.finish)
-    td.write()
-elif options.delete_finished:
-    td.delete_finished()
-    td.write()
-elif text:
-    td.add_task(text)
-    td.write()
-else:
-    td.print_list(verbose=options.verbose)
-