mirror of
https://forge.chapril.org/tykayn/book_generator
synced 2025-06-20 01:34:43 +02:00
up structure
This commit is contained in:
parent
fbaad4fbe5
commit
de532abbb7
5 changed files with 32 additions and 27 deletions
|
@ -1,2 +1,3 @@
|
||||||
|
|
||||||
/home/poule/encrypted/stockage-syncable/www/development/html/book_generator/récits_jeanine
|
/home/poule/encrypted/stockage-syncable/www/development/html/book_generator/récits_jeanine
|
||||||
|
/home/poule/encrypted/stockage-syncable/www/development/html/book_generator/sabotage
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
mkdir -p $dossier_illustrations
|
mkdir -p $dossier_illustrations
|
||||||
cp _models/illustrations/base_dessin.$extension "$dossier_illustrations/$nom_illustration.$extension"
|
cp _models/illustrations/base_dessin.$extension "$dossier_illustrations/$nom_illustration.$extension"
|
||||||
date2name -w "$dossier_illustrations/$nom_illustration.$extension"
|
date2name -w "$dossier_illustrations/$nom_illustration.$extension"
|
||||||
|
rangereal "$dossier_illustrations/*$extension"
|
||||||
|
|
||||||
ls -l $dossier_illustrations
|
ls -l "$dossier_illustrations/$nom_illustration.$extension"
|
||||||
echo "fichier d'illustration $nom_illustration.$extension créé"
|
echo "fichier d'illustration $nom_illustration.$extension créé"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
EBOOK_NAME="camp_chatons_2021"
|
EBOOK_NAME="camp_chatons_2021"
|
||||||
|
|
||||||
# Ce script sert à publier le mon_ebook.
|
# Ce script sert à publier le mon_ebook.
|
||||||
|
|
|
@ -1,35 +1,37 @@
|
||||||
#####################
|
# créer une structure de livre orgmode selon des contraintes données
|
||||||
# génère une structure à copier dans un nouveau fichier livre.org
|
# python structure_generator.py --objective_words 1000 --objective_chapter 2000 --number_chapters 10 --number_parts 4 --save_livre True
|
||||||
# ce script ne remplit pas directement un fichier pour éviter les écrasements trop soudains.
|
|
||||||
# Exemple d'exécution:
|
|
||||||
#
|
|
||||||
# python structure_generator.py --number_chapters 7 --number_parts 2 --objective_words 600 --objective_chapter 1800
|
|
||||||
#
|
|
||||||
#####################
|
|
||||||
#
|
|
||||||
# Si vous voulez créer directement un fichier livre sans le reste de ce que fabriquerait generate_book.sh:
|
|
||||||
#
|
|
||||||
# python structure_generator.py > mon_livre_généré.org
|
|
||||||
#
|
|
||||||
#####################
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser(description='Générer un livre avec des chapitres et des parties.')
|
||||||
parser.add_argument('--objective_words', type=int, default=500)
|
|
||||||
parser.add_argument('--objective_chapter', type=int, default=1500)
|
|
||||||
parser.add_argument('--number_chapters', type=int, default=5)
|
|
||||||
parser.add_argument('--number_parts', type=int, default=3)
|
|
||||||
args = parser.parse_args()
|
|
||||||
book_content = ''
|
|
||||||
|
|
||||||
|
parser.add_argument('--objective_words', type=int, default=500, help='le nombre de mots par chapitre (par défaut 500)')
|
||||||
|
parser.add_argument('--objective_chapter', type=int, default=1500, help='le nombre de mots par chapitre (par défaut 1500)')
|
||||||
|
parser.add_argument('--number_chapters', type=int, default=5, help='le nombre de chapitres (par défaut 5)')
|
||||||
|
parser.add_argument('--number_parts', type=int, default=3, help='le nombre de parties (par défaut 3)')
|
||||||
|
parser.add_argument('--save_livre', type=bool, default=False, help='si le fichier "livre.org" doit être écrasé avec la nouvelle structure générée (par défaut False)')
|
||||||
|
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
print(args)
|
print(args)
|
||||||
|
|
||||||
|
book_content = ''
|
||||||
|
|
||||||
for i in range(args.number_chapters):
|
for i in range(args.number_chapters):
|
||||||
book_content += f"\n\n### Chapitre {i+1} :title:target_{args.objective_words}:"
|
book_content += f"\n\n** Chapitre {i+1} :title:target_{args.objective_words}:"
|
||||||
for j in range(args.number_parts):
|
for j in range(args.number_parts):
|
||||||
book_content += f"\n\n### Chapitre {i+1} - Partie {j+1} :title:target_{args.objective_words}:"
|
book_content += f"\n\n*** Chapitre {i+1} - Partie {j+1} :title:target_{args.objective_words}:"
|
||||||
|
|
||||||
print("--------------")
|
print("--------------")
|
||||||
print(book_content)
|
print(book_content)
|
||||||
print("--------------")
|
print("--------------")
|
||||||
print("vous pouvez copier cette cascade de parties de livre dans livre.org")
|
|
||||||
|
if args.save_livre:
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
date_string = now.strftime("%Y-%m-%d_%H-%M-%S")
|
||||||
|
backup_file_path = f"{date_string}__livre.org"
|
||||||
|
os.copy("livre.org", backup_file_path)
|
||||||
|
|
||||||
|
with open('livre.org', 'w') as f:
|
||||||
|
f.write(book_content)
|
||||||
|
print("Livres sauvegardé sous le nom de livre.txt")
|
||||||
|
else:
|
||||||
|
print("Vous pouvez copier cette cascade de parties de livre dans livre.org")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue