当前位置: 首页>>代码示例>>Python>>正文


Python DB.list_dir_id方法代码示例

本文整理汇总了Python中lib.db.DB.list_dir_id方法的典型用法代码示例。如果您正苦于以下问题:Python DB.list_dir_id方法的具体用法?Python DB.list_dir_id怎么用?Python DB.list_dir_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.db.DB的用法示例。


在下文中一共展示了DB.list_dir_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RestorePanel

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import list_dir_id [as 别名]

#.........这里部分代码省略.........
        self.onSliderScroll(None)
        self.rebuild_tree()
        self.pnlRestore.Layout()

    def get_current_run(self):
        if len(self.runs) == 0:
            return None
        if len(self.runs) == 1:
            return self.runs[0]

        idx = self.date_slider.GetValue()
        if idx >= len(self.runs):
            raise Exception("Invalid date slider position")
        return self.runs[idx]

    def expand_node(self, parent_node):
        log.trace("expand_node", parent_node)
        run = self.get_current_run()
        if not run:
            return
        #    Get the folder - which is in data
        parent_info = self.fs_tree.GetItemPyData(parent_node)
        log.debug("expanding node", parent_info)
        if parent_info.expanded:
            log.debug("Already expanded")
            return
        if parent_info.type == "F":
            log.debug("File node (no children)")
            return
        #    Clean out the dummy sub-node
        self.fs_tree.DeleteChildren(parent_node)

        #    Now add the subnodes (Only up to the currently selected run
        files = self.db.list_dir_id(parent_info.fs_id, run_id=run.run_id)
        for name, item in files.iteritems():
            if parent_info.fs_id == 0 and name == "/":
                continue
            #    The type may be None because this could be a folder that
            #    we log, but dont back up.
            type = item.type
            if type is None:
                type = "D"
            #    We dont add in deleted files
            if type != "X":
                node_name = utils.display_escape(name)
                new_node = self.fs_tree.AppendItem(parent_node, node_name, image=0 if type == "D" else 1)
                new_info = node_info(parent_info.fs_id, item.fs_id, type, False, os.path.join(parent_info.path, name))
                log.debug("New node: ", new_info)
                self.fs_tree.SetItemPyData(new_node, new_info)
                #    For any folders, add a dummy sub-node so we can expand it later
                if type == "D":
                    self.fs_tree.AppendItem(new_node, DummyTreeNode)

        #    Update the parent node to show that its been expanded.
        upd_info = node_info(parent_info.parent_id, parent_info.fs_id, parent_info.type, True, parent_info.path)
        self.fs_tree.SetItemPyData(parent_node, upd_info)
        self.fs_tree.SortChildren(parent_node)

##################################################################
#
#    Event Handlers
#
##################################################################
    def onRefresh(self, event):
        self.force_rebuild()
开发者ID:,项目名称:,代码行数:69,代码来源:


注:本文中的lib.db.DB.list_dir_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。