How to use the colored.stylize function in colored

To help you get started, we’ve selected a few colored 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 magicalraccoon / tootstream / src / tootstream / toot.py View on Github external
for note in reversed(notifications):
        display_name = "  " + format_display_name(note['account']['display_name'])
        username = format_username(note['account'])
        note_id = str(note['id'])

        random.seed(display_name)

        # Check if we should even display this note type
        if kwargs[note['type']]:
            # Display Note ID
            cprint(" note: " + note_id, fg('magenta'))

            # Mentions
            if note['type'] == 'mention':
                time = " " + stylize(format_time(note['status']['created_at']), attr('dim'))
                cprint(display_name + username, fg('magenta'))
                print("  " + format_toot_idline(note['status']) + "  " + time)
                cprint(get_content(note['status']), attr('bold'), fg('white'))
                print(stylize("", attr('dim')))

            # Favorites
            elif note['type'] == 'favourite':
                tz_info = note['status']['created_at'].tzinfo
                note_time_diff = datetime.datetime.now(tz_info) - note['status']['created_at']
                countsline = format_toot_idline(note['status'])
                format_time(note['status']['created_at'])
                time = " " + stylize(format_time(note['status']['created_at']), attr('dim'))
                content = get_content(note['status'])
                cprint(display_name + username, fg(random.choice(COLORS)), end="")
                cprint(" favorited your status:", fg('yellow'))
                print("  "+countsline + stylize(time, attr('dim')))
github mozanunal / img2sh / imgShow.py View on Github external
def renderImage(fileName, pallette):
    termY,termX=getTerminalSize()
    imgR = resize(fileName, termX)
    imgX,imgY = imgR.size
    imageString = "\n"
    for j in range( imgY ):
        for i in range( imgX ):
            color = colored.bg( findNearestColor( imgR.getpixel((i,j)), pallette ) )
            imageString+= stylize( " ", color )
        imageString+="\n"
    return imageString
github magicalraccoon / tootstream / src / tootstream / toot.py View on Github external
def format_toot_nameline(toot, dnamestyle):
    """Get the display, usernames and timestamp for a typical toot printout.

    dnamestyle: a fg/bg/attr set applied to the display name with stylize()"""
    # name line: display name, user@instance, lock if locked, timestamp
    if not toot: return ''
    formatted_time = format_time(toot['created_at'])

    display_name = format_display_name(toot['account']['display_name'])
    out = [stylize(display_name, dnamestyle),
           stylize(format_username(toot['account']), fg('green')),
           stylize(formatted_time, attr('dim'))]
    return ' '.join(out)
github koutto / vulners-lookup / vulners-lookup.py View on Github external
def colorize(string, color=None, highlight=None, attrs=None):
    """Apply style on a string"""
    # Colors list: https://pypi.org/project/colored/
    return colored.stylize(
        string,
        (colored.fg(color) if color else "")
        + (colored.bg(highlight) if highlight else "")
        + (colored.attr(attrs) if attrs else ""),
    )
github geraldoahnert / kali-my-linux / kml.py View on Github external
def options():
    print(
        stylize("Choose a category and put the number.", colored.fg("red"))
    )
    print(stylize("[  1 ]", colored.fg("red")), "All tools.")
    print(stylize("[  2 ]", colored.fg("red")), "Exploration tools.")
    print(stylize("[  3 ]", colored.fg("red")), "Forensic tools.")
    print(stylize("[  4 ]", colored.fg("red")), "Hardware tools.")
    print(stylize("[  5 ]", colored.fg("red")), "Information Gethering tools.")
    print(stylize("[  6 ]", colored.fg("red")), "Maintaining Acess tools.")
    print(stylize("[  7 ]", colored.fg("red")), "Password Atack tools.")
    print(stylize("[  8 ]", colored.fg("red")), "Reporting tools.")
    print(stylize("[  9 ]", colored.fg("red")), "Reverse Engineering tools.")
    print(stylize("[ 10 ]", colored.fg("red")), "Sniffing and Spoofing tools.")
    print(stylize("[ 11 ]", colored.fg("red")), "Stress tools.")
    print(stylize("[ 12 ]", colored.fg("red")), "Vulnerability Analysis tools.")
    print(stylize("[ 13 ]", colored.fg("red")), "Web tools.")
    print(stylize("[ 14 ]", colored.fg("red")), "Wireless Atack tools.")
    user_option = int(input())
    return user_option
github grow / grow / grow / sdk / installer.py View on Github external
def success(cls, message, extras=None):
        """Generate a formatted success message."""
        message = cls.format_message(message, extras)
        styling = colored.fg('green')
        return colored.stylize(MESSAGE_FORMAT.format('✓', message), styling)
github magicalraccoon / tootstream / src / tootstream / toot.py View on Github external
def format_toot_idline(toot):
    """Get boost/faves counts, toot ID, visibility, and
    already-faved/boosted indicators for a typical toot printout."""
    # id-and-counts line: boosted count, faved count, tootid, visibility, favourited-already, boosted-already
    if not toot: return ''
    out = [ stylize(GLYPHS['boost']+":"+str(toot['reblogs_count']), fg('cyan')),
            stylize(GLYPHS['fave']+":"+str(toot['favourites_count']), fg('yellow')),
            stylize("id:"+str(IDS.to_local(toot['id'])), fg('red')),
            stylize("vis:"+GLYPHS[toot['visibility']], fg('blue')) ]

    # app used to post. frequently empty
    if toot.get('application') and toot.get('application').get('name'):
        out.append( ''.join(( stylize("via ", fg('white')),
                              stylize(toot['application']['name'], fg('blue')) )))
    # some toots lack these next keys, use get() to avoid KeyErrors
    if toot.get('favourited'):
        out.append(stylize(GLYPHS['favourited'], fg('magenta')))
    if toot.get('reblogged'):
        out.append(stylize(GLYPHS['reblogged'], fg('magenta')))

    return ' '.join(out)
github magicalraccoon / tootstream / src / tootstream / toot.py View on Github external
def cprint(text, style, end="\n"):
    print(stylize(text, style), end=end)
github jondot / mongomon / mongomon / __init__.py View on Github external
colored.bg("red") + colored.fg("black"),
            )
            if is_over_hwm
            else colored.stylize(
                "{}us (LWM: {}us)".format(duration, self.config.low_watermark_us),
                colored.bg("yellow") + colored.fg("black"),
            )
        )

        self.config.print_fn(
            colored.stylize(
                "{} {}: {} in {}\n{}".format(
                    colored.stylize(
                        "mongomon", colored.fg("black") + colored.bg("magenta")
                    ),
                    colored.stylize(cmd[0], colored.fg("yellow")),
                    colored.stylize(cmd[1], colored.fg("magenta")),
                    fmt_duration,
                    pretty(pformat(self.config.query_filter(dict([q])))),
                ),
                colored.attr("underlined"),
            )
github brouberol / izk / izk / runner.py View on Github external
"""Display the children of a ZNode

        Usage: ls