コード例 #1
0
def main():
    '''
    Parse command line options and launch the interpreter
    '''
    parser = optparse.OptionParser(
        usage="%prog [options] <model_path> [another_model_path..]",
        version=xtuml.version.complete_string,
        formatter=optparse.TitledHelpFormatter())

    parser.add_option("-v",
                      "--verbosity",
                      dest='verbosity',
                      action="count",
                      default=1,
                      help="increase debug logging level")

    parser.add_option("-f",
                      "--function",
                      dest='function',
                      action="store",
                      help="invoke function named NAME",
                      metavar='NAME')

    parser.add_option("-c",
                      "--component",
                      dest='component',
                      action="store",
                      help="look for the function in a component named NAME",
                      metavar='NAME',
                      default=None)

    (opts, args) = parser.parse_args()
    if len(args) == 0 or not opts.function:
        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))

    from bridgepoint import ooaofooa
    mm = ooaofooa.load_metamodel(args)
    c_c = mm.select_any('C_C', where(Name=opts.component))
    domain = ooaofooa.mk_component(mm, c_c, derived_attributes=False)

    func = domain.find_symbol(opts.function)
    return func()
コード例 #2
0
def main():
    if len(sys.argv) < 2:
        logger.info('usage: %s <path to ooaofooa model folder>' % sys.argv[0])
        sys.exit(1)

    loader = ooaofooa.Loader()
    for filename in sys.argv[1:]:
        loader.filename_input(filename)

    m = loader.build_metamodel()

    for r_rel in m.select_many('R_REL', description_filter):
        logger.info('Filtering R%d' % r_rel.Numb)
        xtuml.delete(r_rel)

    for o_obj in m.select_many('O_OBJ', description_filter):
        logger.info('Filtering %s' % o_obj.Key_Lett)
        for r_rel in many(o_obj).R_OIR[201].R_REL[201]():
            logger.info('Filtering R%d' % r_rel.Numb)
            for r_oir in many(r_rel).R_OIR[201]():
                xtuml.unrelate(r_rel, r_oir, 201)

            xtuml.delete(r_rel)

        xtuml.delete(o_obj)

    for o_attr in m.select_many('O_ATTR', where(Name='SMspd_ID')):
        if not one(o_attr).O_RATTR[106]():
            continue

        for o_oida in many(o_attr).O_OIDA[105]():
            for o_rtida in many(o_oida).O_RTIDA[110]():
                xtuml.delete(o_rtida)
            xtuml.delete(o_oida)

        for o_ref in many(o_attr).O_RATTR[106].O_REF[108]():
            xtuml.delete(o_ref)

    c = ooaofooa.mk_component(m, None, derived_attributes=True)
    metaclass = c.find_metaclass('ACT_ACT')
    metaclass.insert_attribute(index=5,
                               name='return_value',
                               type_name='INTEGER')

    for o_obj in m.select_many('O_OBJ'):
        for o_attr in many(o_obj).O_ATTR[102](description_filter):
            logger.info('Filtering %s.%s' % (o_obj.Key_Lett, o_attr.Name))
            metaclass = c.find_metaclass(o_obj.Key_Lett)
            metaclass.delete_attribute(o_attr.Name)

    xtuml.persist_schema(c, '/dev/stdout')
コード例 #3
0
def main():
    if len(sys.argv) < 2:
        logger.info('usage: %s <path to ooaofooa model folder>' % sys.argv[0])
        sys.exit(1)
        
    loader = ooaofooa.Loader()
    for filename in sys.argv[1:]:
        loader.filename_input(filename)
    
    m = loader.build_metamodel()

    for r_rel in m.select_many('R_REL', description_filter):
        logger.info('Filtering R%d' % r_rel.Numb)
        xtuml.delete(r_rel)

    for o_obj in m.select_many('O_OBJ', description_filter):
        logger.info('Filtering %s' % o_obj.Key_Lett)
        for r_rel in many(o_obj).R_OIR[201].R_REL[201]():
            logger.info('Filtering R%d' % r_rel.Numb)
            for r_oir in many(r_rel).R_OIR[201]():
                xtuml.unrelate(r_rel, r_oir, 201)
                
            xtuml.delete(r_rel)
            
        xtuml.delete(o_obj)

    for o_attr in m.select_many('O_ATTR', where(Name='SMspd_ID')):
        if not one(o_attr).O_RATTR[106]():
            continue
            
        for o_oida in many(o_attr).O_OIDA[105]():
            for o_rtida in many(o_oida).O_RTIDA[110]():
                xtuml.delete(o_rtida)
            xtuml.delete(o_oida)

        for o_ref in many(o_attr).O_RATTR[106].O_REF[108]():
            xtuml.delete(o_ref)
            
    c = ooaofooa.mk_component(m, None, derived_attributes=True)
    metaclass = c.find_metaclass('ACT_ACT')
    metaclass.insert_attribute(index=5, name='return_value', type_name='INTEGER')

    for o_obj in m.select_many('O_OBJ'):
        for o_attr in many(o_obj).O_ATTR[102](description_filter):
            logger.info('Filtering %s.%s' % (o_obj.Key_Lett, o_attr.Name))
            metaclass = c.find_metaclass(o_obj.Key_Lett)
            metaclass.delete_attribute(o_attr.Name)
            
    xtuml.persist_schema(c, '/dev/stdout')
コード例 #4
0
ファイル: interpret.py プロジェクト: cortlandstarrett/pyxtuml
def main():
    '''
    Parse command line options and launch the interpreter
    '''
    parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path..]",
                                   version=xtuml.version.complete_string,
                                   formatter=optparse.TitledHelpFormatter())

    parser.add_option("-v", "--verbosity", dest='verbosity', action="count",
                      default=1, help="increase debug logging level")
    
    parser.add_option("-f", "--function", dest='function', action="store",
                      help="invoke function named NAME", metavar='NAME')
    
    parser.add_option("-c", "--component", dest='component', action="store",
                      help="look for the function in a component named NAME",
                      metavar='NAME', default=None)
    
    (opts, args) = parser.parse_args()
    if len(args) == 0 or not opts.function:
        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))
    
    from bridgepoint import ooaofooa
    mm = ooaofooa.load_metamodel(args)
    c_c = mm.select_any('C_C', where(Name=opts.component))
    domain = ooaofooa.mk_component(mm, c_c, derived_attributes=False)
    
    func = domain.find_symbol(opts.function)
    return func()