Beispiel #1
0
class TestDecorators(unittest.TestCase):
    def test_MetaGME(self):
        self.runDecorators(os.environ['GME_ROOT'] +
                           r"\Paradigms\MetaGME\MetaGME-model.xme")

    def test_UML(self):
        self.runDecorators(os.environ['GME_ROOT'] +
                           r"\Paradigms\UML\UMLMeta.xme")

    def runDecorators(self, xme_file):
        mga = GPyUnit.util.parse_xme(self.connstr, xme_file)
        mga.Save()
        mga.Close()

        self.gme = DispatchEx("GME.Application")
        self.gme.OpenProject(self.connstr)
        dumpwmf = DispatchEx("MGA.DumpWMF")
        dumpwmf.DumpWMFs(self.outdir, self.gme)

    outdir = None
    gme = None

    def tearDown(self):
        if self.gme:
            self.gme.Exit()
            del (self.gme)
        import glob
        if self.outdir:
            for file in glob.glob(self.outdir + '/*'):
                os.unlink(file)

    def setUp(self):
        outdir = _adjacent_file("TestDecoratorsOutput")
        if not os.path.isdir(outdir):
            os.mkdir(outdir)
        self.outdir = outdir

    @property
    def connstr(self):
        return "MGA=" + _adjacent_file("TestDecorators.mga")
Beispiel #2
0
def mga2xme(mganame, xmename=''):
    """Given an mga file, it exports to xml format using the GME.Application COM object
        When the method exits the GME.Application object remains alive, so upon the next
        invokation the same object will be used. Beware if you make testcases involving
        the GME.Application object, leave the object in a state regarding that this method 
        tries to open a project.
        """
    if xmename == '':
        xmename = mganame + '.xme'

    try:
        gme = DispatchEx("GME.Application")
    except:
        raise 'Could not create GME.Application'

    try:
        gme.OpenProject("MGA=" + mganame)

        gme.ExportProject(xmename)
        gme.CloseProject(0)
        return xmename
    except:
        gme.CloseProject(0)
Beispiel #3
0
def doit(source, target):
    errors = 0
    errors_with_files = ""
    fs = []
    source_dir = ''
    target_dir = target

    if os.path.isdir(source):
        source_dir = source
        fs = mgafiles(os.path.abspath(os.path.join(os.path.curdir,
                                                   source_dir)))
    elif os.path.isfile(source):
        fs.append(source)
    else:
        raise 'File/Directory not given consistently'

    for i in fs:
        mganame = os.path.join(source_dir, i)
        mganame = os.path.abspath(os.path.join(os.path.curdir, mganame))

        xmename = os.path.join(target_dir, os.path.split(i)[1] + ".xme")
        xmename = os.path.abspath(os.path.join(os.path.curdir, xmename))

        try:
            gme = DispatchEx("GME.Application")
            gme.Visible = 0
            gme.OpenProject("MGA=" + mganame)

            gme.ExportProject(xmename)
            gme.CloseProject(0)
        except:
            errors = errors + 1
            errors_with_files = errors_with_files + mganame + "\n"
            gme.CloseProject(0)
    pass
    return (errors, errors_with_files)