(value, direction=None)
return border_dict
Parse border string into a dictionary of outline properties.

    The font CSS property is a shorthand for border-width, border-style, and border-color.

    Reference:
    - https://www.w3.org/TR/2011/REC-CSS2-20110607/box.html#border-properties
Parse border string into a dictionary of outline properties.
Parse border string into a dictionary of outline properties .
def border(value, direction=None):
    """
    Parse border string into a dictionary of outline properties.

    The font CSS property is a shorthand for border-width, border-style, and border-color.

    Reference:
    - https://www.w3.org/TR/2011/REC-CSS2-20110607/box.html#border-properties
    """
    if value:
        if isinstance(value, str):
            values = [val.strip() for val in value.split()]
        elif isinstance(value, Sequence):
            values = value
        else:
            raise ValueError('Unknown border %s ' % value)
    else:
        raise ValueError('Unknown border %s ' % value)

    # We iteratively split by the first left hand space found and try to validate if that part
    # is a valid <border-width> or <border-style> or <border-color> (which can come in any order)

    # We use this dictionary to store parsed values and check that values properties are not
    # duplicated
    border_dict = {}
    for idx, part in enumerate(values):
        if idx > 2:
            # Border can have a maximum of 3 parts
            raise ValueError('Border property shorthand contains too many parts!')

        border_dict = _parse_border_property_part(part, border_dict, direction=direction)

    return border_dict
def border ( value , direction = None ) : if value : if isinstance ( value , str ) : values = [ val . strip ( ) for val in value . split ( ) ] elif isinstance ( value , Sequence ) : values = value else : raise ValueError ( 'Unknown border %s ' % value ) else : raise ValueError ( 'Unknown border %s ' % value ) # We iteratively split by the first left hand space found and try to validate if that part # is a valid <border-width> or <border-style> or <border-color> (which can come in any order) # We use this dictionary to store parsed values and check that values properties are not # duplicated border_dict = { } for idx , part in enumerate ( values ) : if idx > 2 : # Border can have a maximum of 3 parts raise ValueError ( 'Border property shorthand contains too many parts!' ) border_dict = _parse_border_property_part ( part , border_dict , direction = direction ) return border_dict