Last active
October 30, 2022 00:09
-
-
Save midsonlajeanty/355a7971bfebf924f5a8eaf9b7c5ab0c to your computer and use it in GitHub Desktop.
Generate Epsedo pou Rezo Sosyal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice, randint | |
def clspace(string: str) -> str: | |
return string.replace(" ", "") | |
def get_len(string: str) -> str: | |
return len(clspace(string)) | |
def get_all_first_letter(string: str): | |
return "".join(list(map(lambda el: el[0], string.split()))) | |
def get_word_min_length(first: str, last: str) -> int: | |
listWord = [] | |
listWord.extend(first.split()) | |
listWord.extend(last.split()) | |
min = listWord[0] | |
for el in listWord: | |
min = el if len(el) < len(min) else min | |
return min | |
def get_user_input(type: str) -> str: | |
antre = "" | |
while len(antre) < 3 or not clspace(antre).isalpha(): | |
antre = input(f"Antre {type} w : ") | |
if(len(antre) < 3): | |
print(f"{type} an dwe gen pou pi piti twa let. Eseye Anko !\n") | |
elif not clspace(antre).isalpha(): | |
print(f"{type} an dwe gen let selman. Eseye Anko !\n") | |
return antre.strip().title() | |
def generate_psuedo(first: str, last: str) -> tuple: | |
ps1 = get_all_first_letter(first) + get_all_first_letter(last) | |
ps1 += str(get_len(first + last)) | |
ps2 = clspace(first + last) | |
ps3 = "".join(reversed(get_word_min_length(first, last))) | |
ps3 += str(randint(100, 1000)) | |
ps3 = ps3.title() | |
return ps1, ps2, ps3, clspace(first), clspace(last) | |
def save_psuedo(ps: str): | |
with open('bd.txt', 'a') as f: | |
f.write(ps + ",") | |
def load_psuedos() -> list: | |
with open('bd.txt', 'r') as f: | |
data = f.read() | |
return data[:-1].split(",") | |
try: | |
kantite = len(load_psuedos()) | |
except FileNotFoundError: | |
pass | |
print("Program Generasyon Epsedo pou Rezo Sosyal\n" | |
"Copyright 2022 - Vesyon 1.0\n") | |
print("Pou nou kapab ede w :\n") | |
non = get_user_input("Non") | |
siyati = get_user_input("Siyati") | |
print( | |
f"\nBonjou {non.title()} {siyati.title()}, nou kontan ede w kreye Epsedo pou Rezo Sosyal ou yo.") | |
if "kantite" in locals(): | |
print( | |
f"Nou tre rekoni nan sèvis nou an, nou deja jenere epsedo pou {kantite} moun deja\n") | |
print("Pwosesis generation Epsedo a lanse\n") | |
psuedoes = generate_psuedo(non, siyati) | |
print("Men lis Epsedo System nn Genere pou ou yo :\n") | |
for i, ps in enumerate(psuedoes, 1): | |
print(f"\t{i}- {ps}") | |
print() | |
print("Lansman Analiz sou Epsedo yo\n") | |
system_choice: str = choice(list(filter(lambda el: len(el) < 7, psuedoes))) | |
save_psuedo(system_choice) | |
print("Apre Analiz, Nou kontan anonse w, se Epsedo sa, \"", | |
system_choice.upper(), "\" system nan rekomande w itilize sou Rezo yo.\n") | |
print("Mesi Paske W Itilize Program Nou An ...\n") | |
listWord.extend(first.split()) | |
listWord.extend(last.split()) | |
min = listWord[0] | |
for el in listWord: | |
min = el if len(el) < len(min) else min | |
return min | |
def get_user_input(type: str) -> str: | |
antre = "" | |
while len(antre) < 3 or not clspace(antre).isalpha(): | |
antre = input(f"Antre {type} w : ") | |
if(len(antre) < 3): | |
print(f"{type} an dwe gen pou pi piti twa let. Eseye Anko !\n") | |
elif not clspace(antre).isalpha(): | |
print(f"{type} an dwe gen let selman. Eseye Anko !\n") | |
return antre.strip().title() | |
def generate_psuedo(first: str, last: str) -> tuple: | |
ps1 = get_all_first_letter(first) + get_all_first_letter(last) | |
ps1 += str(get_len(first + last)) | |
ps2 = clspace(first + last) | |
ps3 = "".join(reversed(get_word_min_length(first, last))) | |
ps3 += str(randint(100, 1000)) | |
ps3 = ps3.title() | |
return ps1, ps2, ps3, clspace(first), clspace(last) | |
def save_psuedo(ps: str): | |
with open('bd.txt', 'a') as f: | |
f.write(ps + ",") | |
def load_psuedos() -> list: | |
with open('bd.txt', 'r') as f: | |
data = f.read() | |
return data[:-1].split(",") | |
try: | |
kantite = len(load_psuedos()) | |
except FileNotFoundError: | |
pass | |
print("Program Generasyon Epsedo pou Rezo Sosyal\n" | |
"Copyright 2022 - Vesyon 1.0\n") | |
print("Pou nou kapab ede w :\n") | |
non = get_user_input("Non") | |
siyati = get_user_input("Siyati") | |
print( | |
f"\nBonjou {non.title()} {siyati.title()}, nou kontan ede w kreye Epsedo pou Rezo Sosyal ou yo.") | |
if "kantite" in locals(): | |
print( | |
f"Nou tre rekoni nan sèvis nou an, nou deja jenere epsedo pou {kantite} moun deja\n") | |
print("Pwosesis generation Epsedo a lanse\n") | |
psuedoes = generate_psuedo(non, siyati) | |
print("Men lis Epsedo System nn Genere pou ou yo :\n") | |
for i, ps in enumerate(psuedoes, 1): | |
print(f"\t{i}- {ps}") | |
print() | |
print("Lansman Analiz sou Epsedo yo\n") | |
system_choice: str = choice(list(filter(lambda el: len(el) < 7, psuedoes))) | |
save_psuedo(system_choice) | |
print("Apre Analiz, Nou kontan anonse w, se Epsedo sa, \"", | |
system_choice.upper(), "\" system nan rekomande w itilize sou Rezo yo.\n") | |
print("Mesi Paske W Itilize Program Nou An ...\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment