How to use the sty.fg 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
print(foo, bar, baz, qux, qui, buf, sep='\n')
# ===== End =====

# ===== Start =====
Example("gettings started: select dynamically")
a = ef('italic') + 'Italic text.' + rs.italic
b = fg('blue') + 'Blue text.' + rs.fg
c = bg(randint(0, 254)) + 'Random colored bg' + rs.bg

print(a, b, c, sep='\n')
# ===== End =====

# ===== Start =====
Example("gettings started: select 8bit and 24bit directly")
# select an 8bit color directly.
a = fg(196) + 'This is red text' + rs.fg

# select a 24bit rgb color directly.
b = bg(50, 255, 50) + 'Text with green bg' + rs.bg

print(a, b, sep='\n')
# ===== End =====

# ===== Start =====
Example("hello world")
my_string = fg.black + bg.white + ef.bold + 'Hello world!' + rs.all
print(my_string)
# ===== End =====
github feluxe / sty / tests / docs / exporting.py View on Github external
from .. import Example

print("\n\nETC\n" + "=" * 80)

# ===== Start =====
Example("as dict")
from sty import fg as fg_obj

fg = fg_obj.as_dict()

a = fg['red'] + "I have a red fg." + fg['rs']

print(a)
# ===== End =====

# ===== Start =====
Example("as namedtuple")
from sty import fg as fg_obj

fg = fg_obj.as_namedtuple()

a = fg.yellow + "I have a yellow fg." + fg.rs

print(a)
# ===== End =====
github Jelomite / horrible-downloader / HorribleDownloader / cmd.py View on Github external
exit(0)

    logger.info("found the following files:")
    if not args.quiet:
        episodes_len = len(downloads_list) * len(qualities)
        print(f'{fg(2)}\nFound {episodes_len} file{"s" if episodes_len > 1 else ""} to download:\n{fg.rs}')
    for episode in downloads_list:
        for quality in qualities:
            if not args.quiet:
                print(f'{episode["title"]} - {episode["episode"]} [{quality}p].mkv')
            logger.info(f'{episode["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)
            logger.info("user has aboorted the download")
            exit(1)


    for episode in downloads_list:
        download(episode, qualities, config.download_dir)
        config.update_entry(episode["title"], episode["episode"])
        logger.info(f'updated entry: {episode["title"]} - {episode["episode"]}')
    exit(0)
github Jelomite / horrible-downloader / HorribleDownloader / cmd.py View on Github external
if args.download:
        title = parser.get_proper_title(args.download)
        if not args.quiet:
            print(f"{fg(3)}FETCHING:{fg.rs} {title}")
        episodes = parser.get_episodes(args.download, batches=args.batch)
        def should_download(episode):
            if not args.episodes:
                return True
            return episode_filter(float(episode["episode"]), args.episodes)

        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)
github Jelomite / horrible-downloader / HorribleDownloader / cmd.py View on Github external
downloads_list = []
    for episodes in downloads.values():
        for episode in episodes:
            downloads_list.append(episode)

    if downloads_list == []:
        if not args.quiet:
            print(fg(1) + 'No new episodes were found. Exiting ' + fg.rs)
        logger.info("No new episodes were found. Exiting ")
        exit(0)

    logger.info("found the following files:")
    if not args.quiet:
        episodes_len = len(downloads_list) * len(qualities)
        print(f'{fg(2)}\nFound {episodes_len} file{"s" if episodes_len > 1 else ""} to download:\n{fg.rs}')
    for episode in downloads_list:
        for quality in qualities:
            if not args.quiet:
                print(f'{episode["title"]} - {episode["episode"]} [{quality}p].mkv')
            logger.info(f'{episode["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)
            logger.info("user has aboorted the download")
            exit(1)


    for episode in downloads_list:
        download(episode, qualities, config.download_dir)
github Jelomite / horrible-downloader / HorribleDownloader / cmd_funcs.py View on Github external
shared_dict[proper_show_title] = batches[0]
    else:
        episodes = parser.get_episodes(show_title)
        def should_download(episode):
            return float(episode["episode"]) > float(last_watched)
        filtered_episodes = list(filter(should_download, episodes))
        shared_dict[proper_show_title] = filtered_episodes
    if not quiet:
        with lock:
            clear()
            shows = shared_dict.items()
            for title, episodes in shows:
                dots = "." * (50 - len(title))
                if episodes:
                    found_str = f"FOUND ({len(episodes)})"
                    print(f"{fg(3)}FETCHING:{fg.rs} {title}{dots} {fg(10)}{found_str}{fg.rs}")
                elif episodes == []:
                    print(f"{fg(3)}FETCHING:{fg.rs} {title}{dots} {fg(8)}NONE{fg.rs}")
                else:
                    print(f"{fg(3)}FETCHING:{fg.rs} {title}")
github Jelomite / horrible-downloader / HorribleDownloader / cmd.py View on Github external
shared_dict[proper_show_title] = batches[0]
    else:
        episodes = parser.get_episodes(show_title)
        def should_download(episode):
            return float(episode["episode"]) > float(last_watched)
        filtered_episodes = list(filter(should_download, episodes))
        shared_dict[proper_show_title] = filtered_episodes
    if not quiet:
        with lock:
            clear()
            shows = shared_dict.items()
            for title, episodes in shows:
                dots = "." * (50 - len(title))
                if episodes:
                    found_str = f"FOUND ({len(episodes)})"
                    print(f"{fg(3)}FETCHING:{fg.rs} {title}{dots} {fg(10)}{found_str}{fg.rs}")
                elif episodes == []:
                    print(f"{fg(3)}FETCHING:{fg.rs} {title}{dots} {fg(8)}NONE{fg.rs}")
                else:
                    print(f"{fg(3)}FETCHING:{fg.rs} {title}")
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"])