summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2010-02-04 21:56:55 -0500
committerMike Crute <mcrute@gmail.com>2010-02-04 21:56:55 -0500
commitd977817fbc99e6752f804cab1d0fd82b96e569e6 (patch)
tree6536f64ef2f2df8ec911d32263e7e0ef9e98e3f4
parent5f6c2c4c3f9aeddd5e07e0d2bb25df15b2cc0eb0 (diff)
downloadkronos-d977817fbc99e6752f804cab1d0fd82b96e569e6.tar.bz2
kronos-d977817fbc99e6752f804cab1d0fd82b96e569e6.tar.xz
kronos-d977817fbc99e6752f804cab1d0fd82b96e569e6.zip
Last thoughts about the parser.
-rw-r--r--kronos/parser.py11
-rw-r--r--kronos/tests/test_parser.py1
2 files changed, 7 insertions, 5 deletions
diff --git a/kronos/parser.py b/kronos/parser.py
index 8d93391..f0543f9 100644
--- a/kronos/parser.py
+++ b/kronos/parser.py
@@ -24,8 +24,8 @@ def parse_activity(text):
24 description = description.strip() 24 description = description.strip()
25 25
26 tokens = description.split(' ') 26 tokens = description.split(' ')
27 tags = parse_tags(tokens) 27 tags = _parse_tags(tokens)
28 description = strip_tags(tokens) 28 description = _strip_tags(tokens)
29 29
30 category = None 30 category = None
31 if '@' in text: 31 if '@' in text:
@@ -38,9 +38,10 @@ def parse_activity(text):
38 return activity 38 return activity
39 39
40 40
41def parse_tags(tokens): 41def _parse_tags(tokens):
42 return [token.lstrip('#') for token in tokens if token.startswith('#')] 42 return [token.lstrip('#') for token in tokens if token.startswith('#')]
43 43
44 44
45def strip_tags(tokens): 45def _strip_tags(tokens):
46 return ' '.join([token for token in tokens if not token.startswith('#')]) 46 words = [token for token in tokens if not token.startswith('#')]
47 return ' '.join(words)
diff --git a/kronos/tests/test_parser.py b/kronos/tests/test_parser.py
index 015ae06..8a82a65 100644
--- a/kronos/tests/test_parser.py
+++ b/kronos/tests/test_parser.py
@@ -61,6 +61,7 @@ class TestWhenParsingWithTags(object):
61 assert_equals(self.results.description, "Some cool stuff!") 61 assert_equals(self.results.description, "Some cool stuff!")
62 62
63 63
64# TODO: Implement this functionality when I need it.
64class TestWhenParsingWithTimeOffset(object): 65class TestWhenParsingWithTimeOffset(object):
65 66
66 def test_should_understand_minutes(self): 67 def test_should_understand_minutes(self):