-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordgenerator.py
37 lines (25 loc) · 885 Bytes
/
wordgenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import requests
import random
from pathlib import Path
DEPTH = 3
FOLDERS = 5
FILES = 5
word_site = "https://www.mit.edu/~ecprice/wordlist.10000"
response = requests.get(word_site)
WORDS = response.content.decode().split("\n")
INIT_PATH = "./testdir"
Path(INIT_PATH).mkdir(parents=True, exist_ok=False)
FILENAME = "testcase"
FOLDERNAME = "testdir_"
PATH_QUEUE = ["./testdir"]
def create_tests(deep, path):
for i in range(FILES):
content = [random.choice(WORDS) for i in range(100)]
with Path('{}/{}{}.txt'.format(path, FILENAME, i)).open("w") as f:
f.write("\n".join(content))
if deep != DEPTH:
for i in range(FOLDERS):
new_path = '{}/{}{}'.format(path, FOLDERNAME,i)
Path(new_path).mkdir(parents=True, exist_ok=False)
create_tests(deep + 1, new_path)
create_tests(1, INIT_PATH)