sockets.py 文件源码

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

项目:logging2 作者: vforgione 项目源码 文件源码
def _create_name(self) -> str:
        """Creates the name for the handler - called from ``__init__`` if a name is not given.

        :returns: a template of `({protocol} )?{host}(:{port})?`
        """
        if self.port:
            port = ':{}'.format(self.port)
        else:
            port = ''

        if self.family == socket.AF_UNIX:
            stype = 'UNIX'
        elif self.type == socket.SOCK_STREAM:
            stype = 'TCP'
        elif self.type == socket.SOCK_DGRAM:
            stype = 'UDP'
        else:
            stype = None  # pragma: no cover

        if stype:
            host = ' {}'.format(self.host)
        else:
            host = self.host  # pragma: no cover

        return '{}{}{}'.format(stype, host, port)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号