def get_tree_data(self,directory,parent=None):
"""Creates TreeStore table"""
for dirs in sorted(os.listdir(directory)):
path=os.path.join(directory,dirs)
if os.path.isdir(path):
os.chdir(dirs)
#count media
vidcount = len(glob.glob('*.MP4'))
imgcount = len(glob.glob('*.JPG'))
#size of directory, subdiretories exclued
size = sum([os.path.getsize(f) for f in os.listdir('.') if os.path.isfile(f)])
humansize = self.sizeof_fmt(size)
try:
#4th/5th position in file name of last element in sorted list of sequences (e.g. Seq_03_010.JPG)
seq = int(sorted(glob.glob('Seq_*_*.*'))[-1][4:6])
except:
seq = 0
#transmit row to treestore
row = self.builder.get_object("treestore1").append(parent,[dirs,vidcount,imgcount,humansize,path,seq,False,size])
#read subdirs as child rows
self.get_tree_data(path,row)
os.chdir("..")
评论列表
文章目录