Feat: possiblité de rejouter inv sequence
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bertrand Benjamin 2020-09-22 20:42:19 +02:00
parent 5133d15ffd
commit 4287911c23

View File

@ -49,30 +49,45 @@ def next_weekday(date, day=0):
return date + datetime.timedelta(days=(day - date.weekday() + 7) % 7)
def sequence_prompt():
def sequence_prompt(
author=AUTHOR,
tribe="",
title="",
tags="",
summary="",
*args,
**kwrds,
):
sequence = {}
print("Nouvelle séquence")
sequence["author"] = prompt("Auteur: ", default=AUTHOR)
sequence["author"] = prompt("Auteur: ", default=author)
sequence["date"] = datetime.date.today()
tribes = WordCompleter([t["directory"] for t in TRIBES])
sequence["tribe"] = prompt(
"Classe: ", completer=tribes, validator=Validator.from_callable(is_tribe)
"Classe: ",
completer=tribes,
validator=Validator.from_callable(is_tribe),
default=tribe,
)
sequences = get_sequences(sequence["tribe"])
print("Séquences trouvées:\n\t" + "\n\t".join(sorted([s.name for s in sequences])))
sequence["num"] = max([int(seq.name[0:2]) for seq in sequences]) + 1
sequence["title"] = prompt(f"Nom de la séquence (n°{sequence['num']}): ")
sequence["title"] = prompt(
f"Nom de la séquence (n°{sequence['num']}): ", default=title
)
known_tags = get_tags()
sequence["tags"] = prompt(
"Tags (séparés par une virgule): ", completer=WordCompleter(known_tags)
"Tags (séparés par une virgule): ",
completer=WordCompleter(known_tags),
default=tags,
)
sequence["summary"] = prompt("Résumé: ")
sequence["summary"] = prompt("Résumé: ", default=summary)
return sequence
@ -104,7 +119,10 @@ def import_skel(dest, datas, skel="sequence", skel_path="./tools/skeleton"):
@task
def sequence(c):
sequence = sequence_prompt()
sequence = {}
validate = False
while not validate:
sequence = sequence_prompt(**sequence)
dest = unidecode(
("{tribe}/{num:0>2}_{title}/".format(**sequence)).replace(" ", "_")
@ -124,10 +142,8 @@ def sequence(c):
)
print(seq_summary)
validate = prompt("C'est ok? ")
if validate.lower() in ["o", "y", ""]:
validate = prompt("C'est ok? ").lower() in ["o", "k", "oui", "ok"]
sequence["title_under"] = "#" * len(sequence["title"])
import_skel(dest, sequence, "sequence")
else:
print("Tant pis. Ya plus qu'à recommencer.")