examples/gen_rt_integrity_check.py
def main():
    '''
    Parse argv for options and arguments, and start schema generation.
    '''
    parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path...]",
                                   formatter=optparse.TitledHelpFormatter())
                                   
    parser.set_description(__doc__.strip())
    
    parser.add_option("-f", "--function", dest="function", metavar="NAME",
                      help="append integrity checking actions to functions named NAME (required)",
                      action="store", default=None)
    
    parser.add_option("-o", "--output", dest='output', metavar="PATH",
                      help="save sql model instances to PATH (required)",
                      action="store", default=None)
    
    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, 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))

    m = ooaofooa.load_metamodel(args)
    for c_c in m.select_many('C_C'):

        filt = lambda sel: ooaofooa.is_contained_in(sel, c_c) and sel.Name == opts.function
        s_sync = m.select_any('S_SYNC', filt)
        if not s_sync:
            s_sync = m.new('S_SYNC', Name=opts.function)
            pe_pe = m.new('PE_PE')
            s_dt = m.select_any('S_DT', where(Name='boolean'))
            
            relate(pe_pe, s_sync, 8001)
            relate(s_dt, s_sync, 25)

        generate_actions(m, c_c, s_sync)
    
    xtuml.persist_instances(m, opts.output)
def main():
    '''
    Parse argv for options and arguments, and start schema generation.
    '''
    parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path...]",
                                   formatter=optparse.TitledHelpFormatter())
                                   
    parser.set_description(__doc__.strip())
    
    parser.add_option("-f", "--function", dest="function", metavar="NAME",
                      help="append integrity checking actions to functions named NAME (required)",
                      action="store", default=None)
    
    parser.add_option("-o", "--output", dest='output', metavar="PATH",
                      help="save sql model instances to PATH (required)",
                      action="store", default=None)
    
    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, 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))

    m = ooaofooa.load_metamodel(args)
    for c_c in m.select_many('C_C'):

        filt = lambda sel: ooaofooa.is_contained_in(sel, c_c) and sel.Name == opts.function
        s_sync = m.select_any('S_SYNC', filt)
        if not s_sync:
            s_sync = m.new('S_SYNC', Name=opts.function)
            pe_pe = m.new('PE_PE')
            s_dt = m.select_any('S_DT', where(Name='boolean'))
            
            relate(pe_pe, s_sync, 8001)
            relate(s_dt, s_sync, 25)

        generate_actions(m, c_c, s_sync)
    
    xtuml.persist_instances(m, opts.output)
Parse argv for options and arguments, and start schema generation.