Loading label_files.py 0 → 100644 +83 −0 Original line number Diff line number Diff line #!/usr/bin/python3 import argparse import pandas as pd import collections import os import hashlib import yaml import shutil import subprocess modules = {'stereo_','ism_','mc_','spar_','dirac_','masa_','sba_'} # Main routine if __name__ == '__main__': parser = argparse.ArgumentParser(description='Label c-files in IVAS project and estimate size') parser.add_argument('--input', action='store', type=str, help='Input path') parser.add_argument('--output', action='store', type=str, help='Output xlsx file name') args = parser.parse_args() indir = args.input outfile = args.output filesdict = {'EVS':[],'Framework':[],'Apps':[],'Stereo':[],'ISM':[],'Multichannel':[],'SBA':[],'MASA':[],'Utilities':[],'Renderer':[],'EVS Table ROM':[],'IVAS Table ROM':[]} total = 0 for root, dirs, files in os.walk(indir): for filename in files: path = os.path.join(root, filename) if filename.endswith('.c') or filename.endswith('.h'): # Sort files into modules if 'rom' in filename: if 'ivas' in filename: filesdict['IVAS Table ROM'].append(path) else: filesdict['EVS Table ROM'].append(path) else: if 'apps' in path: filesdict['Apps'].append(path) else: if 'lib_util' in path: filesdict['Utilities'].append(path) else: if 'lib_rend' in path: filesdict['Renderer'].append(path) else: if 'ivas' in filename: if [mod for mod in modules if mod in filename]: if 'ivas_stereo_' in filename: filesdict['Stereo'].append(path) if 'ism' in filename: filesdict['ISM'].append(path) if 'masa' in filename: filesdict['MASA'].append(path) if 'mc_' in filename: filesdict['Multichannel'].append(path) if [tag for tag in ['sba','dirac','spar'] if tag in filename]: filesdict['SBA'].append(path) else: filesdict['Framework'].append(path) else: filesdict['EVS'].append(path) columns = ['Path','Size'] with pd.ExcelWriter(outfile) as writer: for mod in filesdict: sheet = {'Path':[],'Size':[]} for file in filesdict[mod]: with open(file,'r') as fp: lines = len(fp.readlines()) sheet['Path'].append(file) sheet['Size'].append(lines) total = total + 1 data = pd.DataFrame(sheet,columns=columns) data.to_excel (writer, sheet_name=mod, index=False) print("Sorted {} files".format(total)) Loading
label_files.py 0 → 100644 +83 −0 Original line number Diff line number Diff line #!/usr/bin/python3 import argparse import pandas as pd import collections import os import hashlib import yaml import shutil import subprocess modules = {'stereo_','ism_','mc_','spar_','dirac_','masa_','sba_'} # Main routine if __name__ == '__main__': parser = argparse.ArgumentParser(description='Label c-files in IVAS project and estimate size') parser.add_argument('--input', action='store', type=str, help='Input path') parser.add_argument('--output', action='store', type=str, help='Output xlsx file name') args = parser.parse_args() indir = args.input outfile = args.output filesdict = {'EVS':[],'Framework':[],'Apps':[],'Stereo':[],'ISM':[],'Multichannel':[],'SBA':[],'MASA':[],'Utilities':[],'Renderer':[],'EVS Table ROM':[],'IVAS Table ROM':[]} total = 0 for root, dirs, files in os.walk(indir): for filename in files: path = os.path.join(root, filename) if filename.endswith('.c') or filename.endswith('.h'): # Sort files into modules if 'rom' in filename: if 'ivas' in filename: filesdict['IVAS Table ROM'].append(path) else: filesdict['EVS Table ROM'].append(path) else: if 'apps' in path: filesdict['Apps'].append(path) else: if 'lib_util' in path: filesdict['Utilities'].append(path) else: if 'lib_rend' in path: filesdict['Renderer'].append(path) else: if 'ivas' in filename: if [mod for mod in modules if mod in filename]: if 'ivas_stereo_' in filename: filesdict['Stereo'].append(path) if 'ism' in filename: filesdict['ISM'].append(path) if 'masa' in filename: filesdict['MASA'].append(path) if 'mc_' in filename: filesdict['Multichannel'].append(path) if [tag for tag in ['sba','dirac','spar'] if tag in filename]: filesdict['SBA'].append(path) else: filesdict['Framework'].append(path) else: filesdict['EVS'].append(path) columns = ['Path','Size'] with pd.ExcelWriter(outfile) as writer: for mod in filesdict: sheet = {'Path':[],'Size':[]} for file in filesdict[mod]: with open(file,'r') as fp: lines = len(fp.readlines()) sheet['Path'].append(file) sheet['Size'].append(lines) total = total + 1 data = pd.DataFrame(sheet,columns=columns) data.to_excel (writer, sheet_name=mod, index=False) print("Sorted {} files".format(total))