Command line use enable

This commit is contained in:
lafrite 2013-09-27 22:21:46 +02:00
parent 8e172624e8
commit e51d5d1143
2 changed files with 44 additions and 17 deletions

View File

@ -30,7 +30,7 @@ Le barème est donné à titre indicatif, il pourra être modifié.
\begin{Exo}[4]
On cherche à évaluer l'aire du rectangle suivant:
\begin{center}
\includegraphics[scale=0.3]{fig/rectangle}
%\includegraphics[scale=0.3]{fig/rectangle}
\end{center}
\begin{enumerate}[a.]
\item En fonction de $x$, déterminer la hauteur puis la largeur du rectangle.

51
number_rotation.py Normal file → Executable file
View File

@ -2,16 +2,8 @@
# encoding: utf-8
import jinja2, random, os
report_renderer = jinja2.Environment(
block_start_string = '%{',
block_end_string = '%}',
variable_start_string = '%{{',
variable_end_string = '%}}',
loader = jinja2.FileSystemLoader(os.path.abspath('.'))
)
template = report_renderer.get_template('./DS_09_litt_mediane.tpl.tex')
import sys
import optparse
def randfloat(approx = 1, low = 0, up = 10):
""" return a random number between low and up with approx floating points """
@ -34,13 +26,48 @@ random.randfloat = randfloat
random.gaussRandomlist = gaussRandomlist
random.hauteurs = hauteurs
for subj in ["A"]:
dest = 'DS_09_litt_mediane_{subj}.tex'.format(subj = subj)
report_renderer = jinja2.Environment(
block_start_string = '%{',
block_end_string = '%}',
variable_start_string = '%{{',
variable_end_string = '%}}',
loader = jinja2.FileSystemLoader(os.path.abspath('.'))
)
def main(options):
template = report_renderer.get_template(options.template)
if options.output:
output_basename = options.output
else:
tpl_base = os.path.splitext(options.template)[0]
output_basename = tpl_base + "_"
for subj in range(options.num_subj):
subj = subj+1
dest = output_basename + str(subj) + '.tex'
with open( dest, 'w') as f:
f.write(template.render(random = random, infos = {"subj" : subj}))
os.system("pdflatex " + dest)
os.system("rm *.aux *.log")
if __name__ == '__main__':
parser = optparse.OptionParser()
parser.add_option("-t","--tempalte",action="store",type="string",dest="template", help="File with template")
parser.add_option("-o","--output",action="store",type="string",dest="output",help="Base name for output (without .tex or any extension))")
parser.add_option("-n","--number_subjects", action="store",type="int", dest="num_subj", default = 2, help="The number of subjects to make")
(options, args) = parser.parse_args()
if not options.template:
print("I need a template!")
sys.exit(0)
main(options)
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4: