コード例 #1
0
ファイル: cli.py プロジェクト: benthomasson/fsm-designer
def generate(template, fsm_design, output_module):
    module_name = os.path.splitext(os.path.basename(output_module))[0]
    with open(fsm_design) as f:
        missing_states, missing_transitions = validate_design(yaml.load(f.read()), Module(module_name))
    code = generate_code(template, missing_states, missing_transitions)
    with open(output_module, 'w') as f:
        f.write(code)
コード例 #2
0
ファイル: cli.py プロジェクト: benthomasson/fsm-designer
def validate(fsm_design, module_name):
    module = _load_module(module_name)
    with open(fsm_design) as f:
        missing_states, missing_transitions = validate_design(yaml.load(f.read()), module)
    code = generate_code(missing_states, missing_transitions)
    if missing_states or missing_transitions:
        logger.error("FSM design validation failed for %s", module_name)
        logger.error("Add these states and transitions")
        print code
        return False
    else:
        logger.info("FSM design validation passed!")
        return True