2020-10-21 00:22:25 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import random
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
cur_dir = Path(os.path.abspath(__file__)).parent
|
|
|
|
|
|
|
|
# Noms et prénoms les plus fréquents en France:
|
2021-08-31 23:31:36 +02:00
|
|
|
NOMS = [x.strip() for x in open(cur_dir / "nomsprenoms" / "noms.txt").readlines()]
|
|
|
|
PRENOMS_H = [
|
|
|
|
x.strip() for x in open(cur_dir / "nomsprenoms" / "prenoms-h.txt").readlines()
|
|
|
|
]
|
|
|
|
PRENOMS_F = [
|
|
|
|
x.strip() for x in open(cur_dir / "nomsprenoms" / "prenoms-f.txt").readlines()
|
|
|
|
]
|
|
|
|
PRENOMS_X = [
|
|
|
|
x.strip() for x in open(cur_dir / "nomsprenoms" / "prenoms-x.txt").readlines()
|
|
|
|
]
|
2020-10-21 00:22:25 +02:00
|
|
|
|
|
|
|
|
2021-02-13 17:28:55 +01:00
|
|
|
def nomprenom(civilite):
|
|
|
|
"""Un nom et un prenom au hasard,
|
|
|
|
toujours en majuscules. Pour tests et démos.
|
2020-11-11 22:05:29 +01:00
|
|
|
"""
|
2021-02-13 17:28:55 +01:00
|
|
|
if civilite == "F":
|
2020-10-21 00:22:25 +02:00
|
|
|
prenom = random.choice(PRENOMS_F)
|
2021-02-13 17:28:55 +01:00
|
|
|
elif civilite == "M":
|
2020-10-21 00:22:25 +02:00
|
|
|
prenom = random.choice(PRENOMS_H)
|
2021-02-13 17:28:55 +01:00
|
|
|
elif civilite == "X":
|
|
|
|
prenom = random.choice(PRENOMS_X)
|
|
|
|
else:
|
|
|
|
raise ValueError("civilite must be M, F or X")
|
2020-11-11 22:05:29 +01:00
|
|
|
return random.choice(NOMS).upper(), prenom.upper()
|