2019-12-23 17:12:58 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
|
|
|
|
import click
|
2020-08-20 13:06:12 +00:00
|
|
|
import logging
|
2022-04-09 05:30:13 +00:00
|
|
|
|
2022-05-04 19:16:27 +00:00
|
|
|
from bopytex.service import main
|
2020-08-20 13:06:12 +00:00
|
|
|
|
|
|
|
formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s")
|
|
|
|
steam_handler = logging.StreamHandler()
|
|
|
|
steam_handler.setLevel(logging.DEBUG)
|
|
|
|
steam_handler.setFormatter(formatter)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
logger.addHandler(steam_handler)
|
2019-12-23 17:12:58 +00:00
|
|
|
|
2020-11-03 09:23:18 +00:00
|
|
|
|
2019-12-23 17:12:58 +00:00
|
|
|
@click.command()
|
|
|
|
@click.argument(
|
|
|
|
"template",
|
|
|
|
type=click.Path(exists=True),
|
|
|
|
nargs=1,
|
|
|
|
)
|
|
|
|
@click.option(
|
|
|
|
"-w",
|
|
|
|
"--working-dir",
|
2022-04-09 05:30:13 +00:00
|
|
|
default=".",
|
2019-12-23 17:12:58 +00:00
|
|
|
type=click.Path(exists=True),
|
|
|
|
)
|
|
|
|
@click.option(
|
|
|
|
"-s",
|
|
|
|
"--students-csv",
|
|
|
|
type=str,
|
|
|
|
default="",
|
|
|
|
help="CSV containing list of students names",
|
|
|
|
)
|
|
|
|
@click.option(
|
2022-05-04 16:00:54 +00:00
|
|
|
"-n",
|
|
|
|
"--no-compile",
|
2022-04-09 19:53:00 +00:00
|
|
|
is_flag=True,
|
|
|
|
default=False,
|
2022-05-04 16:00:54 +00:00
|
|
|
help="Do not compile source code",
|
2019-12-23 17:12:58 +00:00
|
|
|
)
|
|
|
|
@click.option(
|
2022-05-04 16:00:54 +00:00
|
|
|
"-d",
|
|
|
|
"--dirty",
|
2019-12-23 17:12:58 +00:00
|
|
|
is_flag=True,
|
|
|
|
default=False,
|
2022-05-04 16:00:54 +00:00
|
|
|
help="Do not clean after compilation",
|
2019-12-23 17:12:58 +00:00
|
|
|
)
|
|
|
|
@click.option(
|
2022-04-09 05:30:13 +00:00
|
|
|
"-q",
|
|
|
|
"--quantity_subjects",
|
2019-12-23 17:12:58 +00:00
|
|
|
type=int,
|
|
|
|
default=1,
|
2022-04-09 05:30:13 +00:00
|
|
|
help="The quantity of subjects to make",
|
2019-12-23 17:12:58 +00:00
|
|
|
)
|
|
|
|
@click.option(
|
|
|
|
"-j",
|
|
|
|
"--no-join",
|
|
|
|
is_flag=True,
|
|
|
|
default=False,
|
|
|
|
help="Do not join pdfs to a single pdf and remove individuals",
|
|
|
|
)
|
|
|
|
@click.option(
|
|
|
|
"-O",
|
|
|
|
"--only-corr",
|
|
|
|
is_flag=True,
|
|
|
|
default=False,
|
2020-11-03 09:23:18 +00:00
|
|
|
help="Activate correction and compile only from existing subjects",
|
2019-12-23 17:12:58 +00:00
|
|
|
)
|
|
|
|
@click.option(
|
2022-05-05 12:35:01 +00:00
|
|
|
"-C",
|
2019-12-23 17:12:58 +00:00
|
|
|
"--corr",
|
|
|
|
is_flag=True,
|
|
|
|
default=False,
|
|
|
|
help="Create and compile correction while making subjects",
|
|
|
|
)
|
2022-05-05 12:35:01 +00:00
|
|
|
@click.option(
|
|
|
|
"-c",
|
|
|
|
"--configfile",
|
|
|
|
type=str,
|
|
|
|
default="bopyptex_config.py",
|
|
|
|
help="Config file path",
|
|
|
|
)
|
2019-12-23 17:12:58 +00:00
|
|
|
def new(**options):
|
2022-05-05 12:35:01 +00:00
|
|
|
for message in main(options):
|
2022-05-04 16:00:54 +00:00
|
|
|
try:
|
|
|
|
assert message.status == 0
|
|
|
|
except AssertionError:
|
|
|
|
logger.warning(message)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
logger.info(message.out)
|
2020-08-20 13:06:12 +00:00
|
|
|
|
2019-12-23 17:12:58 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
new()
|
|
|
|
|
|
|
|
# -----------------------------
|
|
|
|
# Reglages pour 'vim'
|
|
|
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
|
|
|
# cursor: 16 del
|