示例#1
0
    return pie

def createTeXfile(pie, filename='piechart.tex',title='Título',author='Melissa', date=''):
    with open(filename,'w') as results:
        print >>results, '\\documentclass{article}'
        print >>results, '\\usepackage{calc}'
        print >>results, '\\usepackage{tikz}'
        print >>results, '\\usepackage[utf8]{inputenc}'
        print >>results, '\\usepackage[T1]{fontenc}'
        print >>results, '\\usepackage{palatino}'
        print >>results, '\\title{', title, '}'
        print >>results, '\\author{', author, '}'
        print >>results, '\\date{', date, '}'
        print >>results, '\\begin{document}'
        print >>results, '\\maketitle'
        print >>results, pie
        print >>results, '\\end{document}'
    
if __name__ == '__main__':
    dados = {'Debian':15, 'Fedora':6, 'Slackware':16, 'Gentoo':5, 'OpenSUSE': 7, 'Chakra':5}
    # Escrever o resultado em um arquivo .tex
    titulo = 'Distribuições Linux entre participantes do SciPy-LA 2016'
    autora = 'Melissa'
    # Criar piechart
    pie = createPiechart(dados)
    # Criar arquivo basico
    createTeXfile(pie, 'piechart.tex',titulo, autora)
    # Compilar e mostrar o pdf resultante.
    latextools.compile('piechart','True')
    latextools.cleanup('piechart')
示例#2
0
        print >> results, '\\date{', date, '}'
        print >> results, '\\begin{document}'
        print >> results, '\\maketitle'
        print >> results, str
        print >> results, '\\end{document}'


if __name__ == '__main__':

    if sys.platform.startswith('linux'):
        # Linux-specific code here...
        str = "{\\centering \\textsc{You are using Linux!}}\\\\ Cool! We're good to go...\\\\ \\paragraph*{Installation} Just run this command as superuser (\\emph{root}):\\\\ \\centering \\verb+# pip install scipy+"
    elif sys.platform.startswith('darwin'):
        # Mac OS code
        str = "Ok, just use a linux virtual machine..."
    elif sys.platform.startswith('win'):
        # Windows?
        str = "Really. No chance I'm supporting this for windows. You're on your own. Sorry"
    else:
        str = "You must really know what you're doing, so don't let me stop you."

    # Escrever o resultado em um arquivo .tex
    titulo = 'OS check'
    autora = 'Melissa'
    filename = 'documentationex'
    # Criar arquivo basico
    createTeXfile(str, filename + '.tex', titulo, autora)
    # Compilar e mostrar o pdf resultante.
    latextools.compile(filename, 'True')
    latextools.cleanup(filename)
            # Codigo LaTeX
            print >> results, '\\documentclass{article}'
            print >> results, '\\usepackage[utf8]{inputenc}'
            print >> results, '\\usepackage{palatino}'
            print >> results, '\\usepackage{verbatim}'
            print >> results, '\\usepackage{longtable}'
            print >> results, '\\begin{document}'
            print >> results, '\\section*{Conteúdo do diretório ', dirname, '}'
            print >> results, '\\begin{center}'
            print >> results, '\\begin{longtable}{|l|}\\hline'
            print >> results, '\\hline Nome do arquivo \\\\ \\hline \\endfirsthead'
            for line in output:
                print >> results, '\\verb+', line[:-1], '+\\\\ '
            print >> results, '\\hline'
            print >> results, '\\end{longtable}'
            print >> results, '\\end{center}'
            print >> results, '\\end{document}'


if __name__ == '__main__':
    dirname = sys.argv[1]
    # Criar a listagem do diretorio
    with open('ls.output', 'w') as f:
        subprocess.call(['ls', dirname], stdout=f)

    write_texfile(dirname)
    # Compilar e mostrar o pdf resultante.
    latextools.compile('ls', 'True', 2)
    # Compilamos 2 vezes pois o pacote longtable às vezes precisa de duas compilações para acertar a largura da tabela final.
    latextools.cleanup('ls')
    # Escrever o resultado em um arquivo .tex
    with open(filename,'r+') as f:
        old = f.readlines()
        if old[0][1:4] == 'def':
            offset = 4
        else:
            offset = 0
        f.seek(0)
        f.write('\\def\\disciplina {'+disciplina+'}\n\\def\\turma {'+turma+'}\n\\def\\semestre {'+semestre+'}\n\\def\\numerodealunos {'+str(numerodealunos)+'}\n')
        f.writelines(old[offset:])

if __name__ == '__main__':

    locale.setlocale(locale.LC_NUMERIC, "pt_BR.UTF-8")

    df = pd.read_csv('notas.csv', sep=';', index_col=0)
    df = df.applymap(lambda x: '0' if x in ['-'] else x)
    df = df.applymap(locale.atof)
    
    # Gerar figuras
    numalunos = len(df.index)
    mediasfinais, aprovados, reprovados = draw_plots(df)

    # Escrever informações sobre a turma
    info = ['Calculo A', '00000', '2016.1', numalunos]
    write_texfile('relatorio.tex', info)

    # Compilar e mostrar o pdf resultante.
    latextools.compile('relatorio', 'True', 2)
    latextools.cleanup('relatorio')
示例#5
0
        print >> results, '\\usepackage[T1]{fontenc}'
        print >> results, '\\usepackage{palatino}'
        print >> results, '\\title{', title, '}'
        print >> results, '\\author{', author, '}'
        print >> results, '\\date{', date, '}'
        print >> results, '\\begin{document}'
        print >> results, '\\maketitle'
        print >> results, pie
        print >> results, '\\end{document}'


if __name__ == '__main__':
    dados = {
        'Debian': 15,
        'Fedora': 6,
        'Slackware': 16,
        'Gentoo': 5,
        'OpenSUSE': 7,
        'Chakra': 5
    }
    # Escrever o resultado em um arquivo .tex
    titulo = 'Distribuições Linux entre participantes do SciPy-LA 2016'
    autora = 'Melissa'
    # Criar piechart
    pie = createPiechart(dados)
    # Criar arquivo basico
    createTeXfile(pie, 'piechart.tex', titulo, autora)
    # Compilar e mostrar o pdf resultante.
    latextools.compile('piechart', 'True')
    latextools.cleanup('piechart')
示例#6
0
    print "Error %s:" % e.args[0]
    sys.exit(1)

finally:
    if con:
        con.close()

# Gerar um certificado para cada nome.
for row in data:
    f = open(filename + '.tex', 'r+')
    old = f.readlines()
    if old[0][1:4] == 'def':
        offset = 1
    else:
        offset = 0
    f.seek(0)
    f.write('\\def\\name {' + row[0] + '}\n')
    f.writelines(old[offset:])
    f.close()

    # Compilar arquivo LaTeX
    latextools.compile(filename)
    # Movendo cada certificado para que o nome do arquivo
    # contenha o nome da beneficiada.
    call([
        'mv', filename + '.pdf',
        filename + '_' + row[0].replace(' ', '_') + '.pdf'
    ])

# Fim!
    data = cur.fetchall()

except sqlite3.Error, e:
    print "Error %s:" % e.args[0]
    sys.exit(1)

finally:
    if con:
        con.close()

# Gerar um certificado para cada nome.
for row in data:
    f = open(filename+'.tex','r+')
    old = f.readlines()
    if old[0][1:4] == 'def':
        offset = 1
    else:
        offset = 0
    f.seek(0)
    f.write('\\def\\name {'+row[0]+'}\n')
    f.writelines(old[offset:])
    f.close()

    # Compilar arquivo LaTeX
    latextools.compile(filename)
    # Movendo cada certificado para que o nome do arquivo
    # contenha o nome da beneficiada.
    call(['mv',filename+'.pdf', filename+'_'+row[0].replace(' ','_')+'.pdf'])

# Fim!
        if old[0][1:4] == 'def':
            offset = 4
        else:
            offset = 0
        f.seek(0)
        f.write('\\def\\disciplina {' + disciplina + '}\n\\def\\turma {' +
                turma + '}\n\\def\\semestre {' + semestre +
                '}\n\\def\\numerodealunos {' + str(numerodealunos) + '}\n')
        f.writelines(old[offset:])


if __name__ == '__main__':

    locale.setlocale(locale.LC_NUMERIC, "pt_BR.UTF-8")

    df = pd.read_csv('notas.csv', sep=';', index_col=0)
    df = df.applymap(lambda x: '0' if x in ['-'] else x)
    df = df.applymap(locale.atof)

    # Gerar figuras
    numalunos = len(df.index)
    mediasfinais, aprovados, reprovados = draw_plots(df)

    # Escrever informações sobre a turma
    info = ['Calculo A', '00000', '2016.1', numalunos]
    write_texfile('relatorio.tex', info)

    # Compilar e mostrar o pdf resultante.
    latextools.compile('relatorio', 'True', 2)
    latextools.cleanup('relatorio')
        print >>results, '\\author{', author, '}'
        print >>results, '\\date{', date, '}'
        print >>results, '\\begin{document}'
        print >>results, '\\maketitle'
        print >>results, str
        print >>results, '\\end{document}'
    
if __name__ == '__main__':

    if sys.platform.startswith('linux'):
        # Linux-specific code here...
        str = "{\\centering \\textsc{You are using Linux!}}\\\\ Cool! We're good to go...\\\\ \\paragraph*{Installation} Just run this command as superuser (\\emph{root}):\\\\ \\centering \\verb+# pip install scipy+"
    elif sys.platform.startswith('darwin'):
        # Mac OS code
        str = "Ok, just use a linux virtual machine..."
    elif sys.platform.startswith('win'):
        # Windows?
        str = "Really. No chance I'm supporting this for windows. You're on your own. Sorry"
    else:
        str = "You must really know what you're doing, so don't let me stop you."
    
    # Escrever o resultado em um arquivo .tex
    titulo = 'OS check'
    autora = 'Melissa'
    filename = 'documentationex'
    # Criar arquivo basico
    createTeXfile(str, filename+'.tex',titulo, autora)
    # Compilar e mostrar o pdf resultante.
    latextools.compile(filename, 'True')
    latextools.cleanup(filename)
示例#10
0
            print >>results, '%& -output-directory=',dirname
            # Codigo LaTeX
            print >>results, '\\documentclass{article}'
            print >>results, '\\usepackage[utf8]{inputenc}'
            print >>results, '\\usepackage{palatino}'
            print >>results, '\\usepackage{verbatim}'
            print >>results, '\\usepackage{longtable}'
            print >>results, '\\begin{document}'
            print >>results, '\\section*{Conteúdo do diretório ',dirname,'}'
            print >>results, '\\begin{center}'
            print >>results, '\\begin{longtable}{|l|}\\hline'
            print >>results, '\\hline Nome do arquivo \\\\ \\hline \\endfirsthead'
            for line in output:
                print >>results, '\\verb+',line[:-1],'+\\\\ '
            print >>results,'\\hline'
            print >>results,'\\end{longtable}'
            print >>results,'\\end{center}'
            print >>results,'\\end{document}'

if __name__ == '__main__':
    dirname = sys.argv[1]
    # Criar a listagem do diretorio
    with open('ls.output', 'w') as f:
        subprocess.call(['ls',dirname], stdout=f)

    write_texfile(dirname)
    # Compilar e mostrar o pdf resultante.
    latextools.compile('ls', 'True',2)
    # Compilamos 2 vezes pois o pacote longtable às vezes precisa de duas compilações para acertar a largura da tabela final.
    latextools.cleanup('ls')