# Path: hurricane/base.py
# class Message(object):
#     def __init__(self, kind, timestamp, raw_data):
#         self.kind = kind
#         self.timestamp = timestamp
#         self.raw_data = raw_data
#         self.uuid = str(uuid.uuid4())
# 
#     def _asdict(self):
#         return {
#             'kind': self.kind,
#             'timestamp': self.timestamp,
#             'raw_data': self.raw_data,
#             'uuid': self.uuid,
#         }
#     
#     def __str__(self):
#         return str(self._asdict())
# 
#     def __repr__(self):
#         return '<%s %r>' % (type(self).__name__, str(self))
# 
# Path: hurricane/handlers/base.py
# class PurePublishHandler(BaseHandler):
#     """Works like a handler but does not subscribe to anything."""
# 
#     def auto_subscribe(self, app_manager):
#         pass


from datetime import datetime
from twitstream import twitstream
from hurricane.base import Message
from hurricane.handlers.base import PurePublishHandler




class TwitterHandler(PurePublishHandler):

    def process_tweet(self, msg):
        msg = Message('tweet', datetime.now(), msg)
        self.publish(msg)


    def run(self):
        twitstream.track(self.settings.TWITTER_USERNAME,
            self.settings.TWITTER_PASSWORD, self.process_tweet,

# Path: hurricane/base.py
# class Message(object):
#     def __init__(self, kind, timestamp, raw_data):
#         self.kind = kind
#         self.timestamp = timestamp
#         self.raw_data = raw_data
#         self.uuid = str(uuid.uuid4())
# 
#     def _asdict(self):
#         return {
#             'kind': self.kind,
#             'timestamp': self.timestamp,
#             'raw_data': self.raw_data,
#             'uuid': self.uuid,
#         }
#     
#     def __str__(self):
#         return str(self._asdict())
# 
#     def __repr__(self):
#         return '<%s %r>' % (type(self).__name__, str(self))
# 
# Path: hurricane/handlers/base.py
# class PurePublishHandler(BaseHandler):
#     """Works like a handler but does not subscribe to anything."""
# 
#     def auto_subscribe(self, app_manager):
#         pass


# Path: hurricane/handlers/twitter.py
from datetime import datetime
from twitstream import twitstream
from hurricane.base import Message
from hurricane.handlers.base import PurePublishHandler





class TwitterHandler(PurePublishHandler):

    def process_tweet(self, msg):
        msg = Message('tweet', datetime.now(), msg)
        self.publish(msg)


    def run(self):
        twitstream.track(self.settings.TWITTER_USERNAME,
            self.settings.TWITTER_PASSWORD, self.process_tweet,

            track=','.join(self.settings.TWITTER_KEYWORDS)).run()