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


Python colored.fg方法代码示例

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


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

示例1: color_text

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [as 别名]
def color_text(text_array, levels, color_fg=True):
	out = []

	l_max = np.amax(levels)
	l_min = np.amin(levels)

	l_max = max(l_max, 1.0)

	for l, s in zip(levels, text_array):
		l_n = (l - l_min) / (l_max + EPSILON)
		l_n = max(0.0, min(1.0, l_n))
		if color_fg:
			color = fg(int(math.floor(DARK_GREY + l_n * (WHITE-DARK_GREY))))
		else:
			color = bg(int(math.floor(BG_BLACK + l_n * (BG_DARK_GREY-BG_BLACK))))
		out.append(stylize(s, color))
	return out 
开发者ID:Octavian-ai,项目名称:shortest-path,代码行数:19,代码来源:print_util.py

示例2: colorize

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [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 fg [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: display_list_models

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [as 别名]
def display_list_models():
    models = sct.deepseg.models.list_models()
    # Display beautiful output
    color = {True: 'green', False: 'red'}
    default = {True: '[*]', False: ''}
    print("{:<25s}DESCRIPTION".format("MODEL"))
    print("-" * 80)
    for name_model, value in models.items():
        path_model = sct.deepseg.models.folder(name_model)
        print("{}{}".format(
            colored.stylize(''.join((name_model, default[value['default']])).ljust(25),
                            colored.fg(color[sct.deepseg.models.is_valid(path_model)])),
            colored.stylize(value['description'],
                            colored.fg(color[sct.deepseg.models.is_valid(path_model)]))
        ))
    print(
        '\nLegend: {} | {} | default: {}\n'.format(
            colored.stylize("installed", colored.fg(color[True])),
            colored.stylize("not installed", colored.fg(color[False])),
            default[True]))
    exit(0) 
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:23,代码来源:models.py

示例5: display_list_tasks

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [as 别名]
def display_list_tasks():
    tasks = sct.deepseg.models.list_tasks()
    # Display beautiful output
    color = {True: 'green', False: 'red'}
    default = {True: '[*]', False: ''}
    print("{:<20s}{:<50s}MODELS".format("TASK", "DESCRIPTION"))
    print("-" * 80)
    for name_task, value in tasks.items():
        path_models = [sct.deepseg.models.folder(name_model) for name_model in value['models']]
        are_models_valid = [sct.deepseg.models.is_valid(path_model) for path_model in path_models]
        task_status = colored.stylize(name_task.ljust(20),
                                      colored.fg(color[all(are_models_valid)]))
        description_status = colored.stylize(value['description'].ljust(50),
                                             colored.fg(color[all(are_models_valid)]))
        models_status = ', '.join([colored.stylize(model_name,
                                                   colored.fg(color[is_valid]))
                                   for model_name, is_valid in zip(value['models'], are_models_valid)])
        print("{}{}{}".format(task_status, description_status, models_status))

    print(
        '\nLegend: {} | {} | default: {}\n'.format(
            colored.stylize("installed", colored.fg(color[True])),
            colored.stylize("not installed", colored.fg(color[False])),
            default[True]))
    exit(0) 
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:27,代码来源:models.py

示例6: parseCookies

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [as 别名]
def parseCookies(self, cookie):
        try:
            cookies = cookie.split(';')
            for i in cookies:
                if len(i) != 0:
                    try:
                        key = i.split('=')[0]
                        value = i.split('=')[1]
                        self.new.update({key.strip():value.strip()})
                    except IndexError:
                        print(fg(1)+'Cookie Error: '+self.rs+str(i))
                        continue
        except IndexError:
                print(fg(1)+'Cookies Error: '+self.rs+str(cookie))
        return self.new

    #Handle the parsing of a user supplied proxy 
开发者ID:maK-,项目名称:scanomaly,代码行数:19,代码来源:dataparser.py

示例7: print_logo

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [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

示例8: prnt_targets

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [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

示例9: hr_text

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [as 别名]
def hr_text(text):
	t_len = len(text) + 2
	pad_len = (TARGET_CHAR_WIDTH - t_len) // 2
	padding = '-'.join(["" for i in range(pad_len)])

	s = padding + " " + text + " " + padding

	print(stylize(s, fg("yellow"))) 
开发者ID:Octavian-ai,项目名称:shortest-path,代码行数:10,代码来源:print_util.py

示例10: hr

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [as 别名]
def hr(bold=False):
	if bold:
		print(stylize("--------------------------", fg("yellow")))
	else:
		print(stylize("--------------------------", fg("blue"))) 
开发者ID:Octavian-ai,项目名称:shortest-path,代码行数:7,代码来源:print_util.py

示例11: compare_with_expected

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [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

示例12: main

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [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

示例13: warn

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [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

示例14: error

# 需要导入模块: import colored [as 别名]
# 或者: from colored import fg [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

示例15: info

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


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