index.py 文件源码

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

项目:dymo-m10-python 作者: pbrf 项目源码 文件源码
def mirrors(self):
        """
        Return the list of hostnames which are mirrors for this index.
        :return: A (possibly empty) list of hostnames of mirrors.
        """
        result = []
        try:
            host = socket.gethostbyname_ex(self.mirror_host)[0]
        except socket.gaierror: # pragma: no cover
            host = None
        if host:
            last, rest = host.split('.', 1)
            n = len(last)
            host_list = (''.join(w) for w in itertools.chain.from_iterable(
                        itertools.product(ascii_lowercase, repeat=i)
                        for i in range(1, n + 1)))
            for s in host_list:
                result.append('.'.join((s, rest)))
                if s == last:
                    break
        return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号