#  end 1

    print('----------------------------------------------------------')
    print('   STEP 2: Resolve the imports and flatten                ')
    print('----------------------------------------------------------')

    import_path = os.path.dirname(model_file)
    #  2.a
    #      Create an Importer instance and use it to resolve the imports in your model.
    importer = Importer()
    importer.resolveImports(model, import_path)

    #  2.b
    #      Check that the importer has not raised any issues.
    print_issues(importer)

    #  2.c
    #      Use the importer to create a flattened version of the model.
    flatModel = importer.flattenModel(model)

    #  end 2

    print('----------------------------------------------------------')
    print('   STEP 3: Validate and analyse the flattened model       ')
    print('----------------------------------------------------------')

    #  3.a
    #      Create a Validator instance, pass in the flattened model, and check that
    #      there are no issues raised.
    validator = Validator()
Exemplo n.º 2
0
    #      Read the mystery file, MysteryModel.cellml.
    with open(model_file) as f:
        content = f.read()

    #  1.b
    #      Create a Parser item.
    parser = Parser()

    #  1.c
    #      Use the parser to deserialise the contents of the string you've read
    #      and return the model.
    model = parser.parseModel(content)

    #  1.d
    #      Check that the parser has not raised any issues.
    print_issues(parser)

    #  end 1

    print('----------------------------------------------------------')
    print('   STEP 2: Find "marco"                                   ')
    print('----------------------------------------------------------')

    #  2.a
    #      Create an Annotator item and use the setModel function to pass in the parsed
    #      mystery model.
    annotator = Annotator()
    annotator.setModel(model)

    #  end 2.a