当前位置: 首页>>代码示例>>Python>>正文


Python validate_email.validate_email函数代码示例

本文整理汇总了Python中validate_email.validate_email函数的典型用法代码示例。如果您正苦于以下问题:Python validate_email函数的具体用法?Python validate_email怎么用?Python validate_email使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了validate_email函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_greek_regular

    def test_greek_regular(self):
        self.assertTrue(validate_email(r'θσερ@εχαμπλε.ψομ'))

        self.assertFalse(validate_email(r'θσερεχαμπλε.ψομ')) # No @
        self.assertFalse(validate_email(r'θσερ@εχαμπλεψομ')) # No .
        self.assertFalse(validate_email(r'θσερ@εχαμπλε.')) # Nothing after the .
        self.assertFalse(validate_email(r'@εχαμπλε.ψομ')) # Nothing before the @
开发者ID:mark0978,项目名称:validate_email,代码行数:7,代码来源:validate_email_tests.py

示例2: main

def main(argv):
    input_folder = ''
    input_email = ''

    try:
        opts, args = getopt.getopt(argv,"hf:e:",["ffolder=","eemail="])
    except getopt.GetoptError:
        print 'test.py -f <folder> -e <email>'
        #print 'test.py -i <inputfile> -o <outputfile>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'globus_share.py -f <folder> -e <email>'
            sys.exit()
        elif opt in ("-f", "--ffolder"):
            input_folder = arg
        elif opt in ("-e", "--eemail"):
            input_email = arg
    
    input_folder = os.path.normpath(input_folder) + os.sep # will add the trailing slash if it's not already there.

    globus_add = "acl-add " + local_user + local_share + os.sep + input_folder  + " --perm r --email " + input_email

    if validate_email(input_email) and os.path.isdir(local_shared_folder + input_folder):
        cmd = "ssh " + globus_user + globus_address + " " + globus_add
        print cmd
        #os.system(cmd)
        print "Download link sent to: ", input_email
    else:
        print "ERROR: "
        if not validate_email(input_email):
            print "email is not valid ..."
        else:
            print local_shared_folder + input_folder, "does not exists on the local server", 
开发者ID:decarlof,项目名称:projects,代码行数:34,代码来源:globus_share.py

示例3: parseParticipant

    def parseParticipant(self,fromstring):
        fromstring=decodeHeader(fromstring)
#            fromstring="".join(i for i in str(fromstring) if i in string.printable)
        fromstring=fromstring.replace("\n","").replace("\t","")
        if ">" in fromstring and "<" not in fromstring:
            fromstring=re.sub(r"(.*[ ^]*)(.*>)",   r"\1<\2", fromstring)
            c("-|-|-|-| corrected fromstring:", fromstring)
        elif "<" in fromstring and ">" not in fromstring:
            fromstring=re.sub(r"(<.*)([ $]*.*)",   r"\1>\2", fromstring)
            c("-|-|-|-| corrected fromstring:", fromstring)
        if fromstring.count(">")==fromstring.count("<")>0:
            name,email=re.findall(r"(.*) {0,1}<(.*)>",fromstring)[0]
        elif "(" in fromstring:
            email,name=re.findall(r"(.*) {0,1}\((.*)\)",fromstring)[0]
        elif " " in fromstring:
            raise ValueError("new author field pattern")
        else:
            email=fromstring
            name=""
        email=email.replace("..",".")
        try:
            assert validate_email(email)
        except:
            if "cardecovil.co.kr" in email:
                email="[email protected]"
                name=""
            elif re.findall(r"(.*):(.*)",email):
                name,email=re.findall(r"(.*):(.*)",email)[0]
            else:
                raise ValueError("bad email")
        assert validate_email(email)
        return email,name.strip().replace("'","").replace('"','')
开发者ID:land-pack,项目名称:gmane,代码行数:32,代码来源:mbox2rdf.py

示例4: main

def main(argv):
    input_folder = ''
    input_email = ''

    try:
        opts, args = getopt.getopt(argv,"hf:e:",["ffolder=","eemail="])
    except getopt.GetoptError:
        print 'test.py -f <folder> -e <email>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'globus_share.py -f <folder> -e <email>'
            sys.exit()
        elif opt in ("-f", "--ffolder"):
            input_folder = arg
        elif opt in ("-e", "--eemail"):
            input_email = arg
    
    input_folder = os.path.normpath(input_folder) + os.sep # will add the trailing slash if it's not already there.
    if validate_email(input_email) and os.path.isdir(local_folder + input_folder):

        globus_add = "acl-add " + local_user + local_share1 + os.sep + input_folder  + " --perm r --email " + input_email
        cmd =  globus_ssh + " " + globus_add
        print cmd
        print "ssh [email protected] acl-add decarlo#data/test/ --perm r --email [email protected]"
        #os.system(cmd)
        print "Download link sent to: ", input_email
    else:
        print "ERROR: "
        print "EXAMPLE: python globus_local_share.py -f test -e [email protected]"
        if not validate_email(input_email):
            print "email is not valid ..."
        else:
            print local_folder + input_folder, "does not exists under the Globus Personal Share folder"
        gb.settings()
开发者ID:aglowacki,项目名称:DMagic,代码行数:35,代码来源:globus_local_share.py

示例5: test_german_regular

    def test_german_regular(self):
        self.assertTrue(validate_email(r'Dö[email protected]örensen.example.com'))

        self.assertFalse(validate_email(r'DörteSörensen.example.com')) # No @
        self.assertFalse(validate_email(r'Dö[email protected]örensenexamplecom')) # No .
        self.assertFalse(validate_email(r'Dö[email protected]örensen.')) # Nothing after the .
        self.assertFalse(validate_email(r'@Sörensen.example.com')) # Nothing before the @
开发者ID:mark0978,项目名称:validate_email,代码行数:7,代码来源:validate_email_tests.py

示例6: test_hindi_regular

    def test_hindi_regular(self):
        self.assertTrue(validate_email(r'उपयोगकर्ता@उदाहरण.कॉम')) # Hindi

        self.assertFalse(validate_email(r'उपयोगकर्ताउदाहरण.कॉम')) # No @
        self.assertFalse(validate_email(r'उपयोगकर्ता@उदाहरणकॉम')) # No .
        self.assertFalse(validate_email(r'उपयोगकर्ता@उदाहरण.')) # Nothing after the .
        self.assertFalse(validate_email(r'@उदाहरण.कॉम')) # Nothing before the @
开发者ID:mark0978,项目名称:validate_email,代码行数:7,代码来源:validate_email_tests.py

示例7: test_ukranian_regular

    def test_ukranian_regular(self):
        self.assertTrue(validate_email(r'юзер@екзампл.ком')) # Chinese

        self.assertFalse(validate_email(r'')) # No @
        self.assertFalse(validate_email(r'')) # No .
        self.assertFalse(validate_email(r'')) # Nothing after the .
        self.assertFalse(validate_email(r'')) # Nothing before the @
开发者ID:mark0978,项目名称:validate_email,代码行数:7,代码来源:validate_email_tests.py

示例8: minion

def minion(id=0, field='email'):

    # zmq context and
    context = zmq.Context()

    # receive work
    consumer_receiver = context.socket(zmq.PULL)
    consumer_receiver.connect("tcp://127.0.0.1:5557")

    # send work
    consumer_sender = context.socket(zmq.PUSH)
    consumer_sender.connect("tcp://127.0.0.1:5558")

    # logger
    logger = open("log/{0}".format(id), 'w')

    while True:
        row = consumer_receiver.recv_json()
        email = row[field]
        if validate_email(email):
            if validate_email(email, check_mx=True):
                if validate_email(email, verify=True):
                    res = {'row': row, 'is_valid': True}
                else:
                    res = {'row': row, 'is_valid': False, 'err': 'KO-USER'}
            else:
                res = {'row': row, 'is_valid': False, 'err': 'KO-MX'}
        else:
            res = {'row': row, 'is_valid': False, 'err': 'KO-RFC'}

        consumer_sender.send_json(res)
        logger.write("{0} - {1}\n".format(datetime.now(), res))
        logger.flush()
开发者ID:openpolis,项目名称:mailing,代码行数:33,代码来源:validate.py

示例9: test_chinese_regular

    def test_chinese_regular(self):
        self.assertTrue(validate_email(r'用户@例子.广告')) # Chinese

        self.assertFalse(validate_email(r'用户例子.广告')) # No @
        self.assertFalse(validate_email(r'用户@例子广告')) # No .
        self.assertFalse(validate_email(r'用户@例子.')) # Nothing after the .
        self.assertFalse(validate_email(r'@例子.广告')) # Nothing before the @
开发者ID:mark0978,项目名称:validate_email,代码行数:7,代码来源:validate_email_tests.py

示例10: parseAddresses

def parseAddresses(string_):
    string_ = decodeHeader(string_)
    string_ = string_.replace("\n", "").replace("\t", "")
    unparsed = ""
    # if string_.count("<") == string_.count(">") == 1:
    #     addresses_all=[re.findall(r"(.*) {0,1}<(.*?)>",string_)[0][::-1]]
    # elif string_.count("<") == string_.count(">") == 0 and string_.count("@") == 1:
    #     address=[part for part in string_.split() if "@" in part][0]
    #     name=" ".join([part for part in string_.split() if "@" not in part])
    #     addresses_all=[(address,name)]
    # else:
    candidates = re.split(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''', string_)[1::2]  # ?? pra que isso?
    candidates = [i.strip() for i in candidates]
    addresses_all = []
    for candidate in candidates:
        if candidate.count("<") == candidate.count(">") > 0:
            # assume name <address> format
            name, address = re.findall(r"(.*) {0,1}<(.*?)>", candidate)[0]
        elif "@" in candidate:
            address = [part for part in candidate.split() if "@" in part][0]
            name = " ".join([part for part in candidate.split() if "@" not in part])
        else:
            unparsed += candidate
            address = ""
        if address:
            try:
                validate_email(address)
                addresses_all += [(address, name.strip().replace('"', '').replace("'", ""))]
            except:
                unparsed += candidate
    return addresses_all, unparsed
开发者ID:ttm,项目名称:gmane,代码行数:31,代码来源:mbox2rdf.py

示例11: getErrors

  def getErrors(self):
    """
    Searches the data for errors. If no errors are detected, 
    None is returned. If one or more errors are detected, a list
    of errors are returned
    """
    def addError(errors, name, err):
      tmp = errors.get(name, list())
      tmp.append(err)
      errors[name] = tmp

    errors = dict()

    if not self.sender:
      addError(errors, 'sender', 'Required')

    if not self.receivers:
      addError(errors, 'receivers', 'Required')

    if not errors.get('sender', []) and not validate_email(self.sender):
      addError(errors, 'sender', 'Invalid email')

    for receiver in self.receivers:
      if not validate_email(receiver):
        addError(errors, 'receivers', {'email': receiver, 'reason': 'Invalid email'})

    if errors:
      return errors
    else:
      return None
开发者ID:bufas,项目名称:awesome-email,代码行数:30,代码来源:emaildatahandler.py

示例12: share

def share(directory, email, mode):
    """
    Send a token e-mail to share a directory under the local or remote Globus Endpoint

    Parameters
    ----------
    directory : str
        Full directory path under the Globus Shared Endpoint

    email : email
        User e-mail address

    mode : str
        local, remote. Shared folder is on local/remote Endpoint 

    Returns
    -------
    cmd : str 
        Globus Command Line string. If executed with os.system() 
        will send notification e-mail to users         
    """

    home = expanduser("~")
    globus = os.path.join(home, 'globus.ini')
    cf = ConfigParser.ConfigParser()
    cf.read(globus)
    globus_address = cf.get('settings', 'cli_address')
    globus_user = cf.get('settings', 'cli_user')
    globus_ssh = "ssh " + globus_user + globus_address

    if mode == 'local':
        user = cf.get('globus connect personal', 'user')
        share = cf.get('globus connect personal', 'share')
        folder = cf.get('globus connect personal', 'folder')

        if os.path.isdir(folder + directory) and validate_email(email):
            globus_add = "acl-add " + user + share + os.sep + \
                directory + " --perm r --email " + email
            cmd = globus_ssh + " " + globus_add
            return cmd
        else:
            if not validate_email(email):
                return -1
            else:
                return -2

    elif mode == 'remote':
        user = cf.get('globus remote server', 'user')
        share = cf.get('globus remote server', 'share')
        folder = cf.get('globus remote server', 'folder')

        if validate_email(email):
            globus_add = "acl-add " + user + share + os.sep + \
                directory + " --perm r --email " + email
            cmd = globus_ssh + " " + globus_add
            return cmd
        else:
            return -1
开发者ID:dgursoy,项目名称:dmagic,代码行数:58,代码来源:globus.py

示例13: get_defaults

def get_defaults():
    """Get default parameters and setting.
    These setting are pre-defined for common analysis. For an alternate setup, generate \"RNAseq_pipeline_defaults.txt\" under home folder and/or run path.
    Pre-defined parameters are superseded by \"RNAseq_pipeline_defaults.txt\" file under home path and that, in turn, is superseded by the one under run path.
    """

    # get package defaults
    with open(os.path.join(iLoop_RNAseq_pipeline.__path__[0], 'defaults', 'RNAseq_pipeline_defaults.txt')) as rpd:
        defaults = {}
        for line in rpd.readlines():
            if line.strip():
                defaults[line.split(',')[0].strip()] = line.split(',')[1].strip()

    try:
        with open(os.path.join(os.path.expanduser("~"), 'RNAseq_pipeline_defaults.txt')) as rpd:
            for line in rpd.readlines():
                if line.strip():
                    defaults[line.split(',')[0].strip()] = line.split(',')[1].strip()
    except FileNotFoundError:
        logger.warning('"RNAseq_pipeline_defaults.txt" does not exist under home path. An email address and project ID should be should be define in that file.')

    # replace with user defaults
    try:
        with open('RNAseq_pipeline_defaults.txt') as rpd:
            for line in rpd.readlines():
                if line.strip():
                    defaults[line.split(',')[0].strip()] = line.split(',')[1].strip()
    except FileNotFoundError:
        logger.info(
            '"RNAseq_pipeline_defaults.txt" does not exist under this folder. Defaults from the package and home path will be used.')

    if 'email' not in defaults:
        if not validate_email(defaults['email']):
            while True:
                email = input('Enter a valid email address for job status: \n')
                if validate_email(email):
                    defaults['email'] = email
                    print('Writing email to "RNAseq_pipeline_defaults.txt" under home path.')
                    f = open(os.path.join(os.path.expanduser("~"), 'RNAseq_pipeline_defaults.txt'), 'w+')
                    f.write('\nemail,{}'.format(email))
                    f.close()
                    break
                else:
                    print('{} is not valid, try again.'.format(email))

    if ('project' not in defaults) or (defaults['project'] == 'projectid'):
        project = input('Enter Computerome project ID for billing: \n')
        # TODO It is possible to validate this by checking folder name under "/home/projects".
        defaults['project'] = project
        print('Writing project ID to "RNAseq_pipeline_defaults.txt" under home path.')
        f = open(os.path.join(os.path.expanduser("~"), 'RNAseq_pipeline_defaults.txt'), 'w+')
        f.write('\nproject,{}'.format(project))
        f.close()

    return defaults
开发者ID:meono,项目名称:iLoop_RNAseq_pipeline,代码行数:55,代码来源:initiate_project.py

示例14: sendRequestEmailWithSES

def sendRequestEmailWithSES(requestername, requesteremail, tool, particulars,
                            senderemail=app.config['REQUEST_EMAIL_SENDEREMAILADDRESS'],
                            recepientemail=app.config['REQUEST_EMAIL_RECEPIENTEMAILADDRESS']):
    """
    Formats and sends the particulars of a request for access as an email
    to the Zen Desk intake email address using Amazon's Simple Email Service. By default
    the from address will come from the configuration file.

    See https://boto.readthedocs.org/en/latest/ses_tut.html#verifying-a-sender-email-address for
    sender email verification SES process to allow AWS message to send messages from the specified
    address

    """

    # P Make sure the email addresses look good
    if not validate_email(requesteremail):
        raise ValueError("Requester email '%s' is not valid" % requesteremail)
    if not validate_email(senderemail):
        raise ValueError("Sender email '%s' is not valid" % senderemail)
    if not validate_email(recepientemail):
        raise ValueError("Recepient email '%s' is not valid" % recepientemail)

    # P Get a connection to AWS
    #conn = boto.ses.connect_to_region(app.config['REQUEST_AWS_SES_REGION'],
    #                                  aws_access_key_id=app.config['REQUEST_AWS_SES_ACCESS_KEY_ID'],
    #                                  aws_secret_access_key=app.config['REQUEST_AWS_SES_SECRET_ACCESS_KEY'])
    conn = boto.ses.connect_to_region(app.config['REQUEST_AWS_SES_REGION'])

    # P Make sure the sender address has already been validated for sending by SES

    blessedSESaddresses = conn.list_verified_email_addresses()

    if senderemail not in blessedSESaddresses['ListVerifiedEmailAddressesResponse']['ListVerifiedEmailAddressesResult'][
        'VerifiedEmailAddresses']:
        raise ValueError("Sender email '%s' is not SES list of verified email addresses." % senderemail)

    # P OK, should be validated. Create the message
    msg = MIMEMultipart()

    msg['Subject'] = "Access Gossip request for access to %s by %s" % (tool, requestername)
    msg['From'] = senderemail
    msg['To'] = recepientemail

    body = ""
    for particular in particulars:
        body += "\n%s:%s" % (particular[0], particular[1])

    msg.attach(MIMEText(body))

    # P Send the message

    result = conn.send_raw_email(msg.as_string())

    return result if 'ErrorResponse' in result else ''
开发者ID:rdpickard,项目名称:accessgossip,代码行数:54,代码来源:views.py

示例15: regUsers

    def regUsers():
        global username, mejl

        username = request.forms.username
        mejl=request.forms.mejl
        password1=request.forms.password1
        password2=request.forms.password2

        if password1==password2:
            if is_valis= validate_email(mejl, check_mx=True):
            #här finns en mysql
                query('INSERT user(username, mejl, password1)' ' VALUES(%s,%s,%s)', (username, mejl, password1))
                return template("loggain", title=username, username=username, mejl=mejl, password1=password1,password2=password2)
开发者ID:Simonjpersson,项目名称:Projekt-Sagoland,代码行数:13,代码来源:functionsClass.py


注:本文中的validate_email.validate_email函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。