Mise à jour des utilitaires pour la création des formations
This commit is contained in:
parent
ddd71f3332
commit
ce9ee26e78
|
@ -11,7 +11,8 @@ from jinja2 import Environment, FileSystemLoader
|
||||||
LICENSES = {'CC-by-sa-2.0': 'license-cc-by-sa-2.0',
|
LICENSES = {'CC-by-sa-2.0': 'license-cc-by-sa-2.0',
|
||||||
}
|
}
|
||||||
|
|
||||||
LATEX_SUBS = {}
|
LATEX_SUBS = [(re.compile('_'), '\\_'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_unique_name(base):
|
def get_unique_name(base):
|
||||||
|
@ -73,7 +74,12 @@ def main():
|
||||||
|
|
||||||
license = LICENSES.get(args.license, 'license-cc-by-sa-2.0')
|
license = LICENSES.get(args.license, 'license-cc-by-sa-2.0')
|
||||||
|
|
||||||
|
document_class = args.format
|
||||||
|
content = 'sli' if document_class == 'beamer' else 'rep'
|
||||||
|
|
||||||
env = {'root': root,
|
env = {'root': root,
|
||||||
|
'class': document_class,
|
||||||
|
'content': content,
|
||||||
'title': title,
|
'title': title,
|
||||||
'author': author,
|
'author': author,
|
||||||
'client': client,
|
'client': client,
|
||||||
|
@ -97,7 +103,7 @@ def main():
|
||||||
re_class = re.compile(r'\\documentclass\{(?P<document_class>.*)\}')
|
re_class = re.compile(r'\\documentclass\{(?P<document_class>.*)\}')
|
||||||
#skbconfig_re = re.compile(r'\\skbconfig\[\s*root\s*=\s*(?P<root>.*),\s*rep\s*=\s*(?P<rep>.*),\s*pub\s*=\s*(?P<pub>.*),\s*fig\s*=\s*(?P<fig>.*),\s*sli\s*=\s*(?P<sli>.*),\s*acr\s*=\s*(?P<acr>.*),\s*bib\s*=\s*(?P<bib>.*),\s*\]\{skblocal.tex\}', re.M)
|
#skbconfig_re = re.compile(r'\\skbconfig\[\s*root\s*=\s*(?P<root>.*),\s*rep\s*=\s*(?P<rep>.*),\s*pub\s*=\s*(?P<pub>.*),\s*fig\s*=\s*(?P<fig>.*),\s*sli\s*=\s*(?P<sli>.*),\s*acr\s*=\s*(?P<acr>.*),\s*bib\s*=\s*(?P<bib>.*),\s*\]\{skblocal.tex\}', re.M)
|
||||||
skbconfig_re = re.compile(r'\\skbconfig\[\n\s*root\s*=\s*(?P<root>.*),\n\s*rep\s*=\s*(?P<rep>.*),\n\s*pub\s*=\s*(?P<pub>.*),\n\s*fig\s*=\s*(?P<fig>.*),\n\s*sli\s*=\s*(?P<sli>.*),\n\s*acr\s*=\s*(?P<acr>.*),\n\s*bib\s*=\s*(?P<bib>.*)\n\s*\]\{skblocal.tex\}', re.M)
|
skbconfig_re = re.compile(r'\\skbconfig\[\n\s*root\s*=\s*(?P<root>.*),\n\s*rep\s*=\s*(?P<rep>.*),\n\s*pub\s*=\s*(?P<pub>.*),\n\s*fig\s*=\s*(?P<fig>.*),\n\s*sli\s*=\s*(?P<sli>.*),\n\s*acr\s*=\s*(?P<acr>.*),\n\s*bib\s*=\s*(?P<bib>.*)\n\s*\]\{skblocal.tex\}', re.M)
|
||||||
skbinput_re = re.compile(r'\\skbinput\[from=(?P<rep>.*)\]\{(?P<tex>.*?)\}')
|
skbinput_re = re.compile(r'[^%]\\skbinput\[from=(?P<rep>.*)\]\{(?P<tex>.*?)\}', re.M)
|
||||||
with open(args.master, 'r') as master:
|
with open(args.master, 'r') as master:
|
||||||
tex_master = master.read()
|
tex_master = master.read()
|
||||||
tex_class = re_class.search(tex_master)
|
tex_class = re_class.search(tex_master)
|
||||||
|
@ -110,10 +116,11 @@ def main():
|
||||||
basename = '{0}.tex'.format(path.basename(skbinput.group('tex')))
|
basename = '{0}.tex'.format(path.basename(skbinput.group('tex')))
|
||||||
dest = path.join(rep, basename)
|
dest = path.join(rep, basename)
|
||||||
if not path.isfile(dest):
|
if not path.isfile(dest):
|
||||||
|
print(dest)
|
||||||
if not path.isdir(rep):
|
if not path.isdir(rep):
|
||||||
makedirs(rep)
|
makedirs(rep)
|
||||||
template = jinja_env.get_template('frame.tex')
|
template = jinja_env.get_template('frame.tex')
|
||||||
env = {'title': '', 'subtitle': '',
|
env = {'title': basename, 'subtitle': '',
|
||||||
'name': dest}
|
'name': dest}
|
||||||
rendered_template = template.render(**env)
|
rendered_template = template.render(**env)
|
||||||
with open(dest, 'w') as rendered_file:
|
with open(dest, 'w') as rendered_file:
|
||||||
|
@ -148,6 +155,7 @@ def main():
|
||||||
parser = argparse.ArgumentParser(description="Préparation des fichiers tex")
|
parser = argparse.ArgumentParser(description="Préparation des fichiers tex")
|
||||||
subparsers = parser.add_subparsers(help='Aide des sous-commandes')
|
subparsers = parser.add_subparsers(help='Aide des sous-commandes')
|
||||||
parser_init = subparsers.add_parser('init', help='Initialisation du fichier maître')
|
parser_init = subparsers.add_parser('init', help='Initialisation du fichier maître')
|
||||||
|
parser_init.add_argument('-f', '--format', help="Format du document", required=True)
|
||||||
parser_init.add_argument('-n', '--name', help="Nom du fichier à créer", required=True)
|
parser_init.add_argument('-n', '--name', help="Nom du fichier à créer", required=True)
|
||||||
parser_init.add_argument('-a', '--author', help="Auteur de la formation")
|
parser_init.add_argument('-a', '--author', help="Auteur de la formation")
|
||||||
parser_init.add_argument('-c', '--client', help="Client")
|
parser_init.add_argument('-c', '--client', help="Client")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
\begin{frame}
|
\begin{frame}
|
||||||
\frametitle{(((title)))}
|
\frametitle{(((title|escape_tex)))}
|
||||||
fichier (((name))) à éditer
|
fichier (((name|escape_tex))) à éditer
|
||||||
% contenu (pas trop long) de la diapositive
|
% contenu (pas trop long) de la diapositive
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
\documentclass{beamer}
|
\documentclass{(((class)))}
|
||||||
|
|
||||||
\usepackage{skb}
|
\usepackage{skb}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
bib = database/bib
|
bib = database/bib
|
||||||
]{skblocal.tex}
|
]{skblocal.tex}
|
||||||
|
|
||||||
\skbinput[from=rep]{style/preambule_slides}
|
\skbinput[from=(((content)))]{style/preambule}
|
||||||
|
|
||||||
\title[]{(((title)))}
|
\title[]{(((title)))}
|
||||||
\subtitle{(((client)))}
|
\subtitle{(((client)))}
|
||||||
|
@ -35,12 +35,12 @@
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
|
||||||
\skbinput[from=rep]{style/title}
|
\skbinput[from=(((content)))]{style/title}
|
||||||
|
|
||||||
% Corps de la formation
|
% Corps de la formation
|
||||||
%\skbinput[from=slides]{}
|
%\skbinput[from=(((content)))]{}
|
||||||
|
|
||||||
\skbinput[from=rep]{licences/(((license)))}
|
\skbinput[from=(((content)))]{licences/(((license)))}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue