Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, random, re, string, time
- from multiprocessing.dummy import Pool as ThreadPool
- def clear():
- from sys import platform
- if platform == "linux" or platform == "linux2":
- os.system('clear')
- elif platform == "darwin":
- os.system('clear')
- elif platform == "win32":
- os.system('cls')
- clear()
- digits = string.digits
- lowercase = string.ascii_lowercase
- digitlowercase = digits + lowercase
- uppercase = string.ascii_uppercase
- digituppercase = digits + uppercase
- upperlower = string.ascii_letters
- any = digits + upperlower
- extractPattern = re.compile(r"\[(.*?)\]")
- print("Pattern samples:")
- print("[0-9] - any digit")
- print("[a-z] - any lowercase character")
- print("[0-z] - any digit or lowercase character")
- print("[A-Z] - any uppercase character")
- print("[0-Z] - any digit or uppercase character")
- print("[a-Z] - any upper- or lowercase character")
- print("[0-zA-Z] - any digit, upper- or lowercase character")
- print("Use `|` as a delimiter, example: `LEQ|0-Z|0-Z|0-9|0-9|0-9|0-9|0-9|0-9`\r\n")
- pattern = input("How would you like your pattern, hun?\r\n")
- pattern = pattern.split('|')
- def generatePatterns(x):
- finalpattern = ""
- for kek in pattern:
- if "0-9" == kek:
- finalpattern += random.choice(digits)
- elif "a-z" == kek:
- finalpattern += random.choice(lowercase)
- elif "0-z" == kek:
- finalpattern += random.choice(digitlowercase)
- elif "A-Z" == kek:
- finalpattern += random.choice(uppercase)
- elif "0-Z" == kek:
- finalpattern += random.choice(digituppercase)
- elif "a-Z" == kek:
- finalpattern += random.choice(upperlower)
- elif "0-zA-Z" == kek:
- finalpattern += random.choice(any)
- else:
- finalpattern += kek
- print(f"[{finalpattern}] - Generated")
- with open("generated.txt","a+") as gen:
- gen.write(finalpattern + "\n")
- clear()
- amount = int(input("How many do you want to generate?\r\n"))
- thread_count = int(input("How many threads do you want to run?\r\n"))
- start = time.time()
- pool = ThreadPool(thread_count)
- pool.map(generatePatterns, range(amount))
- pool.close()
- pool.join()
- ended = time.time()
- elapsed = ended - start
- input(f"Can I have a taco? {elapsed}\r\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement