Beispiel #1
0
def surink_komandos_statistika(String,Straipsnis='Unnamed',komanda='\\usepackage'):
    '''Perdavus texinio failo turini, ir straipsnio pavadinima,
    surenkama nurodyta komanda.'''
    def check_this(cmd):
        nonlocal komanda
        if cmd[1]==komanda:
            return komanda
        else:
            return None    
        
    direktorija=os.path.join(my_stats_dir,komanda[1:]+'_stat/')
    ensure_dir(direktorija)          
    global stat
        
    with open(direktorija+komanda[1:]+".txt",'wt') as output:
        output.write('*'*60)
        output.write("Komandos {} statistika conv_dv direktorijoje".format(komanda))
        output.write('*'*60) 

    for i,char in enumerate(String):
        if char=='\\' and CMDparsing.metachar(i,String):
            cmd=CMDparsing.collect_full_command(i,String)
            if check_this(cmd):
                tmp=komanda
                tmp=tmp+''.join([k for k in cmd[2] if k])
                if stat.get(tmp,None): 
                    stat[tmp][0]+=1
                    stat[tmp][1].append(Straipsnis)
                else:stat[tmp]=[1,[Straipsnis]]
    return 
Beispiel #2
0
def surink_komandas(String,Straipsnis='Unnamed',komanda='\\newcommand'):
    '''Perdavus texinio failo turini, ir straipsnio pavadinima,
    surenkama nurodyta komanda.'''
    for i,char in enumerate(String):
        if char=='\\' and CMDparsing.metachar(i,String):
            cmd=CMDparsing.collect_full_command(i,String)
            if cmd[1]==komanda:
                direktorija=os.path.join(my_stats_dir,komanda[1:]+'/')
                ensure_dir(direktorija)
                with open(direktorija+komanda[1:]+".txt",'at') as output:
                    output.write('\n'+'='*50+'\n')
                    output.write(Straipsnis+'\n'+'Parsed:\n')
                    output.write(cmd[1])
                    for arg in cmd[2]:
                        if arg: output.write(arg)
                    output.write('\n'+'-'*50+'\n'+'Orig:\n')
                    output.write(cmd[3])