bilan_templates are recognize and it works!! :D
This commit is contained in:
parent
8eb8acd899
commit
fda7b41a62
|
@ -8,7 +8,7 @@ from path import Path
|
|||
|
||||
# Defaults settings
|
||||
this_dir, this_filename = os.path.split(__file__)
|
||||
default_template = Path(this_dir + "/tpl_bilan.tex")
|
||||
default_template = "tpl_bilan.tex"
|
||||
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
|
@ -45,7 +45,7 @@ if not options.classe:
|
|||
if not options.ds_name:
|
||||
raise ValueError("Need to pass a evaluation name with -e. See -h for help")
|
||||
|
||||
build_bilan(options.classe,
|
||||
generate_bilan(options.classe,
|
||||
options.ds_name,
|
||||
options.path,
|
||||
options.template)
|
||||
|
|
|
@ -75,10 +75,9 @@ def build_target_name(classe, ds_name, path = Path("./")):
|
|||
>>> build_target_name("312", "DS1", Path("plop/"))
|
||||
Path('plop/312/bilan_DS1.tex')
|
||||
"""
|
||||
return Path(path + classe + "/bilan_" + ds_name + ".tex")
|
||||
|
||||
return path + classe + "/bilan_" + ds_name + ".tex"
|
||||
|
||||
def feed_bilan(target, datas, template = "./tpl_bilan.tex"):
|
||||
def feed_bilan(target, datas, template = "tpl_bilan.tex"):
|
||||
""" Get the template and feed it to create bilans
|
||||
|
||||
:param target: path where the bilan will be saved
|
||||
|
@ -86,11 +85,16 @@ def feed_bilan(target, datas, template = "./tpl_bilan.tex"):
|
|||
:param template: the template
|
||||
"""
|
||||
bilan = texenv.get_template(template)
|
||||
|
||||
path_to_target = target.dirname()
|
||||
if not path_to_target.exists():
|
||||
path_to_target.mkdir()
|
||||
|
||||
with open(target, "w") as f:
|
||||
f.write(bilan.render(**datas))
|
||||
print("{} est construit! Ya plus qu'à compiler!".format(target))
|
||||
|
||||
def generate_bilan(classe, ds_name, path = Path('./'), template = "./tpl_bilan.tex"):
|
||||
def generate_bilan(classe, ds_name, path = Path('./'), template = "tpl_bilan.tex"):
|
||||
""" Generate the bilan of a evaluation for a class
|
||||
|
||||
:param classe: the classe name
|
||||
|
@ -113,7 +117,7 @@ def generate_bilan(classe, ds_name, path = Path('./'), template = "./tpl_bilan.t
|
|||
|
||||
datas = {"ds_info": ds_info, "students":students_df}
|
||||
|
||||
target = build_target_name(classe, ds_name)
|
||||
target = build_target_name(classe, ds_name, path)
|
||||
feed_bilan(target, datas, template)
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ texenv = jinja2.Environment(
|
|||
block_end_string = '}',
|
||||
variable_start_string = '\Var{',
|
||||
variable_end_string = '}',
|
||||
loader = jinja2.FileSystemLoader(os.path.abspath('.')),
|
||||
loader = jinja2.PackageLoader("generate_bilan", "templates"),
|
||||
extensions = ['jinja2.ext.do']
|
||||
)
|
||||
|
||||
|
@ -41,9 +41,8 @@ texenv.filters['shuffle'] = shuffle
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from pymath.expression import Expression
|
||||
exp = Expression("2/4 + 18")
|
||||
print(do_calculus(exp.simplify()))
|
||||
print(texenv.list_templates())
|
||||
texenv.get_template("tpl_bilan.tex")
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue