"""
author: Zack Schwartz (zacharyhschwartz@gmail.com)
date creaetd: 11/13/2011
"""

from pymongo import *
import datetime

def connect_to_db():
    try:
        c = Connection()
        db = c.bauer_engine
        return db
    except:
        print 'database connection failed'
        raise 

def tweepy_to_dict(status):
    result = {}
    result['id'] = status.id
    result['created_at'] = datetime.datetime.now()
    result['author'] = status.author.screen_name
    result['text'] = status.text
    result['geo'] = status.geo
    result['retweet_count'] = status.retweet_count
    result['urls'] = status.entities['urls']
    return result

def dump(obj):
    for attr in dir(obj):
        print 'obj.%s = %s' % (attr, getattr(obj, attr))

def print_status(status):
    print "%s: %s" % (status['author'], status['text'])
       
