How to use the sty.fg.rs function in sty

To help you get started, we’ve selected a few sty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feluxe / sty / tests / docs / getting_started.py View on Github external
from .. import Example
from random import randint

print("\n\nGETTING STARTED\n" + "=" * 80)

# ===== Start =====
Example("gettings started: sty all the strings")
from sty import fg, bg, ef, rs

foo = fg.red + 'This is red text!' + fg.rs
bar = bg.blue + 'This has a blue background!' + bg.rs
baz = ef.italic + 'This is italic text' + rs.italic
qux = fg(201) + 'This is pink text using 8bit colors' + fg.rs
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs

# Add custom colors:

from sty import Style, RgbFg

fg.orange = Style(RgbFg(255, 150, 50))

buf = fg.orange + 'Yay, Im orange.' + fg.rs

print(foo, bar, baz, qux, qui, buf, sep='\n')
# ===== End =====

# ===== Start =====
Example("gettings started: select dynamically")
a = ef('italic') + 'Italic text.' + rs.italic
github Jelomite / horrible-downloader / HorribleDownloader / cmd.py View on Github external
filtered_episodes = list(filter(should_download, episodes))
        if not args.quiet:
            clear()
            dots = "." * (50 - len(title))
            found_str = f"FOUND ({len(filtered_episodes)})"
            print(f"{fg(3)}FETCHING: {fg.rs}{title}{dots}{fg(10)}{found_str}{fg.rs}")

            episodes_len = len(filtered_episodes) * len(qualities)
            print(f'{fg(2)}\nFound {episodes_len} file{"s" if episodes_len > 1 else ""} to download:\n{fg.rs}')
            for episode in filtered_episodes:
                for quality in qualities:
                    print(f'{title} - {episode["episode"]} [{quality}p].mkv')

            if not args.noconfirm and not args.quiet:
                inp = input(f'{fg(3)}\nwould you like to proceed? [Y/n] {fg.rs}')
                if inp not in ('', 'Y', 'y', 'yes', 'Yes'):
                    print(fg(1) + 'aborting download\n' + fg.rs)
                    exit(1)

        for episode in filtered_episodes:
            download(episode, qualities, config.download_dir)
        exit(0)


    manager = Manager()
    initial_downloads_dict = {parser.get_proper_title(title): None for title in config.subscriptions.keys()}
    downloads = manager.dict(initial_downloads_dict)
    printing_lock = Lock()
    procs = []
    method = "batches" if args.batch else "show"
github rednafi / protomate / protomate / script.py View on Github external
def _ascii_flare():
    """
    Draw Pr0t0mate banner !!!
    """
    text = "protomate"
    ascii_color = fg(123, 239, 178)
    ascii_style = art.text2art(text, font="glenyn-large")
    ascii_banner = ascii_color + ascii_style + fg.rs
    cprint(ascii_banner, attrs=["bold"])
github kelvindecosta / image-to-text-art / src / image_to_text_art / colorizer.py View on Github external
            "ansi" : lambda x, y : f"{fg(*y)}{x}{fg.rs}",
            "html" : lambda x, y : f'<span style="color : rgb{tuple(y)};">{x}</span>'
github albertwujj / HearthEnv / hearthenv / envs / hearthEnv.py View on Github external
h_health = fg.red + str(player.hero.health) + fg.rs
		if player.hero.armor != 0:
			h_health += "+" + str(player.hero.armor)

		h_mana = fg.blue + str(player.mana) + "/" + str(player.max_mana) + fg.rs

		line_1 = p(player.hero, h_health, h_mana)


		if player.weapon is not None:
			line_1 += ", " + str(player.weapon.damage) + " " + str(player.weapon.durability)

		pout.append(line_1)
		hand = []

		pout.append(fg.rs + "HAND: " + p(*describe.hand(*player.hand), s=", ")) # line 2
		
		field = []
		for i, c in enumerate(player.field):
			card = ""
			specials = []
			if c.windfury:
				specials += "W"
			if c.taunt:
				specials += "T"
			if c.divine_shield:
				specials += "D"
			if c.poisonous:
				specials += "P"
			if c.silenced:
				specials += "S"
			if c.frozen:
github rednafi / protomate / protomate / cli_prompts.py View on Github external
def draw_ascii_banner():
    """
    Draw Protomate banner !!!
    """
    text = "ProtomatE"
    ascii_banner = art.text2art(text, font="glenyn-large")
    ascii_banner = fg(255, 213, 128) + ascii_banner + fg.rs

    cprint(ascii_banner, attrs=["bold"])
github albertwujj / HearthEnv / hearthenv / utils / color_card.py View on Github external
def color_race(*card):
	""" colors cards according to their in-game race
	"""
	ret = []
	for i in card:
		if hasattr(i, "race") and i.race in race_to_color:
			ret.append("" + race_to_color[i.race] + str(i) + fg.rs)
		else:

			ret.append(str(i))
	return ret
github FreeYourSoul / FSeam / FSeamGenerator / FSeamerFile.py View on Github external
def generateFSeamFiles(filePath, destinationFolder):
    if not str.endswith(filePath, ".hh"):
        raise NameError("Error file " + filePath + " is not a .hh file")

    fSeamerFile = FSeamerFile(filePath)
    fileContent = fSeamerFile.seamParse()
    fileName = fSeamerFile.getFSeamGeneratedFileName()
    fileCreated = open(os.path.normpath(destinationFolder + "/" + fileName), "w")
    fileCreated.write(fileContent)
    fileCreated.close()
    print(fg.cyan + "FSeam generated file " + fileName + " at " + os.path.abspath(destinationFolder) + fg.rs)

    fileCreatedMockDataPath = os.path.normpath(destinationFolder + "/MockData.hpp")
    fileCreatedMockDataContent = ""
    if os.path.exists(fileCreatedMockDataPath):
        fileCreatedMockData = open(fileCreatedMockDataPath, "r")
        fileCreatedMockDataContent = fileCreatedMockData.read().replace(LOCKING_FOOTER, "")
        fileCreatedMockData.close()
    fileCreatedMockData = open(fileCreatedMockDataPath, "w")
    fileCreatedMockData.write(fSeamerFile.getDataStructureContent(fileCreatedMockDataContent))
    fileCreatedMockData.close()
    print(fg.cyan + "FSeam generated file MockData.hpp at " + os.path.abspath(destinationFolder) + fg.rs)