mongo.py 文件源码

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

项目:og-miner 作者: opendns 项目源码 文件源码
def extract(self): # TODO : Should be an exporter plugin
        graph = {
            'meta': {},  # self.__meta,
            'properties': {}  # self.__properties
        }

        graph['nodes'] = list()
        for v in self.__vertices.find().sort('id', pymongo.ASCENDING):
            v.pop("_id")  # Remove MongoDB document ID
            graph['nodes'].append(v)

        graph['edges'] = list()
        for e in self.__edges.find().sort("src", pymongo.ASCENDING):
            e.pop("_id")  # Remove MongoDB document ID
            graph['edges'].append(e)

        graph['tokens'] = list();
        for t in self.__tokens.find().sort('id', pymongo.ASCENDING):
            t.pop("_id")  # Remove MongoDB document ID
            t['id'] = str(t['id'])
            t['ts'] = time.mktime(t['ts'].timetuple())
            graph['tokens'].append(t)

        return graph
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号