whatstyle.py 文件源码

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

项目:whatstyle 作者: mikr 项目源码 文件源码
def category_print(categories, categorytype, category, s, prefix='', end='\n', fp=None):
    # type: (Set[str], str, str, Union[str, bytes], str, str, Optional[IO]) -> None
    if category not in categories:
        return
    if categorytype == 'info':
        msg = prefix
    else:
        msg = '%s%s_%s: ' % (prefix, categorytype, category)
    if MESSAGE_CATEGORY_FILES is not None:
        logfilename = 'whatstyle_%s_%s.log' % (categorytype, category)
        fp = MESSAGE_CATEGORY_FILES.get(logfilename)
        if fp is None:
            path = os.path.join(tempfile.gettempdir(), logfilename)
            fp = open(path, 'wb')
            MESSAGE_CATEGORY_FILES[logfilename] = fp
    if fp is None and LOGFILE:
        global LOGFILEFP
        if not LOGFILEFP:
            LOGFILEFP = open(LOGFILE, 'wb')
        fp = LOGFILEFP
    if fp is None:
        fp = rawstream(sys.stderr if STDERR_OUTPUT else sys.stdout)
    write(msg, fp=fp)
    write(s, fp=fp)
    if end:
        write(end, fp=fp)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号