colour-printing
Project description
Colour-printing
以不同颜色区分终端输出信息类型,标识出重要信息
Python version: 3.5+
内置
info
success
error
warn
debug
过滤器
Switch.filter : list
开关
Switch.signal : bool
示例
from colour_printing.default import log, Switch, Back, Fore, Mode from colour_printing import cprint log.info("hello world!") # Switch.signal=False #关闭 # Switch.filter.append('SUCCESS') #过滤 log.error("hello world!") log.success("hello world!") log.warn("hello world!") log.debug("hello world!") # 颜料 cprint('default') cprint('hello', fore=Fore.RED)
默认模板style
查看样式表:
print(log)
from colour_printing.custom import ColourPrint, Back, Fore, Mode from colour_printing import cprint class MyColour(ColourPrint): def custom(self): self.test = self.Markers('test') .flag_style(fore=Fore.PURPLE, mode=Mode.HIDE) .time_style(mode=Mode.INVERT) .message_style(fore=Fore.YELLOW) echo = MyColour() echo.test('hello world!')
自定义模板/style
- ::
from colour_printing.custom import PrintMe
pe = PrintMe(template=’{time}:{message}’,config_filename=’myconfig’) #config_filename(可选)不存在则创建 pe.info(‘hello’) pe.info(‘hello’) #pe.switch = False #pe.filter.append(‘info’) pe.info(‘hello’) pe.info(‘hello’) pe.error(‘hello’) pe.error(‘hello’)
需要注意
template (模板): 具体由format实现,所以格式要求 “{}{}{}{message}” !{message}必需!
setting.py (配置文件): ××_DEFAULT :由lambda 实现
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
colour-printing-0.2.8.tar.gz
(7.1 kB
view hashes)