'Function to substitute various values into a user-provided string
Returns a tuple consisting of the string with any substitutions made
and a boolean indicating if any substitutions were made
Provided Values:
$pdf_file           | full path of PDF file
$pdf_file_name      | name of the PDF file
$pdf_file_ext       | extension of the PDF file
$pdf_file_base_name | name of the PDF file without the extension
$pdf_file_path      | full path to directory containing PDF file
$sublime_binary     | full path to the Sublime binary
Forward Sync Only:
$src_file           | full path of the tex file
$src_file_name      | name of the tex file
$src_file_ext       | extension of the tex file
$src_file_base_name | name of the tex file without the extension
$src_file_path      | full path to directory containing tex file
$line               | line to sync to
$col                | column to sync to'

def _replace_vars(self, s, pdf_file, tex_file=None, line='', col=''):

    if (not self.CONTAINS_VARIABLE.search(s)):
        return (s, False)
    sublime_binary = (get_sublime_exe() or '')
    pdf_file_path = os.path.split(pdf_file)[0]
    pdf_file_name = os.path.basename(pdf_file)
    (pdf_file_base_name, pdf_file_ext) = os.path.splitext(pdf_file_name)
    if (tex_file is None):
        src_file = ''
        src_file_path = ''
        src_file_name = ''
        src_file_ext = ''
        src_file_base_name = ''
    else:
        if os.path.isabs(tex_file):
            src_file = tex_file
        else:
            src_file = os.path.normpath(os.path.join(pdf_file_path, tex_file))
        src_file_path = os.path.split(src_file)[0]
        src_file_name = os.path.basename(src_file)
        (src_file_base_name, src_file_ext) = os.path.splitext(src_file_name)
    template = string.Template(s)
    return (template.safe_substitute(pdf_file=pdf_file, pdf_file_path=pdf_file_path, pdf_file_name=pdf_file_name, pdf_file_ext=pdf_file_ext, pdf_file_base_name=pdf_file_base_name, sublime_binary=sublime_binary, src_file=src_file, src_file_path=src_file_path, src_file_name=src_file_name, src_file_ext=src_file_ext, src_file_base_name=src_file_base_name, line=line, col=col), True)
