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


Python colorclass.Color方法代码示例

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


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

示例1: test_colorclass_colors

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def test_colorclass_colors():
    "Regression: ANSI colors in a unicode/str subclass (issue #49)"
    try:
        import colorclass

        s = colorclass.Color("{magenta}3.14{/magenta}")
        result = tabulate([[s]], tablefmt="plain")
        expected = "\x1b[35m3.14\x1b[39m"
        assert_equal(result, expected)
    except ImportError:

        class textclass(_text_type):
            pass

        s = textclass("\x1b[35m3.14\x1b[39m")
        result = tabulate([[s]], tablefmt="plain")
        expected = "\x1b[35m3.14\x1b[39m"
        assert_equal(result, expected) 
开发者ID:astanin,项目名称:python-tabulate,代码行数:20,代码来源:test_regression.py

示例2: main

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def main():
		
	choice=menu()

	if(choice==1) :
		team=input("\n Enter team's name:")
		while(len(team)<=1):
			print(Color('{autored}\n Enter valid team name{/autored}'))
			team=input("\n Enter team's name:")

		make_table(team)

	else:
		team1=input("\n Enter name of team 1:")
		team2=input(" Enter name of team 2:")
		while(len(team1)<=1 or len(team2)<=1 or team1.strip(' ')==team2.strip(' ')):
			print(Color('{autored}\n Enter valid team names{/autored}'))
			team1=input("\n Enter name of team 1:")
			team2=input(" Enter name of team 2:")
		make_table(team1,team2) 
开发者ID:umangahuja1,项目名称:Scripting-and-Web-Scraping,代码行数:22,代码来源:cricket_calender.py

示例3: test_ascii

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def test_ascii():
    """Test with ASCII characters."""
    table_data = [
        ['Name', 'Color', 'Type'],
        ['Avocado', 'green', 'nut'],
        ['Tomato', 'red', 'fruit'],
        ['Lettuce', 'green', 'vegetable'],
    ]
    table = BaseTable(table_data)
    actual = table.table

    expected = (
        '+---------+-------+-----------+\n'
        '| Name    | Color | Type      |\n'
        '+---------+-------+-----------+\n'
        '| Avocado | green | nut       |\n'
        '| Tomato  | red   | fruit     |\n'
        '| Lettuce | green | vegetable |\n'
        '+---------+-------+-----------+'
    )

    assert actual == expected 
开发者ID:Robpol86,项目名称:terminaltables,代码行数:24,代码来源:test_table.py

示例4: test_color

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def test_color():
    """Test with color characters."""
    table_data = [
        ['ansi', '\033[31mRed\033[39m', '\033[32mGreen\033[39m', '\033[34mBlue\033[39m'],
        ['colorclass', Color('{red}Red{/red}'), Color('{green}Green{/green}'), Color('{blue}Blue{/blue}')],
        ['colorama', Fore.RED + 'Red' + Fore.RESET, Fore.GREEN + 'Green' + Fore.RESET, Fore.BLUE + 'Blue' + Fore.RESET],
        ['termcolor', colored('Red', 'red'), colored('Green', 'green'), colored('Blue', 'blue')],
    ]
    table = BaseTable(table_data)
    table.inner_heading_row_border = False
    actual = table.table

    expected = (
        u'+------------+-----+-------+------+\n'
        u'| ansi       | \033[31mRed\033[39m | \033[32mGreen\033[39m | \033[34mBlue\033[39m |\n'
        u'| colorclass | \033[31mRed\033[39m | \033[32mGreen\033[39m | \033[34mBlue\033[39m |\n'
        u'| colorama   | \033[31mRed\033[39m | \033[32mGreen\033[39m | \033[34mBlue\033[39m |\n'
        u'| termcolor  | \033[31mRed\033[0m | \033[32mGreen\033[0m | \033[34mBlue\033[0m |\n'
        u'+------------+-----+-------+------+'
    )

    assert actual == expected 
开发者ID:Robpol86,项目名称:terminaltables,代码行数:24,代码来源:test_table.py

示例5: test_colors_cjk_rtl

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def test_colors_cjk_rtl():
    """Test color text, CJK characters, and RTL characters."""
    table_data = [
        [Color('{blue}Test{/blue}')],
        [Fore.BLUE + 'Test' + Fore.RESET],
        [colored('Test', 'blue')],
    ]
    assert max_dimensions(table_data) == ([4], [1, 1, 1], [4], [1, 1, 1])

    table_data = [
        ['蓝色'],
        ['世界你好'],
    ]
    assert max_dimensions(table_data) == ([8], [1, 1], [8], [1, 1])

    table_data = [
        ['שלום'],
        ['معرب'],
    ]
    assert max_dimensions(table_data) == ([4], [1, 1], [4], [1, 1]) 
开发者ID:Robpol86,项目名称:terminaltables,代码行数:22,代码来源:test_max_dimensions.py

示例6: render

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def render(self, target, vlan):
        if vlan.dhcp_on:
            if vlan.primary_rack:
                if vlan.secondary_rack:
                    text = "HA Enabled"
                else:
                    text = "Enabled"
            if target == RenderTarget.pretty:
                text = Color("{autogreen}%s{/autogreen}") % text
        elif vlan.relay_vlan:
            text = "Relayed via %s.%s" % (vlan.fabric.name, vlan.vid)
            if target == RenderTarget.pretty:
                text = Color("{autoblue}%s{/autoblue}") % text
        else:
            text = "Disabled"
        return super().render(target, text) 
开发者ID:maas,项目名称:python-libmaas,代码行数:18,代码来源:tables.py

示例7: run_tasks_for_bootstrap_spokes_in_ou

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def run_tasks_for_bootstrap_spokes_in_ou(tasks_to_run, num_workers):
    for type in ["failure", "success", "timeout", "process_failure", "processing_time", "broken_task", ]:
        os.makedirs(Path(constants.RESULTS_DIRECTORY) / type)

    run_result = luigi.build(
        tasks_to_run,
        local_scheduler=True,
        detailed_summary=True,
        workers=num_workers,
        log_level='INFO',
    )

    for filename in glob('results/failure/*.json'):
        result = json.loads(open(filename, 'r').read())
        click.echo(colorclass.Color("{red}" + result.get('task_type') + " failed{/red}"))
        click.echo(f"{yaml.safe_dump({'parameters':result.get('task_params')})}")
        click.echo("\n".join(result.get('exception_stack_trace')))
        click.echo('')
    exit_status_codes = {
        LuigiStatusCode.SUCCESS: 0,
        LuigiStatusCode.SUCCESS_WITH_RETRY: 0,
        LuigiStatusCode.FAILED: 1,
        LuigiStatusCode.FAILED_AND_SCHEDULING_FAILED: 2,
        LuigiStatusCode.SCHEDULING_FAILED: 3,
        LuigiStatusCode.NOT_RUN: 4,
        LuigiStatusCode.MISSING_EXT: 5,
    }
    sys.exit(exit_status_codes.get(run_result.status)) 
开发者ID:awslabs,项目名称:aws-service-catalog-puppet,代码行数:30,代码来源:runner.py

示例8: _hinton_diagram_value

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def _hinton_diagram_value(val, max_val):
    chars = [' ', '▁', '▂', '▃', '▄', '▅'] #, '▆', '▇', '█']
    # chars = [' ', '·', '▪', '■', '█']
    step = len(chars) - 1
    if abs(abs(val) - max_val) >= 1e-8:
        step = int(abs(float(val) / max_val) * len(chars))
    attr = 'red' if val < 0 else 'green'
    return Color('{auto' + attr + '}' + str(chars[step]) + '{/auto' + attr + '}') 
开发者ID:uclnlp,项目名称:inferbeddings,代码行数:10,代码来源:hinton.py

示例9: make_table

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def make_table(result):
    table_data = [['S.No', 'Name', 'Rating']]

    for s_no,res in enumerate(result,1):
        row = []
        row.extend((Color('{autoyellow}' + str(s_no) + '.' + '{/autoyellow}'),
                        Color('{autogreen}' + res[0] + '{/autogreen}'),
                        Color('{autoyellow}' + res[1] + '{/autoyellow}')))
        table_data.append(row)

    table_instance = DoubleTable(table_data)
    table_instance.inner_row_border = True

    print(table_instance.table)
    print() 
开发者ID:umangahuja1,项目名称:Scripting-and-Web-Scraping,代码行数:17,代码来源:charts.py

示例10: make_table

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def make_table(team1,team2=''):
	data=scrape()
	table_data=[['Match','Series','Date','Month','Time']]

	for i in data[:]:
		row=[]
		if team1.strip(' ') in i.get('desc') and team2.strip(' ') in i.get('desc') :
			row.extend((Color('{autoyellow}'+i.get('desc')+'{/autoyellow}'),Color('{autocyan}'+i.get('srs')[5:]+'{/autocyan}'),Color('{autored}'+i.get('ddt')+'{/autored}'),Color('{autogreen}'+i.get('mnth_yr')+'{/autogreen}'),Color('{autoyellow}'+i.get('tm')+'{/autoyellow}')))
			table_data.append(row)

	table_instance = DoubleTable(table_data)
	table_instance.inner_row_border = True

	print(table_instance.table)
	print() 
开发者ID:umangahuja1,项目名称:Scripting-and-Web-Scraping,代码行数:17,代码来源:cricket_calender.py

示例11: menu

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def menu():
	print(' Search by team')
	print(' 1.One team: ')
	print(' 2.Two teams: ')
	choice=input('\n Enter your choice:')

	while(choice not in ['1','2']):
		print(Color('{autored}\n Wrong choice{/autored}'))
		choice=input('\n Enter your choice:')

	teams=['Ind','SL','Aus','Ban','RSA','ZIM','NZ','Eng','WI']
	print()
	print(teams)

	return int(choice) 
开发者ID:umangahuja1,项目名称:Scripting-and-Web-Scraping,代码行数:17,代码来源:cricket_calender.py

示例12: download_menu

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def download_menu():
    print('1.Song')
    print('2.Video Song')
    print()
    choice = input('Enter your choice:')
    print()
    while choice not in ['1', '2']:
        print(Color('{autored}Wrong Choice{/autored}'))
        choice = input('\nEnter choice: ')
        print()
    return choice 
开发者ID:umangahuja1,项目名称:Scripting-and-Web-Scraping,代码行数:13,代码来源:saavn.py

示例13: song_list_menu

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def song_list_menu():
    print('Select from the above lists\n')
    print('1. Saavn Weekly Top')
    print('2. Hindi Chartbusters')
    print('3. English Chartbusters')
    print()
    choice = input('Enter choice: ')
    print()
    while choice not in ['1', '2', '3']:
        print(Color('{autored}Wrong Choice{/autored}'))
        choice = input('\nEnter choice: ')
        print()

    return choice 
开发者ID:umangahuja1,项目名称:Scripting-and-Web-Scraping,代码行数:16,代码来源:saavn.py

示例14: set_color

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def set_color(options, text, color):
    """
    Little wrapper around Color() to dynamically disable it on demand.
    """
    if options.disable_colors:
        return text

    return colorclass.Color(
        "{{{color}}}{text}{{/{color}}}".format(text=text, color=color)
    ) 
开发者ID:bartTC,项目名称:pip-check,代码行数:12,代码来源:__init__.py

示例15: terminal

# 需要导入模块: import colorclass [as 别名]
# 或者: from colorclass import Color [as 别名]
def terminal(self, level, target, command, message=""):
        if level == 0 and not self.verbose:
            return

        formatting = {
            0: Color('{autoblue}[VERBOSE]{/autoblue}'),
            1: Color('{autogreen}[THREAD]{/autogreen}'),
            3: Color('{autobgyellow}{autored}[ERROR]{/autored}{/autobgyellow}')
        }

        leader = formatting.get(level, '[#]')

        format_args = {
           'time': strftime("%H:%M:%S", localtime()),
           'target': target,
           'command': command,
           'message': message,
            'leader': leader
        }

        if not self.silent:
            if level == 1:
                template = '[{time}] {leader} [{target}] {command} {message}'
            else:
                template = '[{time}] {leader} [{target}] {command} {message}'
            
            print(template.format(**format_args)) 
开发者ID:codingo,项目名称:Interlace,代码行数:29,代码来源:output.py


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