Feat: possiblité de rejouter inv sequence
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5133d15ffd
commit
4287911c23
74
tasks.py
74
tasks.py
@ -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,30 +119,31 @@ 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(" ", "_")
|
||||
)
|
||||
dest = Path(dest)
|
||||
dest = unidecode(
|
||||
("{tribe}/{num:0>2}_{title}/".format(**sequence)).replace(" ", "_")
|
||||
)
|
||||
dest = Path(dest)
|
||||
|
||||
seq_summary = """\
|
||||
Séquence: {num:0>2} {title}
|
||||
Niveau: {tribe}
|
||||
Auteur: {author}
|
||||
Date: {date}
|
||||
Tags: {tags}
|
||||
Sommaire: {summary}
|
||||
Dossier: {dest}
|
||||
""".format(
|
||||
dest=dest, **sequence
|
||||
)
|
||||
print(seq_summary)
|
||||
seq_summary = """\
|
||||
Séquence: {num:0>2} {title}
|
||||
Niveau: {tribe}
|
||||
Auteur: {author}
|
||||
Date: {date}
|
||||
Tags: {tags}
|
||||
Sommaire: {summary}
|
||||
Dossier: {dest}
|
||||
""".format(
|
||||
dest=dest, **sequence
|
||||
)
|
||||
print(seq_summary)
|
||||
|
||||
validate = prompt("C'est ok? ")
|
||||
if validate.lower() in ["o", "y", ""]:
|
||||
sequence["title_under"] = "#" * len(sequence["title"])
|
||||
import_skel(dest, sequence, "sequence")
|
||||
else:
|
||||
print("Tant pis. Ya plus qu'à recommencer.")
|
||||
validate = prompt("C'est ok? ").lower() in ["o", "k", "oui", "ok"]
|
||||
|
||||
sequence["title_under"] = "#" * len(sequence["title"])
|
||||
import_skel(dest, sequence, "sequence")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user