diff options
author | Mike Crute <mcrute@gmail.com> | 2010-02-04 21:56:55 -0500 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2010-02-04 21:56:55 -0500 |
commit | d977817fbc99e6752f804cab1d0fd82b96e569e6 (patch) | |
tree | 6536f64ef2f2df8ec911d32263e7e0ef9e98e3f4 | |
parent | 5f6c2c4c3f9aeddd5e07e0d2bb25df15b2cc0eb0 (diff) | |
download | kronos-d977817fbc99e6752f804cab1d0fd82b96e569e6.tar.bz2 kronos-d977817fbc99e6752f804cab1d0fd82b96e569e6.tar.xz kronos-d977817fbc99e6752f804cab1d0fd82b96e569e6.zip |
Last thoughts about the parser.
-rw-r--r-- | kronos/parser.py | 11 | ||||
-rw-r--r-- | kronos/tests/test_parser.py | 1 |
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 | ||
41 | def parse_tags(tokens): | 41 | def _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 | ||
45 | def strip_tags(tokens): | 45 | def _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. | ||
64 | class TestWhenParsingWithTimeOffset(object): | 65 | class TestWhenParsingWithTimeOffset(object): |
65 | 66 | ||
66 | def test_should_understand_minutes(self): | 67 | def test_should_understand_minutes(self): |