module.py 文件源码

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

项目:PyFunt 作者: dnlcrl 项目源码 文件源码
def find_modules(self, type_c, container):
        container = container or self
        nodes = {}
        containers = {}
        mod_type = type(self)
        if mod_type == type_c:
            nodes[len(nodes)+1] = self
            containers[len(containers)] = container
        # Recurse on nodes with 'modules'
        if self.modules is not None:
            if type(self.modules) is DictType:
                for i in xrange(len(self.modules)):
                    child = self.modules[i]
                    cur_nodes, cur_containers = child.find_modules(
                        type_c, self)

                    # This shouldn't happen
                    if not len(cur_nodes) == len(cur_containers):
                        raise Exception('Internal error: incorrect return length')

                    # add the list items from our child to our list (ie return a
                    # flattened table of the return nodes).
                    for j in xrange(len(cur_nodes)):
                        nodes[len(cur_nodes)+1] = cur_nodes[j]
                        containers[len(containers)+1] = cur_containers[j]

        return nodes, containers
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号