def _match(cls, el, spec):
        "Return the strength of the match (None if no match)"
        spec_dict = dict(zip(['type', 'group', 'label'], spec.split('.')))
        if not isinstance(el, Image) or spec_dict['type'] != 'Image':
            raise NotImplementedError("Only Image currently supported")

        sanitizers = {'group':group_sanitizer, 'label':label_sanitizer}
        strength = 1
        for key in ['group', 'label']:
            attr_value = sanitizers[key](getattr(el, key))
            if key in spec_dict:
                if spec_dict[key] != attr_value: return None
                strength += 1
        return strength
def _match ( cls , el , spec ) : spec_dict = dict ( zip ( [ 'type' , 'group' , 'label' ] , spec . split ( '.' ) ) ) if not isinstance ( el , Image ) or spec_dict [ 'type' ] != 'Image' : raise NotImplementedError ( "Only Image currently supported" ) sanitizers = { 'group' : group_sanitizer , 'label' : label_sanitizer } strength = 1 for key in [ 'group' , 'label' ] : attr_value = sanitizers [ key ] ( getattr ( el , key ) ) if key in spec_dict : if spec_dict [ key ] != attr_value : return None strength += 1 return strength
Return the strength of the match (None if no match)