modules.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:gpt 作者: encarsia 项目源码 文件源码
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("..")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号