log.py 文件源码

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

项目:twitter_word_count 作者: prrateekk 项目源码 文件源码
def should_color(consumer, environ, std=(sys.stdout, sys.stderr)):
    real_consumer = (consumer if not isinstance(consumer, colorama.AnsiToWin32)
                        else consumer.wrapped)

    # If consumer isn't stdout or stderr we shouldn't colorize it
    if real_consumer not in std:
        return False

    # If consumer is a tty we should color it
    if hasattr(real_consumer, "isatty") and real_consumer.isatty():
        return True

    # If we have an ASNI term we should color it
    if environ.get("TERM") == "ANSI":
        return True

    # If anything else we should not color it
    return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号