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


Python ValueSpiderCrawl.find方法代码示例

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


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

示例1: test_find

# 需要导入模块: from dht.crawling import ValueSpiderCrawl [as 别名]
# 或者: from dht.crawling.ValueSpiderCrawl import find [as 别名]
    def test_find(self):
        self._connecting_to_connected()
        self.wire_protocol[self.addr1] = self.con
        self.wire_protocol[self.addr2] = self.con
        self.wire_protocol[self.addr3] = self.con

        self.protocol.router.addContact(self.node1)
        self.protocol.router.addContact(self.node2)
        self.protocol.router.addContact(self.node3)

        node = Node(digest("s"))
        nearest = self.protocol.router.findNeighbors(node)
        spider = ValueSpiderCrawl(self.protocol, node, nearest, 20, 3)
        spider.find()

        self.clock.advance(constants.PACKET_TIMEOUT)
        connection.REACTOR.runUntilCurrent()
        self.assertEqual(len(self.proto_mock.send_datagram.call_args_list), 4)
开发者ID:fivemil,项目名称:PulseShop-Server,代码行数:20,代码来源:test_crawling.py

示例2: get

# 需要导入模块: from dht.crawling import ValueSpiderCrawl [as 别名]
# 或者: from dht.crawling.ValueSpiderCrawl import find [as 别名]
    def get(self, keyword):
        """
        Get a key if the network has it.

        Returns:
            :class:`None` if not found, the value otherwise.
        """
        dkey = digest(keyword)
        if self.storage.get(dkey) is not None:
            return defer.succeed(self.storage.get(dkey))
        node = Node(dkey)
        nearest = self.protocol.router.findNeighbors(node)
        if len(nearest) == 0:
            self.log.warning("there are no known neighbors to get key %s" % dkey.encode('hex'))
            return defer.succeed(None)
        spider = ValueSpiderCrawl(self.protocol, node, nearest, self.ksize, self.alpha)
        return spider.find()
开发者ID:gasull,项目名称:OpenBazaar-Server,代码行数:19,代码来源:network.py

示例3: get

# 需要导入模块: from dht.crawling import ValueSpiderCrawl [as 别名]
# 或者: from dht.crawling.ValueSpiderCrawl import find [as 别名]
    def get(self, keyword, save_at_nearest=True):
        """
        Get a key if the network has it.

        Args:
            keyword = the keyword to save to
            save_at_nearest = save value at the nearest without value

        Returns:
            :class:`None` if not found, the value otherwise.
        """
        dkey = digest(keyword)
        node = Node(dkey)
        nearest = self.protocol.router.findNeighbors(node)
        if len(nearest) == 0:
            self.log.warning("there are no known neighbors to get key %s" % dkey.encode('hex'))
            return defer.succeed(None)
        spider = ValueSpiderCrawl(self.protocol, node, nearest, self.ksize, self.alpha, save_at_nearest)
        return spider.find()
开发者ID:fivemil,项目名称:PulseShop-Server,代码行数:21,代码来源:network.py


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