125 lines
3.5 KiB
Python
125 lines
3.5 KiB
Python
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
import logging
|
|
|
|
# création de l'objet logger qui va nous servir à écrire dans les logs
|
|
logger = logging.getLogger("generate_bilan")
|
|
# 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')
|
|
steam_handler = logging.StreamHandler()
|
|
steam_handler.setLevel(logging.DEBUG)
|
|
steam_handler.setFormatter(formatter)
|
|
logger.addHandler(steam_handler)
|
|
|
|
|
|
import optparse
|
|
import os
|
|
from path import Path
|
|
import sys
|
|
|
|
|
|
def main():
|
|
parser = optparse.OptionParser()
|
|
parser.add_option("-c",
|
|
"--classe",
|
|
action="store",
|
|
type="string",
|
|
dest="classe",
|
|
help="The classe")
|
|
parser.add_option("-e",
|
|
"--evaluation",
|
|
action="store",
|
|
type="string",
|
|
dest="eval",
|
|
help="The evaluation name.")
|
|
parser.add_option("-t",
|
|
"--term",
|
|
action="store",
|
|
type="int",
|
|
dest="term",
|
|
help="The term number.")
|
|
parser.add_option("-p",
|
|
"--path",
|
|
action="store",
|
|
type="string",
|
|
dest="path",
|
|
default=Path("./"),
|
|
help="Path where xlsx are stored")
|
|
parser.add_option("-T",
|
|
"--template",
|
|
action="store",
|
|
type="string",
|
|
dest="template",
|
|
help="The template file")
|
|
parser.add_option("-d",
|
|
"--debug",
|
|
action="store_true",
|
|
dest="debug_level",
|
|
help="Enable debug")
|
|
parser.add_option("-l",
|
|
"--list",
|
|
action="store_true",
|
|
dest="list",
|
|
help="List classe and possible bilan")
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
if options.debug_level:
|
|
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)
|
|
|
|
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
|
|
if options.template:
|
|
logger.info("Not default template: {}".format(options.template))
|
|
template = options.template
|
|
else:
|
|
template = "tpl_bilan_term.tex"
|
|
|
|
term_bilan(options.classe,
|
|
options.term,
|
|
options.path,
|
|
template)
|
|
|
|
elif options.eval:
|
|
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
|
|
if options.template:
|
|
logger.info("Not default template: {}".format(options.template))
|
|
template = options.template
|
|
else:
|
|
template = "tpl_bilan_eval.tex"
|
|
|
|
eval_bilan(options.classe,
|
|
options.eval,
|
|
options.path,
|
|
template)
|
|
|
|
else:
|
|
logger.error("Not enough arguments. See -h for help")
|
|
sys.exit()
|
|
|
|
|
|
logger.info("À fini")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
# -----------------------------
|
|
# Reglages pour 'vim'
|
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
|
# cursor: 16 del
|