#!/usr/bin/env python
import re
import sys


def chunk(l,n):
    return (l[i:i+n] for i in xrange(0, len(l), n))


def is_disposable_email(email):
    emails = [line.strip() for line in open('domain-list.txt')]
    
    """
    Chunk it!
    Regex parser doesn't deal with hundreds of groups
    """
    for email_group in chunk(emails, 20):
        regex = "(.*" + ")|(.*".join(email_group) + ")"
        if re.match(regex, email):
            return True
    
    return False
    

if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.stderr.write("You must supply at least 1 email\n")
    
    for email in sys.argv[1:]:
        if is_disposable_email(email):
            sys.stderr.write("{email} appears to be a disposable address\n".format(email=email))
@@ -1,304 +1,413 @@
-#!/usr/bin/env python%0Aimport re%0Aimport sys%0A%0A%0Adef chunk(l,n):%0A    return (l%5Bi:i+n%5D for i in xrange(0, len(l), n))%0A%0A%0Adef is_disposable_email(email):%0A    emails = %5Bline.strip() for line in open('domain-list.txt')%5D%0A    %0A    %22%22%22%0A    Chunk it!%0A    Regex parser doesn't deal with hundreds of groups
+from django.conf import settings%0Aimport re%0Aimport sys%0A%0A%0Aclass DisposableEmailChecker():%0A    %22%22%22%0A    Check if an email is from a disposable%0A    email service%0A    %22%22%22%0A    %0A    def __init__(self):%0A        self.emails = %5Bline.strip() for line in open(settings.DISPOSABLE_EMAIL_DOMAINS)%5D%0A    %0A    def chunk(l,n):%0A        return (l%5Bi:i+n%5D for i in xrange(0, len(l), n))%0A    %0A    def is_disposable(self, email):
 %0A    
-%22%22%22%0A
     
@@ -425,22 +425,32 @@
 roup in 
+self.
 chunk(
+self.
 emails, 
@@ -454,16 +454,20 @@
 s, 20):%0A
+    
         
@@ -522,16 +522,20 @@
         
+  
+  
 if re.ma
@@ -569,25 +569,8 @@
     
-return True%0A    %0A
     
@@ -580,303 +580,34 @@
 urn 
-Fals
+Tru
 e%0A    %0A
-%0Aif __name__ == %22__main__%22:%0A    if len(sys.argv) %3C 2:%0A        sys.stderr.write(%22You must supply at least 1 email%5Cn%22)%0A    %0A    for email in sys.argv%5B1:%5D:%0A        if is_disposable_email(email):%0A            sys.stderr.write(%22%7Bemail%7D appears to be a disposable address%5Cn%22.format(email=email))
+        return False

Convert for use with Django