Пример #1
0
	def open(file, mga_to_save=None):
		if not os.path.isfile(file):
			raise Exception("'" + file + "' not found")
		extension = os.path.splitext(file)[1]
		mga = None
		if extension == ".mga":
			mga = DispatchEx("Mga.MgaProject")
			mga.Open("MGA=" + file)
			mga_to_save = file
		elif extension == ".xme":
			xme = DispatchEx("Mga.MgaParser")
			(paradigm, parversion, parguid, basename, ver) = xme.GetXMLInfo(file)

			mga = DispatchEx("Mga.MgaProject")
			xme = DispatchEx("Mga.MgaParser")
			if mga_to_save == True:
				mga_to_save = os.path.splitext(file)[0] + ".mga"
			elif not mga_to_save:
				mga_to_save = tempfile.gettempdir() + "gmepy-%s.mga" % os.getpid()
			create_project(mga, "MGA=" + mga_to_save, paradigm)
			xme.ParseProject(mga, file)
		else:
			raise Exception("Don't know how to open '%s'" % file)
		p = Project(mga)
		p.filename = file
		p.mgafile = mga_to_save
		return p
Пример #2
0
    def test_ParseMetaGME(self):
        testdir = os.path.dirname(os.path.abspath(__file__))
        inputfile = os.environ[
            'GME_ROOT'] + r"\Paradigms\MetaGME\MetaGME-model.xme"
        xme = DispatchEx("Mga.MgaParser")
        (paradigm, parversion, parguid, basename,
         ver) = xme.GetXMLInfo(inputfile)
        mga = DispatchEx("Mga.MgaProject")

        mga.Create("MGA=tmp.mga", paradigm)
        terr = mga.BeginTransactionInNewTerr()
        # GME-371: this would crash
        self.assertRaises(com_error, xme.ParseProject, mga, inputfile)
        return
        mga.CommitTransaction()
        terr.Destroy()
        mga.Save()
        mga.Close()
        del (terr)
        del (mga)
        del (xme)
Пример #3
0
def print_paradigm(xmefile):
	"Print the input file and paradigm of a given xme"
	xme = DispatchEx("Mga.MgaParser")
	(paradigm, parversion, parguid, basename, ver) = xme.GetXMLInfo(xmefile)
	print xmefile
	print paradigm
Пример #4
0
 def test_GetXMLInfo(self):
     parser = DispatchEx("Mga.MgaParser")
     xme = os.environ['GME_ROOT'] + r"\Paradigms\MetaGME\MetaGME-model.xme"
     (paradigm, parversion, parguid, basename, ver) = parser.GetXMLInfo(xme)
     assert paradigm == "MetaGME"