# Path: falsy/termcc/termcc.py
# def fore(fore):
#     if type(fore) == str:
#         return wrap(TERMCC_FORE + str(TERMCC_FORE_TABLE[fore]))
#     if 0 < fore <= 256:
#         return wrap(TERMCC_FORE + str(fore))
#     return wrap(TERMCC_FORE + str(TERMCC_FORE_TABLE['white']))
# 
# def back(color):
#     return wrap(TERMCC_BACK + str(TERMCC_FORE_TABLE[color]))
# 
# def style(style):
#     return wrap(TERMCC_STYLE + str(TERMCC_STYLE_TABLE[style]))
# 
# def reset():
#     return wrap(TERMCC_RESET_ALL)
# 
# def rastyle():
#     return wrap(TERMCC_RESET_ALL_STYLE)
# 
# def rred():
#     return rfore('red')
# 
# def ritalic():
#     return rstyle('italic')
# 
# def reverse():
#     return style('reverse')
# 
# def rafore():
#     return wrap(TERMCC_RESET_ALL_FORE)
# 
# def raback():
#     return wrap(TERMCC_RESET_ALL_BACK)


import logging
import collections
from falsy.termcc.termcc import fore, back, style, reset, rastyle, rred, ritalic, reverse, rafore, raback


def get_color_code(e):
    if '0' <= e[0] <= '9':
        if len(e) > 1:
            if e[-1] == '_':
                return back(int(e[:-1]))
            else:
                return fore(int(e))
        else:
            return fore(e)
    return codes[e]


def parse_colors(sequence):
    a = ''.join(get_color_code(e) for e in sequence.split(',') if e)
    return a


class JLogColoredFormatter(logging.Formatter):
    def __init__(self, fmt=None, datefmt=None, style='%',
                 log_colors=None, reset=True):
        if fmt is None:
            default_formats = {
                '%': '%(log_color)s%(levelname)s:%(name)s:%(message)s',
                '{': '{log_color}{levelname}:{name}:{message}',
                '$': '${log_color}${levelname}:${name}:${message}'
            }
            fmt = default_formats[style]


# Path: falsy/termcc/termcc.py
# def fore(fore):
#     if type(fore) == str:
#         return wrap(TERMCC_FORE + str(TERMCC_FORE_TABLE[fore]))
#     if 0 < fore <= 256:
#         return wrap(TERMCC_FORE + str(fore))
#     return wrap(TERMCC_FORE + str(TERMCC_FORE_TABLE['white']))
# 
# def back(color):
#     return wrap(TERMCC_BACK + str(TERMCC_FORE_TABLE[color]))
# 
# def style(style):
#     return wrap(TERMCC_STYLE + str(TERMCC_STYLE_TABLE[style]))
# 
# def reset():
#     return wrap(TERMCC_RESET_ALL)
# 
# def rastyle():
#     return wrap(TERMCC_RESET_ALL_STYLE)
# 
# def rred():
#     return rfore('red')
# 
# def ritalic():
#     return rstyle('italic')
# 
# def reverse():
#     return style('reverse')
# 
# def rafore():
#     return wrap(TERMCC_RESET_ALL_FORE)
# 
# def raback():
#     return wrap(TERMCC_RESET_ALL_BACK)


# Path: falsy/jlog/formatters.py
import logging
import collections
from falsy.termcc.termcc import fore, back, style, reset, rastyle, rred, ritalic, reverse, rafore, raback



def get_color_code(e):
    if '0' <= e[0] <= '9':
        if len(e) > 1:
            if e[-1] == '_':
                return back(int(e[:-1]))
            else:
                return fore(int(e))
        else:
            return fore(e)
    return codes[e]


def parse_colors(sequence):
    a = ''.join(get_color_code(e) for e in sequence.split(',') if e)
    return a


class JLogColoredFormatter(logging.Formatter):
    def __init__(self, fmt=None, datefmt=None, style='%',
                 log_colors=None, reset=True):
        if fmt is None:
            default_formats = {
                '%': '%(log_color)s%(levelname)s:%(name)s:%(message)s',
                '{': '{log_color}{levelname}:{name}:{message}',
                '$': '${log_color}${levelname}:${name}:${message}'
            }
            fmt = default_formats[style]


        super().__init__(fmt, datefmt, style)