Пример #1
0
def update_cyphy(version, upstream_rev):
    subprocess.check_call('git checkout {} ./CyPhyML.xme'.format(upstream_rev), shell=True)
    project = Dispatch("Mga.MgaProject")
    project.Create("MGA=" + "CyPhyML.mga", "MetaGME")
    import_xme(project, "CyPhyML.xme")

    do_mods(project, cyphy_mods)

    with in_tx(project):
        for lib in (l for l in project.RootFolder.ChildFolders if l.LibraryName):
            original_lib_relid = lib.RelID
            lib.RefreshLibrary(lib.LibraryName)
            lib = project.RootFolder.ChildObjectByRelID(original_lib_relid)

    import_xme(project, "CyPhyML-tonka.xme")

    with in_tx(project):
        project.RootFolder.GetObjectByPathDisp("/@Schematic|kind=SheetFolder/@EDACad|kind=ParadigmSheet/@CADModel|kind=ModelProxy").Referred = \
            project.RootFolder.GetObjectByPathDisp("/@CAD|kind=SheetFolder/@3_SolidModeling|kind=ParadigmSheet/@CADModel|kind=Model")

        libs = [lib for lib in project.RootFolder.ChildFolders if lib.LibraryName]
        assert len(libs) == 2
        libs.sort(key=lambda lib: lib.ID)
        original_lib, copy_lib = libs
        print(original_lib.AbsPath)
        print(copy_lib.AbsPath)

        switch_lib(from_=copy_lib, to=original_lib)
        copy_lib.DestroyObject()
        metaint_currentobj = project.RootFolder.GetObjectByPathDisp("/@Ports")

        project.Version = version

    project.Save()

    with in_tx(project):
        for fco in project.AllFCOs(project.CreateFilter()):
            if fco.ObjType == OBJTYPE_REFERENCE and fco.Referred is None:
                raise ValueError('Null reference {}'.format(fco.AbsPath))

    metaint = Dispatch("MGA.Interpreter.MetaInterpreter")
    metaint.InvokeEx(project, metaint_currentobj, Dispatch("Mga.MgaFCOs"), 128)
    # launcher = win32com.client.DispatchEx("Mga.MgaLauncher")
    # launcher.RunComponent("MGA.Interpreter.MetaInterpreter", self.project, N)

    project.Save()

    dumper = Dispatch("Mga.MgaDumper")
    dumper.DumpProject(project, "CyPhyML.xme")
    project.Close(True)