(value, border_dict, direction=None)
Parse border shorthand property part for known properties.
Parse border shorthand property part for known properties.
Parse border shorthand property part for known properties .
def _parse_border_property_part(value, border_dict, direction=None):
    """Parse border shorthand property part for known properties."""
    from .constants import (  # noqa
        BORDER_COLOR_CHOICES, BORDER_STYLE_CHOICES, BORDER_WIDTH_CHOICES
    )

    direction = '' if direction is None else direction + '_'
    property_validators = {
        'border_{direction}width'.format(direction=direction): BORDER_WIDTH_CHOICES,
        'border_{direction}style'.format(direction=direction): BORDER_STYLE_CHOICES,
        'border_{direction}color'.format(direction=direction): BORDER_COLOR_CHOICES,
    }

    for property_name, choices in property_validators.items():
        try:
            value = choices.validate(value)
        except (ValueError, ValidationError):
            continue

        if property_name in border_dict:
            raise ValueError('Invalid duplicated property!')

        border_dict[property_name] = value
        return border_dict

    raise ValueError('Border value "{value}" not valid!'.format(value=value))
def _parse_border_property_part ( value , border_dict , direction = None ) : from . constants import ( # noqa BORDER_COLOR_CHOICES , BORDER_STYLE_CHOICES , BORDER_WIDTH_CHOICES ) direction = '' if direction is None else direction + '_' property_validators = { 'border_{direction}width' . format ( direction = direction ) : BORDER_WIDTH_CHOICES , 'border_{direction}style' . format ( direction = direction ) : BORDER_STYLE_CHOICES , 'border_{direction}color' . format ( direction = direction ) : BORDER_COLOR_CHOICES , } for property_name , choices in property_validators . items ( ) : try : value = choices . validate ( value ) except ( ValueError , ValidationError ) : continue if property_name in border_dict : raise ValueError ( 'Invalid duplicated property!' ) border_dict [ property_name ] = value return border_dict raise ValueError ( 'Border value "{value}" not valid!' . format ( value = value ) )