main.py 文件源码

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

项目:PyIDE 作者: raggesilver 项目源码 文件源码
def populateFileSystemTreeStore(self, treeStore, path, parent=None):
        itemCounter = 0
        # iterate over the items in the path
        _list = os.listdir(path)
        _list.sort(key=str.lower)
        for item in _list:
            # Get the absolute path of the item
            itemFullname = os.path.join(path, item)
            # Extract metadata from the item
            itemMetaData = os.stat(itemFullname)
            # Determine if the item is a folder
            itemIsFolder = stat.S_ISDIR(itemMetaData.st_mode)
            # Generate an icon from the default icon theme
            itemIcon = None
            try:
                itemIcon = Gtk.IconTheme.get_default().load_icon("folder" if itemIsFolder else "gnome-mime-text-x-c" if os.path.splitext(itemFullname)[1] == '.c' else "gnome-mime-text-x-c++" if os.path.splitext(itemFullname)[1] == '.cpp' else "gnome-mime-text-x-python" if os.path.splitext(itemFullname)[1] == '.py' else "application-json" if os.path.splitext(itemFullname)[1] == '.json' else "text-x-markdown" if os.path.splitext(itemFullname)[1] == '.md' else "text-x-cmake" if os.path.basename(itemFullname) == 'Makefile' else "gnome-mime-image" if os.path.splitext(itemFullname)[1] in ['.png', '.jpg', '.jpeg', '.gif'] else "text-x-script" if not self.is_exe(os.path.join(self.projectPath, itemFullname)) else "application-x-executable", 22, 0)
            except:
                itemIcon = Gtk.IconTheme.get_default().load_icon("text-x-script", 22, 0)

            # print('{} is equal to Makefile? {}'.format(itemFullname, itemFullname == 'Makefile'))
            # Append the item to the TreeStore
            currentIter = treeStore.append(parent, [item, itemIcon, itemFullname])
            # add dummy if current item was a folder
            if itemIsFolder: treeStore.append(currentIter, [None, None, None])
            #increment the item counter
            itemCounter += 1
        # add the dummy node back if nothing was inserted before
        if itemCounter < 1: treeStore.append(parent, [None, None, None])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号