当前位置: 首页>>代码示例>>Python>>正文


Python colored.attr方法代码示例

本文整理汇总了Python中colored.attr方法的典型用法代码示例。如果您正苦于以下问题:Python colored.attr方法的具体用法?Python colored.attr怎么用?Python colored.attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在colored的用法示例。


在下文中一共展示了colored.attr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __str__

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def __str__(self):
        answer = ""
        skip_next = False
        for i, line in enumerate(self.field):
            for j, c in enumerate(line):
                fg_ansi = ""
                bg_ansi = ""
                stop = ""

                if self.field[i][j].foreground:
                    fg_ansi = '\033[38;2;%s;%s;%sm' % rgb_from_str(self.field[i][j].foreground)
                    stop = colored.attr("reset")

                if self.field[i][j].background:
                    bg_ansi = '\033[48;2;%s;%s;%sm' % rgb_from_str(self.field[i][j].background)
                    stop = colored.attr("reset")

                char = c.char or " "
                if not skip_next:
                    answer += fg_ansi + bg_ansi + char.encode('utf-8') + stop
                skip_next = wcswidth(char) == 2

            # answer += "...\n"
            answer += "\n"
        return answer 
开发者ID:chubin,项目名称:rate.sx,代码行数:27,代码来源:panela_colors.py

示例2: colorize

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def colorize(message, format, color=False):
    '''
    Returns the given message in a colorized format
    string with ANSI escape codes for colorized console outputs:
    - message:   the message to be formatted.
    - format:    triple containing format information:
                 (bg-color, fg-color, bf-boolean) supported colors are
                 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
    - color:     boolean determining whether or not the colorization
                 is to be actually performed.
    '''
    if color is False: return message
    (bg, fg, bold) = format
    params = []
    if bold:
        params.append(colored.attr('bold'))
    if bg:
        params.append(colored.bg(bg))
    if fg:
        params.append(colored.fg(fg))

    return colored.stylize(message, set(params)) 
开发者ID:danielnyga,项目名称:pracmln,代码行数:24,代码来源:util.py

示例3: colorize

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def colorize(message, format, color=False):
    '''
    Returns the given message in a colorized format
    string with ANSI escape codes for colorized console outputs:
    - message:   the message to be formatted.
    - format:    triple containing format information:
                 (bg-color, fg-color, bf-boolean) supported colors are
                 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
    - color:     boolean determining whether or not the colorization
                 is to be actually performed.
    '''

    if color is False: return message
    (bg, fg, bold) = format
    params = []
    if bold:
        params.append(colored.attr('bold'))
    if bg:
        params.append(colored.bg(bg))
    if fg:
        params.append(colored.fg(fg))

    return colored.stylize(message, set(params)) 
开发者ID:danielnyga,项目名称:pracmln,代码行数:25,代码来源:util.py

示例4: print_logo

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def print_logo():

	print ('%s\n%s' % (fg(1), attr(1)))
	print ('%s  /$$$$$$$    /$$$$$$   /$$$$$$$$ %s' % (fg(1), attr(1)))
	print ('%s | $$__  $$  /$$__  $$ | $$_____/ %s' % (fg(1), attr(1)))
	print ('%s | $$  \ $$ | $$  \ $$ | $$       %s' % (fg(1), attr(1)))
	print ('%s | $$$$$$$  | $$$$$$$$ | $$$$$    %s' % (fg(1), attr(1)))
	print ('%s | $$$$$$$  | $$$$$$$$ | $$$$$    %s' % (fg(1), attr(1)))
	print ('%s | $$__  $$ | $$__  $$ | $$__/    %s' % (fg(1), attr(1)))
	print ('%s | $$  \ $$ | $$  | $$ | $$       %s' % (fg(1), attr(1)))
	print ('%s | $$  \ $$ | $$  | $$ | $$       %s' % (fg(1), attr(1)))
	print ('%s | $$$$$$$/ | $$  | $$ | $$       %s' % (fg(1), attr(1)))
	print ('%s |_______/  |__/  |__/ |__/       %s' % (fg(1), attr(1)))
	print "\n"
	print ('%s 	version [0.2.0] %s' % (fg(1), attr('reset')))
 	print "\n"
	return
########################################################################### 
开发者ID:engMaher,项目名称:BAF,代码行数:20,代码来源:BAF_0.2.0.py

示例5: prnt_targets

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def prnt_targets(ip_lst):

	n=len(ip_lst)
	print ('%s\n%s' % (fg(1), attr(1)))
	print ('%s  printing ips & ports .. refer to the targets.txt file for processing them with your own flavor ;) %s' % (fg(1), attr('reset')))
	print ('%s\n%s' % (fg(2), attr(1)))
	for i in range(0,n):
		print(i,ip_lst[i],port_lst[i])
		if(i==0):
			with open("output.txt", "w") as text_file:
    				text_file.write(ip_lst[i]+":"+port_lst[i]+'\n')
		else:
			with open("output.txt", "a") as text_file:
    				text_file.write(ip_lst[i]+":"+port_lst[i]+'\n')
	return
########################################################################### 
开发者ID:engMaher,项目名称:BAF,代码行数:18,代码来源:BAF_0.2.0.py

示例6: compare_with_expected

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def compare_with_expected( in_hex, expected ):
    nearest = HEX( in_hex )
    # Look up the matched hex value (e.g. xterm colors 10 and 46 are
    # the same hex value)
    match = _xterm_colors[nearest] == _xterm_colors[expected]

    e_str = '%s%s##%s' % (fg( expected ), bg( expected ), attr('reset'))
    n_str = '%s%s##%s' % (fg( nearest ), bg( nearest ), attr('reset'))
    print( "%s: %s => %s = %s" % ( 'pass' if match else 'FAIL', in_hex, n_str, e_str) )

    return match 
开发者ID:dslackw,项目名称:colored,代码行数:13,代码来源:test_hex_1.py

示例7: main

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def main():

    for color in range(0, 256):
        print("%s This text is colored %s" % (fg(color), attr("reset")))
        print("%s This background is colored %s" % (bg(color), attr("reset")))
        time.sleep(0.1) 
开发者ID:dslackw,项目名称:colored,代码行数:8,代码来源:test_1.py

示例8: __log_to_stdout

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def __log_to_stdout(color, date, tag, message):

    """Write entry to stdout"""

    entry = "%s[%s] %s - %s %s\n" % (color, date, tag, message, attr(0))
    __log(stdout, entry)


# Low level file print 
开发者ID:android-dtf,项目名称:dtf,代码行数:11,代码来源:logging.py

示例9: error

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def error(message):

    """Color format a message for errors"""

    if __use_colors():
        return "%s%s%s" % (COLOR_ERR, message, attr(0))
    else:
        return message 
开发者ID:android-dtf,项目名称:dtf,代码行数:10,代码来源:colors.py

示例10: warning

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def warning(message):

    """Color format a message for warnings"""

    if __use_colors():
        return "%s%s%s" % (COLOR_WARN, message, attr(0))
    else:
        return message 
开发者ID:android-dtf,项目名称:dtf,代码行数:10,代码来源:colors.py

示例11: info

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def info(message):

    """Color format a message for informational messages"""

    if __use_colors():
        return "%s%s%s" % (COLOR_INFO, message, attr(0))
    else:
        return message 
开发者ID:android-dtf,项目名称:dtf,代码行数:10,代码来源:colors.py

示例12: verbose

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def verbose(message):

    """Color format a message for verbose messages"""

    if __use_colors():
        return "%s%s%s" % (COLOR_VERB, message, attr(0))
    else:
        return message 
开发者ID:android-dtf,项目名称:dtf,代码行数:10,代码来源:colors.py

示例13: bold

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def bold(message):

    """Format a bold message"""

    if __use_colors():
        return "%s%s%s" % (attr('bold'), message, attr(0))
    else:
        return message 
开发者ID:android-dtf,项目名称:dtf,代码行数:10,代码来源:colors.py

示例14: warn

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def warn(self, msg):
        msg = self._pad(msg)
        msg = "%s %s[WARN]  %s%s" % (self._logtime(), fg('yellow'), attr(0), msg)
        return self.log(msg, 'warn') 
开发者ID:ethgasstation,项目名称:ethgasstation-backend,代码行数:6,代码来源:output.py

示例15: error

# 需要导入模块: import colored [as 别名]
# 或者: from colored import attr [as 别名]
def error(self, msg):
        msg = self._pad(msg)
        msg = "%s %s[ERROR] %s%s" % (self._logtime(), fg('red'), attr(0), msg)
        return self.log(msg, 'error') 
开发者ID:ethgasstation,项目名称:ethgasstation-backend,代码行数:6,代码来源:output.py


注:本文中的colored.attr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。