def test_remove_globals(self):
     m = ooaofooa.empty_model(load_globals=False)
     s = xtuml.serialize_instances(m)
     self.assertFalse(s)
     
     m = ooaofooa.empty_model(load_globals=True)
     s = xtuml.serialize_instances(m)
     self.assertTrue(s)
     
     ooaofooa.delete_globals(m)
     s = xtuml.serialize_instances(m)
     self.assertFalse(s)
Beispiel #2
0
    def test_remove_globals(self):
        m = ooaofooa.empty_model(load_globals=False)
        s = xtuml.serialize_instances(m)
        self.assertFalse(s)

        m = ooaofooa.empty_model(load_globals=True)
        s = xtuml.serialize_instances(m)
        self.assertTrue(s)

        ooaofooa.delete_globals(m)
        s = xtuml.serialize_instances(m)
        self.assertFalse(s)
Beispiel #3
0
    def test_clone(self):
        s_ee = self.metamodel.new('S_EE',
                                  Name='Test',
                                  Descrip='test',
                                  Key_Lett='TEST')
        pe_pe = self.metamodel.new('PE_PE')
        self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))

        m = ooaofooa.empty_model()
        self.assertNotEqual(pe_pe, m.clone(pe_pe))
        self.assertNotEqual(s_ee, m.clone(s_ee))

        s_ee_clone = m.select_any('S_EE', where(Name='Test'))
        self.assertNotEqual(s_ee, s_ee_clone)
        self.assertEqual(s_ee_clone.EE_ID, s_ee.EE_ID)
        self.assertEqual(s_ee_clone.Name, s_ee.Name)
        self.assertEqual(s_ee_clone.Descrip, s_ee.Descrip)
        self.assertEqual(s_ee_clone.Key_Lett, s_ee.Key_Lett)

        pe_pe_clone = xtuml.navigate_one(s_ee_clone).PE_PE[8001]()
        self.assertTrue(pe_pe_clone)
        self.assertNotEqual(pe_pe, pe_pe_clone)
        self.assertEqual(pe_pe_clone.Element_ID, pe_pe.Element_ID)
        self.assertEqual(pe_pe_clone.Visibility, pe_pe.Visibility)
        self.assertEqual(pe_pe_clone.Package_ID, pe_pe.Package_ID)
        self.assertEqual(pe_pe_clone.Component_ID, pe_pe.Component_ID)
        self.assertEqual(pe_pe_clone.type, pe_pe.type)
Beispiel #4
0
 def wrapper(*args):
     m = ooaofooa.empty_model()
     
     pe_pe = m.new('PE_PE')
     s_sync = m.new('S_SYNC', Name=fn.__name__)
     relate(pe_pe, s_sync, 8001)
     
     s_sync.Action_Semantics_internal = translate_text(m, fn.__doc__)
     
     args = list(args)
     args.append(m)
     fn(*args)
Beispiel #5
0
    def wrapper(*args):
        m = ooaofooa.empty_model()

        pe_pe = m.new('PE_PE')
        s_sync = m.new('S_SYNC', Name=fn.__name__)
        relate(pe_pe, s_sync, 8001)

        s_sync.Action_Semantics_internal = translate_text(m, fn.__doc__)

        args = list(args)
        args.append(m)
        fn(*args)
 def test_clone(self):
     s_ee = self.metamodel.new('S_EE', Name='Test', Descrip='test', Key_Lett='TEST')
     pe_pe = self.metamodel.new('PE_PE')
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     
     m = ooaofooa.empty_model()
     self.assertNotEqual(pe_pe, m.clone(pe_pe))
     self.assertNotEqual(s_ee, m.clone(s_ee))
     
     s_ee_clone = m.select_any('S_EE', where(Name='Test'))
     self.assertNotEqual(s_ee, s_ee_clone)
     self.assertEqual(s_ee_clone.EE_ID, s_ee.EE_ID)
     self.assertEqual(s_ee_clone.Name, s_ee.Name)
     self.assertEqual(s_ee_clone.Descrip, s_ee.Descrip)
     self.assertEqual(s_ee_clone.Key_Lett, s_ee.Key_Lett)
     
     pe_pe_clone = xtuml.navigate_one(s_ee_clone).PE_PE[8001]()
     self.assertTrue(pe_pe_clone)
     self.assertNotEqual(pe_pe, pe_pe_clone)
     self.assertEqual(pe_pe_clone.Element_ID, pe_pe.Element_ID)
     self.assertEqual(pe_pe_clone.Visibility, pe_pe.Visibility)
     self.assertEqual(pe_pe_clone.Package_ID, pe_pe.Package_ID)
     self.assertEqual(pe_pe_clone.Component_ID, pe_pe.Component_ID)
     self.assertEqual(pe_pe_clone.type, pe_pe.type)
Beispiel #7
0

def translate_docstring(fn):
    '''
    decorator function for translating the docstring of a function
    from rsl to oal.
    '''
    @functools.wraps(fn)
    def wrapper(*args):
        m = ooaofooa.empty_model()
        
        pe_pe = m.new('PE_PE')
        s_sync = m.new('S_SYNC', Name=fn.__name__)
        relate(pe_pe, s_sync, 8001)
        
        s_sync.Action_Semantics_internal = translate_text(m, fn.__doc__)
        
        args = list(args)
        args.append(m)
        fn(*args)
        
    return wrapper


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    m = ooaofooa.empty_model()
    oal = translate_file(m, sys.argv[1])
    print (oal)
    
Beispiel #8
0
    return ''.join(strings).strip('\n ')


def translate_docstring(fn):
    '''
    decorator function for translating the docstring of a function
    from rsl to oal.
    '''
    @functools.wraps(fn)
    def wrapper(*args):
        m = ooaofooa.empty_model()

        pe_pe = m.new('PE_PE')
        s_sync = m.new('S_SYNC', Name=fn.__name__)
        relate(pe_pe, s_sync, 8001)

        s_sync.Action_Semantics_internal = translate_text(m, fn.__doc__)

        args = list(args)
        args.append(m)
        fn(*args)

    return wrapper


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    m = ooaofooa.empty_model()
    oal = translate_file(m, sys.argv[1])
    print(oal)
def main():
    parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path...]",
                                   formatter=optparse.TitledHelpFormatter())
                                   
    parser.set_description(__doc__.strip())
    
    parser.add_option("-o", "--output", dest='output', metavar="PATH",
                      help="save sql model instances to PATH",
                      action="store", default='/dev/stdout')
    
    parser.add_option("-v", "--verbosity", dest='verbosity', action="count",
                      help="increase debug logging level", default=2)
    
    (opts, args) = parser.parse_args()
    if len(args) == 0 or None in [opts.output]:
        parser.print_help()
        sys.exit(1)

    levels = {
              0: logging.ERROR,
              1: logging.WARNING,
              2: logging.INFO,
              3: logging.DEBUG,
    }
    logging.basicConfig(level=levels.get(opts.verbosity, logging.DEBUG))
    
    m1 = bridgepoint.load_metamodel(args, load_globals=True)
    m2 = ooaofooa.empty_model()
    
    dt_boolean = m2.select_any('S_DT', where(Name='boolean'))
    dt_integer = m2.select_any('S_DT', where(Name='integer'))
    dt_real = m2.select_any('S_DT', where(Name='real'))
    dt_string = m2.select_any('S_DT', where(Name='string'))
    dt_unique_id = m2.select_any('S_DT', where(Name='unique_id'))
    dt_void = m2.select_any('S_DT', where(Name='void'))
    
    pe_pe = m2.new('PE_PE', Visibility=True, type=7)
    ep_pkg = m2.new('EP_PKG', Name='SQL_Instance_Stream_Provider')
    relate(pe_pe, ep_pkg, 8001)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Connect',
                         Action_Semantics_internal=gen_connect(m1))
    mk_parameters(s_sync, from_id=dt_unique_id, from_key_letter=dt_string,
                  to_id=dt_unique_id, to_key_letter=dt_string, rel_id=dt_string)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Connect_Using',
                         Action_Semantics_internal=gen_connect_using(m1))
    mk_parameters(s_sync, from_id=dt_unique_id, from_key_letter=dt_string,
                  to_id=dt_unique_id, to_key_letter=dt_string, 
                  using_id=dt_unique_id, rel_id=dt_string)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_New',
                         Action_Semantics_internal=gen_new(m1))
    mk_parameters(s_sync, key_letter=dt_string)
    unrelate(s_sync, dt_void, 25)
    relate(s_sync, dt_unique_id, 25)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Boolean',
                         Action_Semantics_internal=gen_set_boolean(m1))
    mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id,
                  name=dt_string, value=dt_boolean)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Integer',
                         Action_Semantics_internal=gen_set_integer(m1))
    mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id,
                  name=dt_string, value=dt_integer)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Real',
                         Action_Semantics_internal=gen_set_real(m1))
    mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id,
                  name=dt_string, value=dt_real)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_String',
                         Action_Semantics_internal=gen_set_string(m1))
    mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id,
                  name=dt_string, value=dt_string)
    
    s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Unique_Id',
                         Action_Semantics_internal=gen_set_unique_id(m1))
    mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id,
                  name=dt_string, value=dt_unique_id)
    
    ooaofooa.delete_globals(m2)
    
    with open(opts.output, 'w') as f:
        f.write('-- root-types-contained: Package_c\n')
        f.write('-- generics\n')
        f.write('-- BP 7.1 content: StreamData syschar: 3 persistence-version: 7.1.6\n')
        f.write(xtuml.serialize_instances(m2))