__init__.py 文件源码

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

项目:purelove 作者: hucmosin 项目源码 文件源码
def __cprint(*args, **kwargs):
    """ Color print()

    Signature like Python 3 print() function
    print([object, ...][, sep=' '][, end='\n'][, file=sys.stdout])
    """
    if not kwargs.pop("verbose", True):
        return

    color = kwargs.get('color', None)
    sep = kwargs.get('sep', ' ')
    end = kwargs.get('end', '\n')
    thread = threading.current_thread()
    try:
        file_ = thread_output_stream.get(thread, ())[-1]
    except IndexError:
        file_ = kwargs.get('file', sys.stdout)

    if color:
        printer_queue.put(PrintResource(content='\033[{}m'.format(colors[color]), end='', file=file_, sep=sep, thread=thread))
        printer_queue.put(PrintResource(content=args, end='', file=file_, sep=sep, thread=thread))  # TODO printing text that starts from newline
        printer_queue.put(PrintResource(content='\033[0m', sep=sep, end=end, file=file_, thread=thread))
    else:
        printer_queue.put(PrintResource(content=args, sep=sep, end=end, file=file_, thread=thread))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号