Add pwgen-fr entrypoint
This commit is contained in:
parent
4f152d45f2
commit
64a3a30ddc
3 changed files with 26 additions and 6 deletions
22
pwgen_fr/entrypoints.py
Normal file
22
pwgen_fr/entrypoints.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
import argparse
|
||||
import typing as t
|
||||
|
||||
from . import generate
|
||||
|
||||
|
||||
def pwgen_fr():
|
||||
choices_map: dict[str, t.Callable[[], str]] = {
|
||||
"phrase4": generate.gen_phrase4,
|
||||
"phrase6": generate.gen_phrase6,
|
||||
"rand4": lambda: generate.gen_rand(n=4),
|
||||
"rand6": lambda: generate.gen_rand(n=4),
|
||||
}
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"mode", choices=choices_map.keys(), help="Select the generation procedure used"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print(choices_map[args.mode]())
|
|
@ -5,7 +5,7 @@ from . import word_db
|
|||
wdb = word_db.WordDb.autoload()
|
||||
|
||||
|
||||
def gen_phrase4():
|
||||
def gen_phrase4() -> str:
|
||||
"""Generates a sentence with four words, of structure Adjective Noun Verb Adverb"""
|
||||
nombre = word_db.Nombre.pick()
|
||||
temps = word_db.Temps.pick()
|
||||
|
@ -25,7 +25,7 @@ def gen_phrase4():
|
|||
)
|
||||
|
||||
|
||||
def gen_phrase6():
|
||||
def gen_phrase6() -> str:
|
||||
"""Generates a sentence with six words, of structure Adjective Noun Verb Adjective
|
||||
Noun Adverb"""
|
||||
nombres = [word_db.Nombre.pick() for _ in range(2)]
|
||||
|
@ -50,7 +50,7 @@ def gen_phrase6():
|
|||
)
|
||||
|
||||
|
||||
def gen_rand(n=4):
|
||||
def gen_rand(n=4) -> str:
|
||||
"""Generates a fully random sequence of n words, without grammatical consistency"""
|
||||
out = []
|
||||
for _ in range(n):
|
||||
|
|
4
setup.py
4
setup.py
|
@ -25,9 +25,7 @@ setup(
|
|||
install_requires=parse_requirements(),
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
# (
|
||||
# "proxmox-snapshot-review = proxmox_scripts.snapshots:review_snapshots",
|
||||
# ),
|
||||
("pwgen-fr = pwgen_fr.entrypoints:pwgen_fr",),
|
||||
]
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue