Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
yasyf committed Sep 13, 2014
1 parent 2121142 commit c8849fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
if __name__ == '__main__':
while True:
newest_notifications = get_notifications(MAX_NOTIFICATION_BATCH_SIZE)
print newest_notifications
if len(newest_notifications) > 0:
process_notifications(newest_notifications, process_notification)
time.sleep(20)
Expand Down
4 changes: 2 additions & 2 deletions mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

@contextmanager
def get_raw_email(object_id):
raw_email = raw_data.find_one({'_id':ObjectId(objectId)})
raw_email = raw_data.find_one({'_id':ObjectId(object_id)})
if processed_data.find_one({'email_id':raw_email['id']}):
raise Exception('dupe')
del raw_email['_id']
try:
yield raw_email
raw_data.remove({'_id':ObjectId(objectId)})
raw_data.remove({'_id':ObjectId(object_id)})
except Exception as e:
raise e

Expand Down
4 changes: 2 additions & 2 deletions pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def process_email(raw_email):
for extractor in extractors:
results.update(extractor.extract(raw_email))
return results

def process_notification(notification):
object_id = notification['object_id']
try:
Expand All @@ -17,4 +17,4 @@ def process_notification(notification):
store_processed_data(processed_email)
return processed_email
except:
pass
raise

0 comments on commit c8849fd

Please sign in to comment.