Add support for neuter nouns
This commit is contained in:
20
generate.py
20
generate.py
@@ -12,11 +12,18 @@ from reportlab.graphics import renderPDF
|
||||
from svglib.svglib import svg2rlg
|
||||
from urllib.parse import urljoin
|
||||
|
||||
def generate_random_username(female_nouns, male_nouns, adjectives, used_usernames):
|
||||
def generate_random_username(female_nouns, male_nouns, neuter_nouns, adjectives, used_usernames):
|
||||
random_username = None
|
||||
while True:
|
||||
nouns = choice([female_nouns, male_nouns])
|
||||
random_username = f"{adjectives[randrange(len(adjectives)-1)]}{'' if nouns is female_nouns else 'r'}-{nouns[randrange(len(nouns)-1)].lower()}"
|
||||
nouns = choice([female_nouns, male_nouns, neuter_nouns])
|
||||
|
||||
adjektive_suffix = ""
|
||||
if nouns is male_nouns:
|
||||
adjektive_suffix = "r"
|
||||
elif nouns is neuter_nouns:
|
||||
adjektive_suffix = "s"
|
||||
|
||||
random_username = f"{adjectives[randrange(len(adjectives))]}{adjektive_suffix}-{nouns[randrange(len(nouns))].lower()}"
|
||||
if random_username not in used_usernames:
|
||||
used_usernames.add(random_username)
|
||||
print(random_username)
|
||||
@@ -36,6 +43,7 @@ if __name__ == "__main__":
|
||||
adjectives = set()
|
||||
female_nouns = set()
|
||||
male_nouns = set()
|
||||
neuter_nouns = set()
|
||||
with open('adjektive-weiblich.txt', 'r') as file:
|
||||
for line in file:
|
||||
adjectives.add(line.strip())
|
||||
@@ -45,9 +53,13 @@ if __name__ == "__main__":
|
||||
with open('nomen-maennlich.txt', 'r') as file:
|
||||
for line in file:
|
||||
male_nouns.add(line.strip())
|
||||
with open('nomen-neutrum.txt', 'r') as file:
|
||||
for line in file:
|
||||
neuter_nouns.add(line.strip())
|
||||
adjectives = list(adjectives)
|
||||
female_nouns = list(female_nouns)
|
||||
male_nouns = list(male_nouns)
|
||||
neuter_nouns = list(neuter_nouns)
|
||||
|
||||
pdf = canvas.Canvas(args.output, pagesize=A4)
|
||||
page_width, page_height = A4
|
||||
@@ -94,7 +106,7 @@ if __name__ == "__main__":
|
||||
|
||||
for y in range(codes_per_col):
|
||||
for x in range(codes_per_row):
|
||||
url = urljoin(args.url, generate_random_username(female_nouns, male_nouns, adjectives, used_usernames))
|
||||
url = urljoin(args.url, generate_random_username(female_nouns, male_nouns, neuter_nouns, adjectives, used_usernames))
|
||||
qr_code = QrCodeWidget(url)
|
||||
bounds = qr_code.getBounds()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user