def main(): args = parse_arguments() is_test = True if not args.official else False santas = config.santas for s in santas: validator.validate_email(s.email) # Clear contents of the file open(config.record_file, 'w').close() while True: random.shuffle(santas) if is_compatible(santas): break set_recipients(santas) for k in santas: send_letter(k, is_test) print('\nFinished!\n') print('Mail record saved to: {}'.format(config.record_file))
def main(): parser = argparse.ArgumentParser(description="Labwork") parser.add_argument("--sort", "-s", action="store", nargs=1, type=str, help=sortHelp) parser.add_argument("--genunsort", "-gus", action="store", nargs=4, type=str, help=gustHelp) parser.add_argument("--fib", "-f", action="store", nargs=1, type=int, help=fibHelp) parser.add_argument("--storage", "-st", action="store_true", help=storageHelp) parser.add_argument("--text", "-t", action="store", nargs=1, type=str, help=textHelp) parser.add_argument("--ngram", "-ng", action="store", nargs=2, type=int, help=ngramHelp) parser.add_argument("--valid", "-v", action="store", nargs=2, type=str, help=validHelp) args = parser.parse_args() if args.sort: sort.sort_all(sort.read_unsorted_file(args.sort[0].strip())) elif args.genunsort: sort.gen_unsorted_file(args.genunsort[0].strip(), int(args.genunsort[1].strip()), int(args.genunsort[2].strip()), int(args.genunsort[3].strip())) elif args.storage: storage.element_storage() elif args.fib: fib.print_fib(args.fib[0]) elif args.text: count = 10 n = 4 if args.ngram: count = args.ngram[0] n = args.ngram[1] text.analyze_(args.text[0].strip(), count, n) elif args.valid: if args.valid[0] == "url": validator.get_url_parts(args.valid[1]) elif args.valid[0] == "email": validator.validate_email(args.valid[1]) elif args.valid[0] == "real": validator.validate_real_num(args.valid[1]) else: print("Please, enter --help")
def post(self): try: user = User.query.filter_by(email=request.data['email']).first() if not user: post_data = request.data # register the user email = post_data['email'].strip() username = post_data['username'].strip() password = post_data['password'].strip() if username and password and email: if validator.validate_name(username) != "Valid Name": return jsonify( {'message': 'please provide a valid username'}), 400 if validator.validate_password( password) != "Valid password": return jsonify({ 'message': 'please provide a strong valid password above six characters' }), 400 if validator.validate_email(email) != "Valid email": return jsonify( {'message': 'please provide a valid email'}), 400 user = User(username=username, password=password, email=email) user.save() response = { 'message': 'You registered successfully. Please log in.' } # return a response notifying the user that they registered well return make_response(jsonify(response)), 201 else: return jsonify({'message': 'all fields required'}), 400 else: # there is an existing user. we dont want to register twice # return a message to the user telling them that they already exist response = { 'message': 'User already exists. Please choose another username' } return make_response(jsonify(response)), 400 except Exception as e: # An error occured, therefore return a string message containg the error response = {'message': "Provide all the fields."} return make_response(jsonify(response)), 401
def test_valid_email(self): """ this test is for valid email""" result = validate_email('*****@*****.**') self.assertEqual(result, "Valid email")
#import datetime from datetime import date import time import camelcase from validator import validate_email ''' #today = datetime.date.today() today = date.today() timestamp = time.time() # print(today) print(timestamp, today) camel = camelcase.CamelCase() text = 'Hello there world' print(camel.hump(text)) ''' print(validate_email("steve@__gmail.com11111"))
""" appdirs==1.4.4 apturl==0.5.2 ... six==1.11.0 system-service==0.3 systemd-python==234 toml==0.10.1 typed-ast==1.4.1 ubuntu-drivers-common==0.0.0 ufw==0.36 unattended-upgrades==0.1 urllib3==1.22 wadllib==1.3.2 xkit==0.0.0 zope.interface==4.3.2 """ print(today, timestamp) # import custom module from validator import validate_email email = "*****@*****.**" wrong_email = "vinicius@com" if validate_email(wrong_email): print("Valid Email") else: print("Invalid email")
# A module is basically a file containing a set of functions to include in your application. There are core python modules, modules you can install using the pip package manager (including Django) as well as custom modules import datetime from datetime import date import validator import camelcase my_date = date.today() print(my_date) myEmail = 'rehmanaziz20yahoo.com' if validator.validate_email(myEmail): print('Valid Email') else: print('invalid Email') print(camelcase.CamelCase().hump('my name is rehman aziz'))
# Core modules import datetime from datetime import date from time import time # Pip module import camelcase camel = camelcase.CamelCase() text = 'hello there world' print(camel.hump(text)) # Custom module import validator email = 'test#test.com' if validator.validate_email(email): print('Email is valid') else: print('Not an email') # today = datetime.date.today() today = date.today() timestamp = time() print(today) print(timestamp)
def test_valid_with_plus(self): email = '*****@*****.**' validator.validate_email(email)
# A module is basically a file containing a set of functions to include in your application. There are core python modules, modules you can install using the pip package manager (including Django) as well as custom modules # from camelcase import CamelCase import datetime from datetime import date import time from validator import validate_email timestamp = time.time() today = date.today() print(today, timestamp) # c = CamelCase() # print(c.hump('hello mr world')) email = 'test&tes.com' if (validate_email(email)): print('valid') else: print('invalid')
# A module is basically a file containing a set of functions to include in your application # There are core python modules, modules you can install using the pip package manager (including Django) # as well as custom modules # Core modules import datetime from datetime import date import time from time import time today = datetime.date.today() today = date.today() timestamp = time() print(today, timestamp) # Pip module import camelcase from camelcase import CamelCase c = CamelCase() print(c.hump('hello there world')) # Import custom module import validator from validator import validate_email print(validate_email('*****@*****.**'))
def test_valid_complex(self): email = '*****@*****.**' validator.validate_email(email)
# core python module # import datetime # from datetime import date # # import time # from time import time # today = date.today() # print(today) # timestamp = time() # print(timestamp) # import custom module from validator import validate_email email = 'myemail@emailio' print(validate_email(email))
def test_valid_basic(self): email = '*****@*****.**' validator.validate_email(email)
def test_invalid_tld(self): email = 'invalid-email@bad{}.com' with self.assertRaises(validator.ValidateError): validator.validate_email(email)
def test_invalid_bad_chars(self): email = 'invalid email [email protected]' with self.assertRaises(validator.ValidateError): validator.validate_email(email)
def test_valid_tree_sufix(self): email = '*****@*****.**' validator.validate_email(email)
def test_valid_domain(self): email = '*****@*****.**' validator.validate_email(email)
def email(self, value): self.__email = validator.validate_email(value)
from time import time # Pip module from camelcase import CamelCase # import custom module from validator import validate_email # today = datetime.date.today() today = date.today() timestamp = time() print(today) print(timestamp) print('---------- Pip Modules ----------') c = CamelCase() print(c.hump('hello there world')) print(validate_email('*****@*****.**')) if validate_email('*****@*****.**'): print('email is valid') else: print('email is invalid')
# Import derived libary #import datetime #from datetime import date now = date.today() print(now) #timestamp = time.time() #print(timestamp) # import method from module #from time import time timestamp1 = time() print(timestamp1) # install module usint pip3 in termenal #pip3 install camelcase # to see all installed modules #pip3 freeze c = CamelCase() print(c.hump('hello there world')) email = '*****@*****.**' email1 = 'test#test.com' if validate_email(email1): print('email is valid') else: print('email is bad')
# Strings in python are surrounded by either single or double quotation marks. Let's look at string formatting and some string methods # String Formatting # String Methods import sys from datetime import date import validator print(date.today()) s = 'Hello World' print(s.count('World') * 5) print(sys.version) print(validator.validate_email('*****@*****.**'))
# A module is basically a file containing a set of functions to include in your application. There are core python modules, modules you can install using the pip package manager (including Django) as well as custom modules import datetime from time import time from validator import validate_email if validate_email('rohan.outlook'): print('success') else: print('failure') print(time())
# A module is a basically a file containing a set of funcitons to include in your application. There are core pythn modules, modules you can install using the pip package manager (including Django ) as well as custom modules. # Core modules from datetime import date from time import time #Pip modules from camelcase import CamelCase from validator import validate_email today = date.today(); case = CamelCase() print (case.hump('hello there world')) print (today) print (time()) print (validate_email('*****@*****.**')) print (validate_email('visakh_gmail.com'))
# A module is basically a file containing a set of functions to include in your application. There are core python modules, modules you can install using the pip package manager (including Django), as well as custom modules # import a core python module (i.e. datetime) import datetime today = datetime.date.today() print(today) # import a certain piece of a core python module (i.e. time) from time import time timestamp = time() print(timestamp) # pip module (i.e. camelcase) from camelcase import CamelCase c = CamelCase() print(c.hump("hello world")) # import custom module (i.e. validator.py) import validator from validator import validate_email email = "*****@*****.**" if validate_email(email): print("email is valid") else: print("email is bad")
# A module is basically a file containing a set of functions to include in your application. There are core python modules, modules you can install using the pip package manager (including Django) as well as custom modules # core modules # import datetime # importing the whole module from datetime import date # importing ony needed funcitons from the module. from time import time # pip modules from camelcase import CamelCase # custom modules from validator import validate_email # print(date.today()) # for i in range(0,1000): # print(f'Time is {time()}') c = CamelCase() print(c.hump('Hello sweetheart')) print(validate_email('*****@*****.**'))