Beispiel #1
0
def download_email(message_id):
    raw_message = get_gmail_message(message_id)
    parsed_message = parse_message(raw_message)
    try:
        Email.get(Email.message_id == parsed_message['message_id'])
        print "Found email with id %s. Did not create" % parsed_message[
            'message_id']
    except DoesNotExist:
        e = Email.create(**parsed_message)
        sender_email_address = e.get_sender_email()
        # if '@' not in sender_email_address: import pdb; pdb.set_trace()
        s = SenderMetadata.get_or_create(
            email_address=sender_email_address,
            email_url=sender_email_address.split('@')[1])
        e.sender = s
        e.save()
Beispiel #2
0
# Find the batches
boolean_matrix = [map(lambda x: 1 if x > .9 else 0, vector) for vector in cosine_vectors]
g = nx.Graph(sparse.csr_matrix(boolean_matrix))

# Populate Forms
for batch in nx.connected_components(g):
  f = Form(blank="")
  f.save()
  # form.save(force_insert=True)
  for item_id in batch:

    if len(batch) <= 1: 
      continue

    item_id += 1

    # POPULATE FORM FROM BATCH
    try:
      email = Email.get(Email.id==item_id)
      email.form = f
      email.save()
      # import pdb; pdb.set_trace()
      # comment.save(force_insert=True)
    except:
      print t.red("Could not get comment with id #%d" % item_id)

    # POPULATE CATEGORY FROM LABELS
    import pdb; pdb.set_trace()