summaryrefslogtreecommitdiff
path: root/kronos/parser.py
blob: b18b4f99b4ed2fccf8089fc98dcf4402492db80f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# vim: set filencoding=utf8
"""
Activity Parser

@author: Mike Crute (mcrute@ag.com)
@organization: American Greetings Interactive
@date: February 04, 2010
"""

class Activity(object):

    def __init__(self, activity, description=None, category=None):
        self.activity = activity
        self.description = description
        self.category = category


def parse_activity(text):
    description = None
    if ',' in text:
        text, description = text.split(',', 1)
        description = description.strip()

    category = None
    if '@' in text:
        text, category = text.split('@', 1)
        category = category.strip()

    activity = text.strip()

    return Activity(activity, description, category)