xtuml/load.py
def _populate_instance_with_named_arguments(metamodel, stmt):
        '''
        Populate a *metamodel* with an instance previously encountered from 
        input that was defined using named arguments.
        '''
        if stmt.kind.upper() not in metamodel.metaclasses:
            ModelLoader._populate_matching_class(metamodel, stmt.kind, 
                                                 stmt.names, stmt.values)
            
        metaclass = metamodel.find_metaclass(stmt.kind)
            
        schema_unames = [name.upper() for name in metaclass.attribute_names]
        inst_unames = [name.upper() for name in stmt.names]
        
        if set(inst_unames) - set(schema_unames):
            logger.warn('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))
            
        inst = metamodel.new(stmt.kind)
        for name, ty in metaclass.attributes:
            uname = name.upper()
            if uname in inst_unames:
                idx = inst_unames.index(uname)
                value = deserialize_value(ty, stmt.values[idx])
                if value is None:
                    raise ParsingException("%s:%d:unable to deserialize "\
                                           "%s to a %s" % (stmt.filename,
                                                           stmt.lineno,
                                                           value,
                                                           ty))
            else:
                value = None
            
            inst.__dict__[name] = value

        return inst
def _populate_instance_with_named_arguments(metamodel, stmt):
        '''
        Populate a *metamodel* with an instance previously encountered from 
        input that was defined using named arguments.
        '''
        if stmt.kind.upper() not in metamodel.metaclasses:
            ModelLoader._populate_matching_class(metamodel, stmt.kind, 
                                                 stmt.names, stmt.values)
            
        metaclass = metamodel.find_metaclass(stmt.kind)
            
        schema_unames = [name.upper() for name in metaclass.attribute_names]
        inst_unames = [name.upper() for name in stmt.names]
        
        if set(inst_unames) - set(schema_unames):
            logger.warn('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))
            
        inst = metamodel.new(stmt.kind)
        for name, ty in metaclass.attributes:
            uname = name.upper()
            if uname in inst_unames:
                idx = inst_unames.index(uname)
                value = deserialize_value(ty, stmt.values[idx])
                if value is None:
                    raise ParsingException("%s:%d:unable to deserialize "\
                                           "%s to a %s" % (stmt.filename,
                                                           stmt.lineno,
                                                           value,
                                                           ty))
            else:
                value = None
            
            inst.__dict__[name] = value

        return inst
Populate a *metamodel* with an instance previously encountered from 
        input that was defined using named arguments.