def process_inputs(tex_source, root_dir=None):
logger = logging.getLogger(__name__)<EOL>def _sub_line(match):<EOL><INDENT>"""<STR_LIT>"""<EOL>fname = match.group('<STR_LIT:filename>')<EOL>if not fname.endswith('<STR_LIT>'):<EOL><INDENT>full_fname = "<STR_LIT:.>".join((fname, '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>full_fname = fname<EOL><DEDENT>full_path = os.path.abspath(os.path.join(root_dir, full_fname))<EOL>try:<EOL><INDENT>included_source = read_tex_file(full_path, root_dir=root_dir)<EOL><DEDENT>except IOError:<EOL><INDENT>logger.error("<STR_LIT>".format(full_path))<EOL>raise<EOL><DEDENT>else:<EOL><INDENT>return included_source<EOL><DEDENT><DEDENT>tex_source = input_include_pattern.sub(_sub_line, tex_source)<EOL>return tex_source<EOL>
r"""Insert referenced TeX file contents (from  ``\input`` and ``\include``
    commands) into the source.

    Parameters
    ----------
    tex_source : `str`
        TeX source where referenced source files will be found and inserted.
    root_dir : `str`, optional
        Name of the directory containing the TeX project's root file. Files
        referenced by TeX ``\input`` and ``\include`` commands are relative to
        this directory. If not set, the current working directory is assumed.

    Returns
    -------
    tex_source : `str`
        TeX source.

    See also
    --------
    `read_tex_file`
        Recommended API for reading a root TeX source file and inserting
        referenced files.