def filter_prop_defs(prop_defs, hierarchy, cls_names):
    """ Reads through the prop_defs and returns a dictionary filtered by the
        current class

    args:
        prop_defs: the defintions from the rdf vocabulary defintion
        cls_object: the class object to tie the property
        cls_names: the name of the classes
    """

    def _is_valid(test_list, valid_list):
        """ reads the list of classes in appliesToClass and returns whether
            the test_list matches

        args:
            test_list: the list of clasees to test against
            valid_list: list of possible matches
        """

        for test in test_list:
            if test in valid_list:
                return True
        return False

    new_dict = {}
    valid_classes = [Uri('kdr_AllClasses')] + cls_names + hierarchy
    for def_name, value in prop_defs.items():
        new_dict[def_name] = []
        empty_def = []
        try:
            for item in value:
                if item.get('kds_appliesToClass'):
                    if _is_valid(item['kds_appliesToClass'], valid_classes):
                        new_dict[def_name].append(item)
                else:
                    empty_def.append(item)
            if not new_dict[def_name]:
                new_dict[def_name] = empty_def
        except AttributeError:
            new_dict[def_name] = value
    return new_dict
def filter_prop_defs ( prop_defs , hierarchy , cls_names ) : def _is_valid ( test_list , valid_list ) : for test in test_list : if test in valid_list : return True return False new_dict = { } valid_classes = [ Uri ( 'kdr_AllClasses' ) ] + cls_names + hierarchy for def_name , value in prop_defs . items ( ) : new_dict [ def_name ] = [ ] empty_def = [ ] try : for item in value : if item . get ( 'kds_appliesToClass' ) : if _is_valid ( item [ 'kds_appliesToClass' ] , valid_classes ) : new_dict [ def_name ] . append ( item ) else : empty_def . append ( item ) if not new_dict [ def_name ] : new_dict [ def_name ] = empty_def except AttributeError : new_dict [ def_name ] = value return new_dict
Reads through the prop_defs and returns a dictionary filtered by the
        current class

    args:
        prop_defs: the defintions from the rdf vocabulary defintion
        cls_object: the class object to tie the property
        cls_names: the name of the classes