Formatter.py 文件源码

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

项目:QXSConsolas 作者: qxsch 项目源码 文件源码
def __init__(self, fmt=None, datefmt="%Y-%m-%d %H:%M:%S", exceptionfmt="Traceback (most recent call last):\n%(traceback)s\n%(classname)s: %(message)s"):
        # set standard Formatter values
        self.datefmt = datefmt
        self._fmt = fmt
        self._exceptionfmt = exceptionfmt
        # set colors
        self._fmt = Template(fmt).safe_substitute(SHELL_COLORS)
        self._exceptionfmt = Template(exceptionfmt).safe_substitute(SHELL_COLORS)
        # do we have a tty?
        if sys.stdout.isatty() or os.isatty(sys.stdout.fileno()):
            self.useColors = True
        else:
            self.useColors = False
        # remove all colors
        if not self.useColors:
            self._fmt = re.sub("\033\[(\d+|;)+m", "", self._fmt)
            self._exceptionfmt = re.sub("\033\[(\d+|;)+m", "", self._exceptionfmt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号