color.py 文件源码

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

项目:OpenDoor 作者: stanislav-web 项目源码 文件源码
def __has_colors(stream):
        """
        Is tty output check
        :param object stream: input stream
        :return: bool
        """

        if not hasattr(stream, "isatty"):
            return False
        # noinspection PyUnresolvedReferences
        if not stream.isatty():
            return False  # auto color only on TTYs
        # noinspection PyBroadException
        try:
            import curses
            curses.setupterm()
            return curses.tigetnum("colors") > 2
        except Exception:
            # guess false in case of error
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号