def parse_text(text_json, default = ""):
    """
    TODO: Add definition ... .
    """

    text = default
    if text_json:
        text = text_json

    return text

# enf def

def parse_int(int_json, default = 0):
    """
    TODO: Add definition ... .
    """

    value = default
    try:
        value = int(int_json)
    except:
        pass

    return value

# enf def

def parse_style(style_json, default = {}):
    """
    TODO: Add definition ... .
    set(align="center", font="a",width=2, height=2, invert=True, text_type="B")
    """
    styles = default

    if style_json == None:
        return styles

    if "align" in style_json:
        if style_json["align"] in ("center", "left", "right"):
            styles["align"] = style_json["align"]

    if "font" in style_json:
        if style_json["font"] in ("a", "b"):
            styles["font"] = style_json["font"]

    if "width" in style_json:
        width = int(style_json["width"])
        if width >= 1 and width <= 8:
            styles["width"] = width

    if "height" in style_json:
        height = int(style_json["height"])
        if height >= 1 and width <= 8:
            styles["height"] = height

    if "invert" in style_json:
        invert = int(style_json["invert"])
        styles["invert"] = bool(invert)

    if "text_type" in style_json:
        if style_json["text_type"] in ("B", "U", "BU"):
            styles["text_type"] = style_json["text_type"]

    return styles

# enf def
