-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
45 lines (37 loc) · 1.14 KB
/
generator.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
38
39
40
41
42
43
44
45
import random
import yaml
class Animal:
def __init__(self) -> None:
with open("animals.yaml", "r") as stream:
try:
self.animals = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)
def getRandom(self) -> str:
random_num = random.randrange(0,len(self.animals))
return list(self.animals)[random_num]
class Adjective:
def __init__(self) -> None:
with open("adjectives.yaml", "r") as stream:
try:
self.adjectives = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)
def getByLetter(self,letter) -> str:
adjective_list = set()
for adjective in self.adjectives:
if adjective[0] == letter:
adjective_list.add(adjective)
random_num = random.randrange(0,len(adjective_list))
return list(adjective_list)[random_num]
class NFT:
def __init__(self) -> None:
pass
def getName(self) -> str:
animal = Animal().getRandom()
adjective = Adjective().getByLetter(animal[0])
return adjective + ' ' + animal
class Main:
print("NFT Project Name: {}'s".format(NFT().getName()))
if __name__ == "__main__":
Main()