repytex/repytex/reports/produce_compile.py

44 lines
1.1 KiB
Python
Raw Normal View History

2017-04-17 10:10:20 +00:00
#!/usr/bin/env python
# encoding: utf-8
"""
Producing and compiling reports
"""
from path import Path
import pytex
import logging
#logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
from .filters import includegraphics
pytex.add_filter("includegraphics", includegraphics)
# texenv.filters['includegraphics'] = includegraphics
2017-04-17 12:10:14 +00:00
pytex.add_pkg_loader("repytex.reports", "templates")
2017-04-17 10:10:20 +00:00
def produce_compile(template, datas, target, force=1):
""" Get the template and feed it to create reports
:param target: path where the report will be saved
:param datas: dictonnary to feed the template
:param template: the template
"""
directory = Path(target).dirname()
datas.update({"directory": directory})
pytex.feed(template, datas, target, force)
logger.info(f"{target} has been created")
pytex.pdflatex(target)
logger.info(f"{target} has been compiled")
# pytex.clean()
# logger.info(f"Clean the directory")
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del