xtuml/load.py
def _populate_instance_with_positional_arguments(metamodel, stmt):
        '''
        Populate a *metamodel* with an instance previously encountered from 
        input that was defined using positional arguments.
        '''
        if stmt.kind.upper() not in metamodel.metaclasses:
            names = ['_%s' % idx for idx in range(len(stmt.values))]
            ModelLoader._populate_matching_class(metamodel, stmt.kind, 
                                                 names, stmt.values)
            
        metaclass = metamodel.find_metaclass(stmt.kind)
        if len(metaclass.attributes) != len(stmt.values):
            logger.warn('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))
                
        inst = metamodel.new(stmt.kind)
        for attr, value in zip(metaclass.attributes, stmt.values):
            name, ty = attr
            py_value = deserialize_value(ty, value)
            if py_value is None:
                raise ParsingException("%s:%d:unable to deserialize "\
                                       "%s to a %s" % (stmt.filename,
                                                       stmt.lineno,
                                                       value,
                                                       ty))

            inst.__dict__[name] = py_value
        
        return inst
def _populate_instance_with_positional_arguments(metamodel, stmt):
        '''
        Populate a *metamodel* with an instance previously encountered from 
        input that was defined using positional arguments.
        '''
        if stmt.kind.upper() not in metamodel.metaclasses:
            names = ['_%s' % idx for idx in range(len(stmt.values))]
            ModelLoader._populate_matching_class(metamodel, stmt.kind, 
                                                 names, stmt.values)
            
        metaclass = metamodel.find_metaclass(stmt.kind)
        if len(metaclass.attributes) != len(stmt.values):
            logger.warn('%s:%d:schema mismatch' % (stmt.filename, stmt.lineno))
                
        inst = metamodel.new(stmt.kind)
        for attr, value in zip(metaclass.attributes, stmt.values):
            name, ty = attr
            py_value = deserialize_value(ty, value)
            if py_value is None:
                raise ParsingException("%s:%d:unable to deserialize "\
                                       "%s to a %s" % (stmt.filename,
                                                       stmt.lineno,
                                                       value,
                                                       ty))

            inst.__dict__[name] = py_value
        
        return inst
Populate a *metamodel* with an instance previously encountered from 
        input that was defined using positional arguments.