change bilan to report

This commit is contained in:
Benjamin Bertrand 2017-03-07 13:08:50 +03:00
parent b273cb548f
commit 090be7a348
11 changed files with 57 additions and 54 deletions

View File

@ -4,7 +4,7 @@
import logging
# création de l'objet logger qui va nous servir à écrire dans les logs
logger = logging.getLogger("generate_bilan")
logger = logging.getLogger(__name__)
# on met le niveau du logger à DEBUG, comme ça il écrit tout
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s :: %(name)s :: %(levelname)s :: %(message)s')
@ -62,7 +62,7 @@ def main():
"--list",
action="store_true",
dest="list",
help="List classe and possible bilan")
help="List classe and possible reports")
(options, args) = parser.parse_args()
@ -70,23 +70,23 @@ def main():
logger.setLevel(logging.DEBUG)
if options.list:
from .bilan_tools import print_bilan
logger.info("Listing all bilan in {}".format(options.path))
print_bilan(options.path)
from .reports.reports_tools import print_reports
logger.info("Listing all reports in {}".format(options.path))
print_reports(options.path)
elif options.term:
if not options.classe:
logger.error("Need to pass a class with -c. See -h for help")
sys.exit()
logger.info("Creating term {} bilan".format(options.term))
from .term_bilan import term_bilan
logger.info("Creating term {} report".format(options.term))
from .reports.term_reports import term_report
if options.template:
logger.info("Not default template: {}".format(options.template))
template = options.template
else:
template = "tpl_bilan_term.tex"
template = "tpl_reports_term.tex"
term_bilan(options.classe,
term_report(options.classe,
options.term,
options.path,
template)
@ -95,15 +95,15 @@ def main():
if not options.classe:
logger.error("Need to pass a class with -c. See -h for help")
sys.exit()
logger.info("Creating {} bilan".format(options.eval))
from .eval_bilan import eval_bilan
logger.info("Creating {} report".format(options.eval))
from .reports.eval_reports import eval_report
if options.template:
logger.info("Not default template: {}".format(options.template))
template = options.template
else:
template = "tpl_bilan_eval.tex"
template = "tpl_reports_eval.tex"
eval_bilan(options.classe,
eval_report(options.classe,
options.eval,
options.path,
template)

View File

@ -9,7 +9,7 @@ import xlrd
from path import Path
import logging
logger = logging.getLogger("generate_bilan")
logger = logging.getLogger(__name__)
def eval_info(classe, ds_df):
"""TODO: Docstring for build_ds_info.
@ -31,20 +31,20 @@ def build_target_name(classe, evalname, path = Path("./")):
""" Build the path where the .tex will be sored
>>> build_target_name("312", "DS1")
Path('./312/bilan_DS1.tex')
Path('./312/report_DS1.tex')
>>> build_target_name("312", "DS1", Path("plop/"))
Path('plop/312/bilan_DS1.tex')
Path('plop/312/report_DS1.tex')
"""
return Path(path + "/" + classe + "/bilan_" + evalname + ".tex")
return Path(path + "/" + classe + "/report_" + evalname + ".tex")
def eval_bilan(classe, evalname, path = Path('./'), template = "tpl_bilan_eval.tex"):
""" Generate the bilan of a evaluation for a class
def eval_report(classe, evalname, path = Path('./'), template = "tpl_reports_eval.tex"):
""" Generate the report of a evaluation for a class
:param classe: the classe name
:param evalname: name of the evaluation
:param path: path where xlsx are stored
:param template: template for the bilan
:param template: template for the report
"""
ws = get_class_ws(classe, path)
@ -56,10 +56,10 @@ def eval_bilan(classe, evalname, path = Path('./'), template = "tpl_bilan_eval.t
quest_df, exo_df, eval_df = eval_tools.select(quest_df, exo_df, eval_df, evalname)
bilan_info = eval_info(classe, eval_df)
report_info = eval_info(classe, eval_df)
students = eval_tools.students_pov(quest_df, exo_df, eval_df)
datas = {"bilan_info": bilan_info, "students":students,
datas = {"report_info": report_info, "students":students,
"quest_df":quest_df, "exo_df":exo_df, "eval_df":eval_df}
target = build_target_name(classe, evalname, path)

View File

@ -4,7 +4,7 @@
from uuid import uuid4
from path import Path
import logging
logger = logging.getLogger("generate_bilan")
logger = logging.getLogger(__name__)
def includegraphics(fig_ax, document_path="./", fig_path="fig/",
prefix="", scale=1):

View File

@ -8,11 +8,11 @@ import xlrd
from path import Path
import logging
logger = logging.getLogger("generate_bilan")
logger = logging.getLogger(__name__)
def print_bilan_of(classe_ws):
"""TODO: Docstring for list_bilan.
def print_report_of(classe_ws):
"""TODO: Docstring for list_report.
:param arg1: TODO
:returns: TODO
@ -31,8 +31,8 @@ def print_bilan_of(classe_ws):
for t in df['Trimestre'].unique():
print("\t-Trimestre {}".format(t))
def print_bilan(path):
""" List all bilan which can be generate in the directory
def print_reports(path):
""" List all report which can be generate in the directory
:param path: the directory
:returns: TODO
@ -42,7 +42,7 @@ def print_bilan(path):
for c in list_classes(path):
print("Classe de {}".format(c))
ws = get_class_ws(c, path)
print_bilan_of(ws)
print_report_of(ws)
# -----------------------------
# Reglages pour 'vim'

View File

@ -4,10 +4,10 @@
\usepackage{booktabs}
% Title Page
\titre{\Var{bilan_info["Nom"]}}
\titre{\Var{report_info["Nom"]}}
% \seconde \premiereS \PSTMG \TSTMG
\classe{\Var{bilan_info["Classe"]}}
\date{\Var{bilan_info["Date"]}}
\classe{\Var{report_info["Classe"]}}
\date{\Var{report_info["Date"]}}
\begin{document}

View File

@ -1,6 +1,6 @@
%- extends "tpl_bilan.tex"
%- extends "tpl_reports.tex"
% FILENAME: "tpl_bilan_eval.tex
% FILENAME: "tpl_reports_eval.tex
%- block classPOV
\maketitle

View File

@ -1,5 +1,5 @@
%- extends "tpl_bilan.tex"
% FILENAME: "tpl_bilan_term.tex
%- extends "tpl_reports.tex"
% FILENAME: "tpl_reports_term.tex
%- block classPOV
%- endblock
@ -20,7 +20,9 @@
\vfill
%#\Var{conn_df}
%- if not conn_df.empty
\Var{conn_df | parallele_on("Exercice", e["Nom"]) | includegraphics(document_path=directory, scale=0.5)}
%- endif
\vfill
\vfill

View File

@ -9,7 +9,7 @@ import xlrd
from path import Path
import logging
logger = logging.getLogger("generate_bilan")
logger = logging.getLogger(__name__)
def term_info(classe, ds_df):
"""TODO: Docstring for build_ds_info.
@ -29,20 +29,20 @@ def build_target_name(classe, term, path = Path("./")):
""" Build the path where the .tex will be sored
>>> build_target_name("312", "DS1")
Path('./312/bilan_DS1.tex')
Path('./312/report_DS1.tex')
>>> build_target_name("312", "DS1", Path("plop/"))
Path('plop/312/bilan_DS1.tex')
Path('plop/312/report_DS1.tex')
"""
return Path(path + "/{cls}/bilan_T{term}.tex".format(cls=classe, term=term))
return Path(path + "/{cls}/report_T{term}.tex".format(cls=classe, term=term))
def term_bilan(classe, term, path = Path('./'),
template = "tpl_bilan_term.tex"):
""" Generate the bilan of a evaluation for a class
def term_report(classe, term, path = Path('./'),
template = "tpl_reports_term.tex"):
""" Generate the report of a evaluation for a class
:param classe: the classe name
:param evalname: name of the evaluation
:param path: path where xlsx are stored
:param template: template for the bilan
:param template: template for the report
"""
ws = get_class_ws(classe, path)
@ -56,10 +56,10 @@ def term_bilan(classe, term, path = Path('./'),
quest_df, exo_df, eval_df = digest_flat_df(term_df)
conn_df = exo_df[exo_df["Nom"].str.contains('Conn')]
bilan_info = term_info(classe, eval_df)
report_info = term_info(classe, eval_df)
students = term_tools.students_pov(quest_df, exo_df, eval_df)
datas = {"bilan_info": bilan_info, "students":students,
datas = {"report_info": report_info, "students":students,
"quest_df":quest_df, "exo_df":exo_df, "eval_df":eval_df,
"conn_df": conn_df}

View File

@ -5,7 +5,7 @@ import jinja2, os
from .filters import includegraphics
import logging
logger = logging.getLogger("generate_bilan")
logger = logging.getLogger(__name__)
__all__ = ["texenv"]
@ -20,7 +20,7 @@ texenv = jinja2.Environment(
comment_end_string = '}',
line_statement_prefix = '%-',
line_comment_prefix = '%#',
loader = jinja2.ChoiceLoader([jinja2.PackageLoader("notes_tools.generate_bilan", "templates"),
loader = jinja2.ChoiceLoader([jinja2.PackageLoader("notes_tools.reports", "templates"),
jinja2.FileSystemLoader(['./']),
]),
extensions = ['jinja2.ext.do']
@ -37,25 +37,26 @@ texenv.filters['marks_hist'] = marks_hist
texenv.filters['parallele_on'] = parallele_on
def feed_template(target, datas, template):
""" Get the template and feed it to create bilans
""" Get the template and feed it to create reports
:param target: path where the bilan will be saved
:param target: path where the report will be saved
:param datas: dictonnary to feed the template
:param template: the template
"""
logger.info("Getting template {}".format(template))
bilan = texenv.get_template(template)
report = 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, directory=path_to_target))
f.write(report.render(**datas, directory=path_to_target))
logger.info("{} est construit! Ya plus qu'à compiler!".format(target))
if __name__ == '__main__':
print(texenv.list_templates())
texenv.get_template("tpl_bilan.tex")
texenv.get_template("tpl_reports.tex")

View File

@ -18,7 +18,7 @@ setup(name="notes_analysis",
'path.py',
],
entry_points = {
"console_scripts": ['generate_bilan = notes_tools.generate_bilan.__main__:main']
"console_scripts": ['generate_bilan = notes_tools.generate_reports_main:main']
},
zip_safe=False
)