def insertSelectionInTemplate(fontSelectionList, fontTemplateFile, outputFile):
    for fontSelectionEntries in fontSelectionList:
        # create fontString for output filename
        for line in fontSelectionEntries:
            # search for \fontdesc and change its string, if necessary
            # Example: \renewcommand{\fontdesc}{Charter, Bera Sans, Luxi Mono}
            match = re.search(r"\\renewcommand{\\fontdesc}{(.+)}", line)
            if match:
                fontString = match.group(1)
                fontString = fontString.replace(', ', '-')
                fontString = fontString.replace(',', '-')
        # Open output file with changed font string
        # Insert all lines of fontSelectionEntries to the template positions
        outputFileChanged = outputFile + ' - ' + fontString + '.tex'
        print ('Creating font sample: ' + outputFileChanged)
        with open(fontTemplateFile, 'r') as parseFileHandle:
            with open(outputFileChanged, 'w') as outputFileHandle:
                for lineParse in parseFileHandle:
                    # write line to output
                    if lineParse.startswith('%%?'):
                        # write all lines of fontSelectionEntries to outputFileHandle
                        index = lineParse.find('<*preamblefontcode*>')
                        if index >= 0:
                            for fontline in fontSelectionEntries:
                                outputFileHandle.write(fontline)
                        # write all lines of fontSelectionEntries to outputFileHandle
                        # except the line with 'fontdesc'
                        index = lineParse.find('<*fontcode*>')
                        if index >= 0:
                            for fontline in fontSelectionEntries:
                                index = fontline.find('fontdesc')
                                if index < 0:
                                    outputFileHandle.write(fontline)
                    else:
                        outputFileHandle.write(lineParse)
        # get path and file of full file name
        newPath, filename = os.path.split(outputFileChanged)
        # compile file in folder of file
        oldPath = os.getcwd()
        os.chdir(newPath)
        tex.callSystemCommand(['pdflatex', '-interaction=nonstopmode', '-shell-escape', filename])
        # executeCode = 'pdflatex.exe -interaction=nonstopmode  -shell-escape "' \
        #              + filename + '"'
        # os.system(executeCode)

        # move pdf to different folder "fonts/"
        filenamepdf = filename.replace('.tex', '.pdf')
        if os.path.isfile(filenamepdf):
            shutil.move(filenamepdf, 'fonts/' + filenamepdf)
        else:
            print('file ' + filenamepdf + ' not found, aborting!')
            sys.exit()

        # remove all aux files
        tex.cleanupAuxFiles(filename.replace('.tex', '.'))
        tex.unfailingRemoveFile(filename)
        tex.unfailingRemoveFile(filename.replace('.tex', '.log'))
        # change to previous folder
        os.chdir(oldPath)
def compileLaTeXPackage(package):
    # move to path of package
    newPath, filename = os.path.split(package)
    oldPath = os.getcwd()
    if os.path.exists(newPath):
        os.chdir(newPath)
    # call pdflatex on package
    executeCode = 'pdflatex' \
                + ' -interaction=nonstopmode  ' \
                + '-shell-escape "' \
                + filename + '"'
    result = os.system(executeCode)
    print ('Execution returns: ' + result)
    # clean up temp files
    tex.cleanupAuxFiles(filename.replace('.tex', '.'))
    # move back to original path
    os.chdir(oldPath)
def compileLaTeXPackage(package):
    # move to path of package
    newPath, filename = os.path.split(package)
    oldPath = os.getcwd()
    if os.path.exists(newPath):
        os.chdir(newPath)
    # call pdflatex on package
    executeCode = 'pdflatex' \
                + ' -interaction=nonstopmode  ' \
                + '-shell-escape "' \
                + filename + '"'
    result = os.system(executeCode)
    print('Execution returns: ' + result)
    # clean up temp files
    tex.cleanupAuxFiles(filename.replace('.tex', '.'))
    # move back to original path
    os.chdir(oldPath)
def compileDTXPackage(package):
    # move to path of package
    newPath, filename = os.path.split(package)
    oldPath = os.getcwd()
    if os.path.exists(newPath):
        os.chdir(newPath)
    # base filename
    packageName = filename.replace('.dtx', '')
    print ('----> creating package ' + packageName + ' ---' )
    # call pdflatex on package.ins
    executeCode = 'pdflatex -shell-escape "' + packageName + '.ins"'
    print (executeCode)
    result = os.system(executeCode)

    # call pdflatex on package.dtx
    executeCode = 'pdflatex -shell-escape "' + packageName + '.dtx"'
    print (executeCode)
    result = os.system(executeCode)

    # call makeindex
    executeCode = 'makeindex -s gind.ist "' + packageName + '.idx"'
    print (executeCode)
    result = os.system(executeCode)

    # call pdflatex on package.dtx
    executeCode = 'pdflatex -shell-escape "' + packageName + '.dtx"'
    print (executeCode)
    result = os.system(executeCode)

    # call pdflatex on package.dtx
    executeCode = 'pdflatex -shell-escape "' + packageName + '.dtx"'
    print (executeCode)
    result = os.system(executeCode)

    # clean up temp files
    print ('----> cleaning up temp files')
    tex.cleanupAuxFiles(filename.replace('.dtx', '.'))
    # move back to original path
    os.chdir(oldPath)
def compileDTXPackage(package):
    # move to path of package
    newPath, filename = os.path.split(package)
    oldPath = os.getcwd()
    if os.path.exists(newPath):
        os.chdir(newPath)
    # base filename
    packageName = filename.replace('.dtx', '')
    print('----> creating package ' + packageName + ' ---')
    # call pdflatex on package.ins
    executeCode = 'pdflatex -shell-escape "' + packageName + '.ins"'
    print(executeCode)
    result = os.system(executeCode)

    # call pdflatex on package.dtx
    executeCode = 'pdflatex -shell-escape "' + packageName + '.dtx"'
    print(executeCode)
    result = os.system(executeCode)

    # call makeindex
    executeCode = 'makeindex -s gind.ist "' + packageName + '.idx"'
    print(executeCode)
    result = os.system(executeCode)

    # call pdflatex on package.dtx
    executeCode = 'pdflatex -shell-escape "' + packageName + '.dtx"'
    print(executeCode)
    result = os.system(executeCode)

    # call pdflatex on package.dtx
    executeCode = 'pdflatex -shell-escape "' + packageName + '.dtx"'
    print(executeCode)
    result = os.system(executeCode)

    # clean up temp files
    print('----> cleaning up temp files')
    tex.cleanupAuxFiles(filename.replace('.dtx', '.'))
    # move back to original path
    os.chdir(oldPath)
Пример #6
0
def main():
    print("--- clean up main folder before compilation ---")
    tex.unfailingRemoveFile('../template/TemplateDocumentation-figure*.log')
    tex.cleanupRecursiveAuxFiles('../template/', '*.aux')
    texfile = '../template/LaTeXTemplate.'
    tex.cleanupAuxFiles(texfile)
    texfile = '../template/TemplateDocumentation.'
    tex.cleanupAuxFiles(texfile)

    # print ("--- Creation of Packages ---")
    # importCreatePackages.main()

    # print ("--- Copy Packages ---")
    # copyPackages()

    print("--- Create Font Examaples ---")
    # importFontExamples.main()

    print("--- fill doc-code.tex ---")
    # importInsertPrintCode.main()

    print("--- compiling LaTeXTemplate.tex ---")
    texfile = '../template/LaTeXTemplate.tex'
    tex.compileLatexDocument(texfile)
    copyTeXFile(texfile)

    print("--- compiling TemplateDocumentation.tex ---")
    texfile = '../template/TemplateDocumentation.tex'
    tex.compileLatexDocument(texfile)
    copyFile(texfile.replace('.tex', '.pdf'), '')
    tex.cleanupRecursiveAuxFiles('../template/', '*.aux')
    tex.unfailingRemoveFile('../template/content/demo/democode.tex')
    tex.unfailingRemoveFile('../template/content/longtable.tex')
    tex.unfailingRemoveFile('../template/demo-glossaries-*')

    copyFile('bib/BibtexDatabase.bib', 'bib')
    copyFile('bib/publications.bib', 'bib')
    copyFile('content/template/latextutorial.tex', 'content/template/')
    copyFile('content/*.tex', 'content')
    copyFile('fonts/*.tex', 'fonts')
    copyFile('images/*', 'images')
    copyFile('macros/*', 'macros')
    copyFile('preamble/commands.tex', 'preamble')
    copyFile('preamble/makeCommands.tex', 'preamble')
    copyFile('preamble/fix*.tex', 'preamble')
    copyFile('preamble/listings*.tex', 'preamble')
    copyFile('preamble/packages*.tex', 'preamble')
    copyFile('preamble/style*.tex', 'preamble')
    copyFile('version.txt', '')
    copyFile('licence.txt', '')
    # copyFile('*.sty', '')

    # zip publish folder

    oldPath = os.getcwd()
    os.chdir('../template/')

    currentDateStr = datetime.datetime.now().strftime("%Y-%m-%d")
    filename = 'latexthesistemplate-' + currentDateStr + '.zip'
    executeCode = 'zip -r ' + filename + ' latexthesistemplate/*'
    print(executeCode)
    result = os.system(executeCode)

    os.chdir(oldPath)
Пример #7
0
def main():
    print ("--- clean up main folder before compilation ---")
    tex.unfailingRemoveFile('../template/TemplateDocumentation-figure*.log')
    tex.cleanupRecursiveAuxFiles('../template/', '*.aux')
    texfile = '../template/LaTeXTemplate.'
    tex.cleanupAuxFiles(texfile)
    texfile = '../template/TemplateDocumentation.'
    tex.cleanupAuxFiles(texfile)
    # sys.exit()

    print ("--- Creation of Packages ---")
    # importCreatePackages.main()

    print ("--- Copy Packages ---")
    # copyPackages()

    print ("--- Create Font Examaples ---")
    # importFontExamples.main()

    print ("--- fill doc-code.tex ---")
    importInsertPrintCode.main()

    print ("--- compiling LaTeXTemplate.tex ---")
    texfile = '../template/LaTeXTemplate.tex'
    tex.compileLatexDocument(texfile)
    copyTeXFile(texfile)

    print ("--- compiling TemplateDocumentation.tex ---")
    texfile = '../template/TemplateDocumentation.tex'
    tex.compileLatexDocument(texfile)
    copyFile(texfile.replace('.tex', '.pdf'), '')
    tex.cleanupRecursiveAuxFiles('../template/', '*.aux')
    tex.unfailingRemoveFile('../template/content/demo/democode.tex')
    tex.unfailingRemoveFile('../template/content/longtable.tex')
    tex.unfailingRemoveFile('../template/demo-glossaries-*')



    copyFile('bib/BibtexDatabase.bib', 'bib')
    copyFile('bib/publications.bib', 'bib')
    copyFile('content/template/latextutorial.tex', 'content/template/')
    copyFile('content/*.tex', 'content')
    copyFile('fonts/*.tex', 'fonts')
    copyFile('images/*', 'images')
    copyFile('macros/*', 'macros')
    copyFile('preamble/commands.tex', 'preamble')
    copyFile('preamble/makeCommands.tex', 'preamble')
    copyFile('preamble/fix*.tex', 'preamble')
    copyFile('preamble/listings*.tex', 'preamble')
    copyFile('preamble/packages*.tex', 'preamble')
    copyFile('preamble/style*.tex', 'preamble')
    copyFile('version.txt', '')
    copyFile('licence.txt', '')
    # copyFile('*.sty', '')


    # zip publish folder

    oldPath = os.getcwd()
    os.chdir('../template/')

    currentDateStr = datetime.datetime.now().strftime("%Y-%m-%d")
    filename = 'latexthesistemplate-' + currentDateStr + '.zip'
    executeCode = 'zip -r ' +  filename + ' latexthesistemplate/*'
    print (executeCode)
    result = os.system(executeCode)

    os.chdir(oldPath)
Пример #8
0
def insertSelectionInTemplate(fontSelectionList, fontTemplateFile, outputFile):
    for fontSelectionEntries in fontSelectionList:
        # create fontString for output filename
        for line in fontSelectionEntries:
            # search for \fontdesc and change its string, if necessary
            # Example: \renewcommand{\fontdesc}{Charter, Bera Sans, Luxi Mono}
            match = re.search(r"\\renewcommand{\\fontdesc}{(.+)}", line)
            if match:
                fontString = match.group(1)
                fontString = fontString.replace(', ', '-')
                fontString = fontString.replace(',', '-')
        # Open output file with changed font string
        # Insert all lines of fontSelectionEntries to the template positions
        outputFileChanged = outputFile + ' - ' + fontString + '.tex'
        print('Creating font sample: ' + outputFileChanged)
        with open(fontTemplateFile, 'r') as parseFileHandle:
            with open(outputFileChanged, 'w') as outputFileHandle:
                for lineParse in parseFileHandle:
                    # write line to output
                    if lineParse.startswith('%%?'):
                        # write all lines of fontSelectionEntries to outputFileHandle
                        index = lineParse.find('<*preamblefontcode*>')
                        if index >= 0:
                            for fontline in fontSelectionEntries:
                                outputFileHandle.write(fontline)
                        # write all lines of fontSelectionEntries to outputFileHandle
                        # except the line with 'fontdesc'
                        index = lineParse.find('<*fontcode*>')
                        if index >= 0:
                            for fontline in fontSelectionEntries:
                                index = fontline.find('fontdesc')
                                if index < 0:
                                    outputFileHandle.write(fontline)
                    else:
                        outputFileHandle.write(lineParse)
        # get path and file of full file name
        newPath, filename = os.path.split(outputFileChanged)
        # compile file in folder of file
        oldPath = os.getcwd()
        os.chdir(newPath)
        tex.callSystemCommand([
            'pdflatex', '-interaction=nonstopmode', '-shell-escape', filename
        ])
        # executeCode = 'pdflatex.exe -interaction=nonstopmode  -shell-escape "' \
        #              + filename + '"'
        # os.system(executeCode)

        # move pdf to different folder "fonts/"
        filenamepdf = filename.replace('.tex', '.pdf')
        if os.path.isfile(filenamepdf):
            shutil.move(filenamepdf, 'fonts/' + filenamepdf)
        else:
            print('file ' + filenamepdf + ' not found, aborting!')
            sys.exit()

        # remove all aux files
        tex.cleanupAuxFiles(filename.replace('.tex', '.'))
        tex.unfailingRemoveFile(filename)
        tex.unfailingRemoveFile(filename.replace('.tex', '.log'))
        # change to previous folder
        os.chdir(oldPath)