How to use the colored.bg 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 mike820324 / microProxy / tests / viewer / test_console.py View on Github external
def test_fg_and_bg(self):
        self.assertEqual(fg("blue") + bg("blue") + "fg bg test" + attr("reset"),
                         str(ColorText("fg bg test", fg_color="blue", bg_color="blue")))
github ealter / vim_turing_machine / vim_turing_machine / turing_machine.py View on Github external
def print_tape(self):
        tape = ''
        for i, character in enumerate(self.tape):
            if i == self.cursor_position:
                tape += '{}{}{}{}'.format(colored.bg('red'), colored.fg('white'), character, colored.attr('reset'))
            else:
                tape += character

            if i != len(self.tape) - 1:
                tape += ' | '

        print(tape)
        print('State: {}'.format(self.current_state))
        print()  # Add empty line
github JagandeepBrar / Plex-Assistant-Bot / backend / constants.py View on Github external
CONFIG_FILE = "data/config.ini"
DB_FILE = "data/database.db"
BOT_NAME = "Plex Assistant"

NOTIFICATION_TIME = ""
NOTIFICATION_DAY = ""

###################
# LOGGING RELATED #
###################

LOGGING_COLOURS = {
    'INFO': colored.fg('white'), 
    'INFO_GREEN': colored.fg('white')+colored.bg('dark_green'),
    'INFO_BLUE': colored.fg('white')+colored.bg('deep_sky_blue_4c'),
    'WARNING': colored.fg('white')+colored.bg('orange_3'),
    'ERROR': colored.fg('white')+colored.bg('red'),
}

##################
# SOCKET RELATED #
##################

SOCKET_MAX_MSG_LENGTH = 256
if(os.name == 'nt'):
    # Windows does not support 0.0.0.0 by default
    SOCKET_HOST = "127.0.0.1"
else:
    # More versatile to use 0.0.0.0, works on Mac & Linux
    SOCKET_HOST = "0.0.0.0"
SOCKET_PORT = "25535"
github python-tableformatter / tableformatter / tableformatter.py View on Github external
"""Returns the printable width of a string accounting for escape characters and wide-display unicode characters"""
    return _wcswidth(_translate_tabs(text))


# noinspection PyUnresolvedReferences
class TableColors(object):
    """Colors"""
    try:
        from colored import fg, bg, attr

        TEXT_COLOR_WHITE = fg('white')
        TEXT_COLOR_YELLOW = fg(226)
        TEXT_COLOR_RED = fg(196)
        TEXT_COLOR_GREEN = fg(119)
        TEXT_COLOR_BLUE = fg(27)
        BG_COLOR_ROW = bg(234)
        BG_RESET = attr('reset')  # docs say bg(0) should do this but it doesn't work right
        BOLD = attr('bold')
        RESET = attr('reset')
    except ImportError:
        try:
            from colorama import Fore, Back, Style

            TEXT_COLOR_WHITE = Fore.WHITE
            TEXT_COLOR_YELLOW = Fore.LIGHTYELLOW_EX
            TEXT_COLOR_RED = Fore.LIGHTRED_EX
            TEXT_COLOR_GREEN = Fore.LIGHTGREEN_EX
            TEXT_COLOR_BLUE = Fore.LIGHTBLUE_EX
            BG_COLOR_ROW = Back.LIGHTBLACK_EX
            BG_RESET = Back.RESET
            BOLD = Style.BRIGHT
            RESET = Fore.RESET + Back.RESET
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 HynekPetrak / sshame / sshame / main.py View on Github external
from sqlalchemy.orm import sessionmaker, scoped_session, Query
from sqlalchemy.sql import func, select, case, functions
from sqlalchemy import create_engine
from sshame.db import Host, Base, Key, Credential, Command, CommandAlias

version = "0.10"

try:
    from colorama import Back
    BACK_RESET = Back.RESET
    BACK_GREEN = Back.LIGHTGREEN_EX
    BACK_BLUE = Back.LIGHTBLUE_EX
except ImportError:
    try:
        from colored import bg
        BACK_RESET = bg(0)
        BACK_BLUE = bg(27)
        BACK_GREEN = bg(119)
    except ImportError:
        BACK_RESET = ''
        BACK_BLUE = ''
        BACK_GREEN = ''

# https://www.pythoncentral.io/sqlalchemy-orm-examples/
# db = sqlite3.connect('session.db')

logging.getLogger().setLevel(logging.DEBUG)
asyncssh.set_log_level(logging.DEBUG)
log = logging.getLogger('sshame')
asyncssh.set_debug_level(2)
github python-tableformatter / tableformatter / tableformatter / colors.py View on Github external
class TableColors(object):
    """Colors"""
    try:
        from colored import fg, bg, attr

        TEXT_COLOR_WHITE = fg('white')
        TEXT_COLOR_YELLOW = fg(226)
        TEXT_COLOR_RED = fg(196)
        TEXT_COLOR_GREEN = fg(119)
        TEXT_COLOR_BLUE = fg(27)
        BG_COLOR_ROW = bg(244)
        BG_RESET = attr('reset')  # docs say bg(0) should do this but it doesn't work right
        BOLD = attr('bold')
        RESET = attr('reset')
    except ImportError:
        try:
            from colorama import Fore, Back, Style

            TEXT_COLOR_WHITE = Fore.WHITE
            TEXT_COLOR_YELLOW = Fore.LIGHTYELLOW_EX
            TEXT_COLOR_RED = Fore.LIGHTRED_EX
            TEXT_COLOR_GREEN = Fore.LIGHTGREEN_EX
            TEXT_COLOR_BLUE = Fore.LIGHTBLUE_EX
            BG_COLOR_ROW = Back.LIGHTBLACK_EX
            BG_RESET = Back.RESET
            BOLD = Style.BRIGHT
            RESET = Style.NORMAL + Fore.RESET + Back.RESET
github HynekPetrak / sshame / sshame / main.py View on Github external
from sqlalchemy import create_engine
from sshame.db import Host, Base, Key, Credential, Command, CommandAlias

version = "0.10"

try:
    from colorama import Back
    BACK_RESET = Back.RESET
    BACK_GREEN = Back.LIGHTGREEN_EX
    BACK_BLUE = Back.LIGHTBLUE_EX
except ImportError:
    try:
        from colored import bg
        BACK_RESET = bg(0)
        BACK_BLUE = bg(27)
        BACK_GREEN = bg(119)
    except ImportError:
        BACK_RESET = ''
        BACK_BLUE = ''
        BACK_GREEN = ''

# https://www.pythoncentral.io/sqlalchemy-orm-examples/
# db = sqlite3.connect('session.db')

logging.getLogger().setLevel(logging.DEBUG)
asyncssh.set_log_level(logging.DEBUG)
log = logging.getLogger('sshame')
asyncssh.set_debug_level(2)


def configure_logging():
    global log