# Path: bipy/utils.py
# def remove_suffix(filename):
#     filename, extension = os.path.splitext(filename)
#     return filename


from mako.template import Template
from itertools import repeat
from bipy.utils import remove_suffix
from bcbio.distributed.transaction import file_transaction
from bcbio.utils import curdir_tmpdir
import sh
import os
import abc
import shutil
"""reporting.py provides classes to inherit from to provide output
reports for stages of pipelines.

"""



def safe_latex(to_fix):
    """Escape characters that make LaTeX unhappy.
    Lifted from Brad Chapman (bcbio)
    """
    chars = ["%", "_", "&", "#"]
    for char in chars:
        to_fix = to_fix.replace(char, "\\%s" % char)
    return to_fix


class LatexPdf(object):
    """Generates a PDF document from a list of sections.
    usage: generate_pdf(sections)"""

    @classmethod
    def generate_pdf(self, sections=None, out_file=None):
        out_tmpl = Template(self._base_template)
        if not out_file:
            latex_file = "latex.tex"
            out_file = "latex.pdf"
        else:

# Path: bipy/utils.py
# def remove_suffix(filename):
#     filename, extension = os.path.splitext(filename)
#     return filename


# Path: bipy/toolbox/reporting.py
from mako.template import Template
from itertools import repeat
from bipy.utils import remove_suffix
from bcbio.distributed.transaction import file_transaction
from bcbio.utils import curdir_tmpdir
import sh
import os
import abc
import shutil

"""reporting.py provides classes to inherit from to provide output
reports for stages of pipelines.

"""



def safe_latex(to_fix):
    """Escape characters that make LaTeX unhappy.
    Lifted from Brad Chapman (bcbio)
    """
    chars = ["%", "_", "&", "#"]
    for char in chars:
        to_fix = to_fix.replace(char, "\\%s" % char)
    return to_fix


class LatexPdf(object):
    """Generates a PDF document from a list of sections.
    usage: generate_pdf(sections)"""

    @classmethod
    def generate_pdf(self, sections=None, out_file=None):
        out_tmpl = Template(self._base_template)
        if not out_file:
            latex_file = "latex.tex"
            out_file = "latex.pdf"
        else:

            latex_file = remove_suffix(out_file) + ".tex"