Пример #1
0
def levelTwo():
    rw = RandomWord(max_word_size=10,
                    constant_word_size=True,
                    special_chars=r"@#$%.*",
                    include_special_chars=True)
    return rw.generate()
    print(rw.generate())
Пример #2
0
def home():


	rw = RandomWord(max_word_size=10,
		                constant_word_size=True,
		                include_digits= True,
		                special_chars=r"$%.*",
		                include_special_chars=True)
	print(rw.generate())

	return render_template("random_app.html", data = rw.generate())
Пример #3
0
def main_gen():
    ''' Creates main dict '''
    import pprint
    import random
    from RandomWordGenerator import RandomWord

    rw = RandomWord(max_word_size=5)
    for_model = rw.generate()
    res = str(int(random.random()))
    model = "shop_{}.book".format(for_model)
    result = {}
    for_result_dict = next(subgen())
    result.update(for_result_dict)
    val = [model, random.randrange(1, 50)]
    keys = ["model", "pk"]
    final = ','.join(('{},{}'.format(y, x) for y, x in (list(
        i for i in (zip(keys, val)))))).split(',')
    fld = {"field": result}

    i = iter(final)
    book = dict(zip(i, i))
    book.update(fld)

    while True:
        yield book
Пример #4
0
    async def ran_word(self, ctx):
        rw = RandomWord(max_word_size=15,
                        constant_word_size=True,
                        special_chars=r"@#$%.*",
                        include_special_chars=True)

        await ctx.send(rw.generate())
Пример #5
0
def main_gen():
    ''' Creates main dict '''
    import pprint
    import random
    from RandomWordGenerator import RandomWord

    rw = RandomWord(max_word_size=5)
    for_model = rw.generate()
    res = str(int(random.random()))
    model = "shop_{}.book".format(for_model)
    result = {}
    val = [model, random.randrange(1, 50)]
    keys = ["model", "pk"]
    final = ','.join(('{},{}'.format(y, x) for y, x in (list(i for i in (zip(keys, val)))))).split(',')
    fld = {"field": ' '}
    for key, val in fld.items():
        collect = delegate(result, key)
        next(collect)
        for v in val:
            collect.send(v)
        collect.send(None)


    i = iter(final)
    book = dict(zip(i, i))
    book.update(result)

    while True:
        yield book
Пример #6
0
def generatePassword(numberTests, wordSize):

    baseDeDados = []

    rw = RandomWord(max_word_size=wordSize, constant_word_size=False)

    count = 0

    while True:
        if count == numberTests:
            return baseDeDados
            break
        else:
            palavra = rw.generate()
            palavra = palavra.upper()
            count += 1
            baseDeDados.append(palavra)


# print(generatePassword(200, 5))
Пример #7
0
def subgen():
    ''' Creates a dict which will be nested to main dict as a value'''

    from RandomWordGenerator import RandomWord
    import random
    import datetime

    year = str(datetime.datetime.now() -
               datetime.timedelta(days=random.randrange(400, 1000)))[0:4]
    isbn_13 = '{}-{}-{}-{}-{}'.format(random.randrange(111, 999),
                                      random.randrange(1, 10),
                                      random.randrange(0, 99999),
                                      random.randrange(111, 999),
                                      random.randrange(1, 10))
    rw = RandomWord(max_word_size=5)
    book_name = rw.generate()
    res = str(int(random.random()))

    author = (((lambda x, y: x + y)(
        ("author_{}, ".format(random.randrange(101, 200))),
        ("author_{}".format(random.randrange(1, 100)))))).split(',')
    rating = random.randrange(1, 100)
    price = round(random.uniform(1111111.0, 999999.9), 2)
    discount = random.randrange(1, 50)
    val_for_nested_dict = [
        '{}_book'.format(book_name), year, (str(random.randrange(50, 1500))),
        isbn_13, rating, price, discount
    ]
    lst_for_nested_dict = [
        "title", "year", "pages", "isbn13", "rating", "price", "discount",
        "author"
    ]
    nested_dict = ','.join(('{},{}'.format(y, x) for y, x in (list(
        i
        for i in (zip(lst_for_nested_dict, val_for_nested_dict)))))).split(',')
    final = {"author": author}
    i = iter(nested_dict)
    ndict = dict(zip(i, i))
    ndict.update(final)
    while True:
        yield ndict
Пример #8
0
def routerBulk(request):
    print("dfgdgf")
    rw = RandomWord(max_word_size=5)
    res = []
    val = {}
    for i in range(0, 3):

        tmp = str(rw.generate())
        val["sapid"] = tmp + str(i)
        val["hostname"] = tmp
        val["loopbackid"] = ".".join(
            map(str, (random.randint(0, 255) for _ in range(4))))
        val["mac_add"] = str(RandMac())
        ser = RouterDetailsSerializer(data=val)
        print(ser)
        if ser.is_valid():
            ser.save()
            print("****")
            res.append(val["loopbackid"])

    return Response(res)
Пример #9
0
def generate_random_letter():
    print('''Choose the difficulty level 
    1.Easy
    2.Normal
    3.Hard
    4.Extreme''')
    user_input = int(input('Enter your choice here:- '))

    if user_input == 1:
        word_lenth = 2
    elif user_input == 2:
        word_lenth = 3
    elif user_input == 3:
        word_lenth = 4
    elif user_input == 4:
        word_lenth = 5
    Random_letters = RandomWord(max_word_size=word_lenth)
    letters = Random_letters.generate()

    # The instructions for the user.
    Instructions = f'''\nComputer has choosen {word_lenth} letters. 
Guess these {word_lenth} in 3 chances for each letter.\n'''
    print(Instructions)
    counter = 0  # This variable will count the number of chances of user to guess the letter.

    # This while statement will be keep running until the counter is less than 3.
    while counter < 3:

        # This if statement will run when user_input will be equal to 1.
        if word_lenth == 2:
            user_guess_1 = input('Guess both letters:- ')
            if user_guess_1 == letters:
                print('The Letters are correct.\nWell Played!!')
            elif user_guess_1 != letters:
                print("The letters are wrong.")
                counter = counter + 1

        # This elif statement will run when user_input will be equal to 2.
        elif word_lenth == 3:
            user_guess_2 = input('Guess the 3 random letters:- ')
            if user_guess_2 == letters:
                print('The letters are correct.\nWell Played!!')
            elif user_guess_2 != letters:
                print('The letters are wrong.')
                counter = counter + 1

        # This elif statement will run when user_input will be equal to 3.
        elif word_lenth == 4:
            user_guess_3 = input('Guess the 4 random letters:- ')
            if user_guess_3 == letters:
                print('The letters are correct.\nWell Played!!')
            elif user_guess_3 != letters:
                print('The letters are wrong.')
                counter = counter + 1

        # This elif statement will run when user_input will be equal to 4.
        elif word_lenth == 5:
            user_guess_4 = input('Guess the 5 random letters:- ')
            if user_guess_4 == letters:
                print('The letters are correct.\nWell PLayed!!')
            elif user_guess_4 != letters:
                print('The letters are wrong.')
                counter = counter + 1

    # This else statement will run when the counter will be equal to 3.
    else:
        print("\nYour all 3 chances are over.\nBetter Luck Next Time!!")
        print(f'The correct letters are "{letters}"')
Пример #10
0
from RandomWordGenerator import RandomWord
import time, random

while True:
    rw = RandomWord(max_word_size=100)
    x = rw.generate().upper()
    print(x)
    time.sleep(0.3)
    if 'FD' in x:
        break
Пример #11
0
from RandomWordGenerator import RandomWord
import requests
import json
import random
import pytest


rw = RandomWord()
#Datos API
base='http://*****:*****@pytest.mark.parametrize("userid, name", [(1,"Luke"),(3,"David")])
def test_employee_by_id(supply_url,userid,name):
    response = requests.get(supply_url+'employees/'+str(userid))
    response_data = response.json()
    assert response.status_code == 200
    assert response_data['id'] == userid
    assert response_data['name'] == name

def test_nf_employee_by_id(supply_url, id = 0):
    response = requests.get(supply_url+'employees/'+str(id))
    assert response.status_code == 500
Пример #12
0
def generateW():
    r = RandomWord()
    return r.generate()
Пример #13
0
# -*- coding: utf-8 -*-
"""
Created on Sun Feb  7 12:36:05 2021

@author: bhanu
"""

from RandomWordGenerator import RandomWord
import pandas as pd

words = []
for i in range(0, 50000):
    word = RandomWord(max_word_size=9, constant_word_size=False)
    words.append(word.generate())

df = pd.DataFrame(words)
df.to_csv("spamWordCreation.csv")
import csv
import json
from faker import Faker
import random
from RandomWordGenerator import RandomWord

nums = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
phones = []
for i in range(1000000):
    phones.append('+7' + ''.join(random.sample(nums, 10)))

rw1 = RandomWord(constant_word_size=False)
rw2 = RandomWord(max_word_size=5, constant_word_size=False)   
mails = []
for i in range(1000000):
    mails.append(rw1.generate() + '@' + rw2.generate() + '.com')

fake = Faker()
destinations_date = [['name', 'contact', 'offered_products']]
for i in range(1, 1000001):
    contact = {
        'phone': phones[i - 1],
        'email': mails[i - 1],
        'address':fake.address()
    }
    offered_products = [random.randint(0, 1000000), random.randint(0, 1000000), random.randint(0, 1000000), random.randint(0, 1000000), random.randint(0, 1000000)]
    destinations_date.append([fake.name(), json.dumps(contact), offered_products])

myFile = open('destinations_date.csv', 'w')
with myFile:
    writer = csv.writer(myFile)
Пример #15
0
def levelOne():
    rw = RandomWord(max_word_size=8, constant_word_size=False)
    return rw.generate()
    print(rw.generate())
Пример #16
0
def test3():
    rw = RandomWord(max_word_size=1000000, constant_word_size=True)
    assert len(rw.generate()) == 1000000
Пример #17
0
def test1():
    rw = RandomWord(max_word_size=-15, constant_word_size=True)
    assert rw.generate() is None
Пример #18
0
    def generate_random_documents(self, random_type=str, size=10):
        """
        Generate random documents to MongoDB.

        Args:
        -----
        random_type: Choose random data type. Has three type: int, float and str.
        
        size: Generate specified amount documents.
        """

        # Define constant.
        logging.info("Initializing random data constant variable...")
        if random_type == str:
            rand_account = RandomWord(max_word_size=12,
                                      constant_word_size=False,
                                      include_digits=True)
            rand_passwd = RandomWord(max_word_size=20,
                                     constant_word_size=False,
                                     include_digits=True,
                                     include_special_chars=True)
        elif random_type == int:
            computer_brands = [
                "ASUS", "Acer", "MSI", "Lenovo", "Microsoft", "Mac"
            ]
            countrys = ["America", "China", "Taiwan", "Japan", "Korea"]
        elif random_type == float:
            names = ["michael", "peter", "allen", "kevin", "jack"]
        else:
            logging.warning(
                "random_type data type error ! only str、int and float type.",
                exc_info=True)
            raise TypeError

        # Insert data to MongoDB.
        logging.info("Inserting {} type random data...".format(random_type))
        for i in range(size):
            if random_type == str:
                create_time = get_now_time("%Y-%m-%d %H:%M:%S")
                account = rand_account.generate()
                password = rand_passwd.generate()
                account_length = len(account)
                password_length = len(password)

                logging.debug(
                    self.collection.insert_one({
                        "account": account + '@gmail.com',
                        "password": password,
                        "account_length": account_length,
                        "password_length": password_length,
                        "create_time": create_time
                    }))
            elif random_type == int:
                create_time = get_now_time("%Y-%m-%d %H:%M:%S")
                year = randint(1980, 2021)
                country = countrys[randint(0, len(countrys) - 1)]
                computer_brand = computer_brands[randint(
                    0,
                    len(computer_brands) - 1)]
                notebook_sales = randint(100000, 99999999)
                pc_sales = randint(100000, 99999999)

                logging.debug(
                    self.collection.insert_one({
                        "year": year,
                        "country": country,
                        "computer_brand": computer_brand,
                        "notebook_sales": notebook_sales,
                        "pc_sales": pc_sales,
                        "create_time": create_time
                    }))
            elif random_type == float:
                create_time = get_now_time("%Y-%m-%d %H:%M:%S")
                name = names[randint(0, len(names) - 1)]
                height = randint(150, 220) + round(random(), 2)
                weight = randint(30, 100) + round(random(), 2)
                logging.debug(
                    self.collection.insert_one({
                        "name": name,
                        "height": height,
                        "weight": weight,
                        "create_time": create_time
                    }))

        logging.info("Insertd {} doduments successfully !".format(size))
Пример #19
0
def random_word():
    r = RandomWord(max_word_size=5)
    return r.generate()