Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Minor tweaks to make code more modular
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrhaas committed Nov 25, 2015
1 parent d088ea3 commit 169b0a7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions traptor/traptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def create_kafka_producer(kafka_hosts=KAFKA_HOSTS, kafka_topic=KAFKA_TOPIC):


def create_birdy_stream(rules,
apikeys=APIKEYS,
traptor_type=TRAPTOR_TYPE,
traptor_id=TRAPTOR_ID,
):
Expand Down Expand Up @@ -132,15 +133,14 @@ def create_birdy_stream(rules,
logger.critical('That traptor type has not been implemented yet')
sys.exit(3)

def tweet_time_to_iso(tweet_time):
return parser.parse(tweet_time).isoformat()

def clean_tweet_data(tweet_dict):
""" Do any pre-processing to raw tweet data before passing on
to Kafka
"""

def tweet_time_to_iso(tweet_time):
return parser.parse(tweet_time).isoformat()

if tweet_dict.get('created_at'):
tweet_dict['created_at'] = tweet_time_to_iso(tweet_dict['created_at'])
return tweet_dict
Expand Down Expand Up @@ -168,7 +168,7 @@ def run(test):

# Iterate through the twitter results
for _data in birdyclient.stream():
# logger.debug('Raw Data: {0}'.format(json.dumps(_data)))
logger.debug('Raw Data: {0}'.format(json.dumps(_data)))

# Do tweet data pre-processing
data = clean_tweet_data(_data)
Expand Down

0 comments on commit 169b0a7

Please sign in to comment.