b8afd9a5c913

Support lines without metadata in taskfiles to ease plaintext editing.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 28 Sep 2009 23:19:42 -0400
parents 68288cdc5a7f
children c00fff9956e6
branches/tags (none)
files t.py

Changes

--- a/t.py	Mon Sep 28 23:14:29 2009 -0400
+++ b/t.py	Mon Sep 28 23:19:42 2009 -0400
@@ -49,12 +49,19 @@
           'text': <summary text>,
            ... other metadata ... }
     
+    A taskline can also consist of only summary text, in which case the id
+    and other metadata will be generated when the line is read.  This is
+    supported to enable editing of the taskfile with a simple text editor.
     """
-    text, _, meta = taskline.partition('|')
-    task = { 'text': text.strip() }
-    for piece in meta.strip().split(','):
-        label, data = piece.split(':')
-        task[label.strip()] = data.strip()
+    if '|' in taskline:
+        text, _, meta = taskline.partition('|')
+        task = { 'text': text.strip() }
+        for piece in meta.strip().split(','):
+            label, data = piece.split(':')
+            task[label.strip()] = data.strip()
+    else:
+        text = taskline.strip()
+        task = { 'id': _hash(text), 'text': text }
     return task
 
 def _tasklines_from_tasks(tasks):