How to use the pyisemail.diagnosis.valid_diagnosis.ValidDiagnosis function in pyIsEmail

To help you get started, we’ve selected a few pyIsEmail examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assembl / assembl / assembl / alembic / versions / 250035d23e83_recalc_message_id.py View on Github external
SET source_post_id = substring(source_post_id, 2, length(source_post_id)-2)
            WHERE source_post_id LIKE '<%>'""")
        op.execute("""UPDATE email
            SET in_reply_to = substring(in_reply_to, 2, length(in_reply_to)-2)
            WHERE in_reply_to LIKE '<%>'""")
        op.execute("""UPDATE post
            SET message_id = concat(
                substring(message_id, 10, length(message_id)), '_assembl@%s')
            WHERE message_id LIKE 'urn:uuid:%%'""" % (
                config.get('public_hostname'),))

    # Do stuff with the app's models here.
    from assembl import models as m
    db = m.get_session_maker()()
    accepted = (
        pyisemail.diagnosis.valid_diagnosis.ValidDiagnosis(),
        pyisemail.diagnosis.rfc5322_diagnosis.RFC5322Diagnosis('LOCAL_TOOLONG'))

    with transaction.manager:
        for id, email in db.execute("SELECT id, message_id FROM post"):
            if pyisemail.is_email(email, diagnose=True) in accepted:
                continue
            c = m.Content.get(id)
            if isinstance(c, m.ImportedPost):
                c.message_id = c.source.generate_message_id(c.source_post_id)
            elif isinstance(c, m.AssemblPost):
                c.message_id = c.generate_message_id()
            else:
                print "ERROR: Pure post", id