Exemple #1
0
 def OnSaveStats(self, event):
     fn, suc = self.model.editor.saveAsDlg(\
       os.path.splitext(self.model.filename)[0]+'.prof', 'BoaIntFiles')
     if suc and self.stats:
         from Explorers.Explorer import openEx
         transport = openEx(fn)
         transport.save(transport.currentFilename(), marshal.dumps(self.stats), 'wb')
Exemple #2
0
 def OnSaveStats(self, event):
     fn, suc = self.model.editor.saveAsDlg(\
       os.path.splitext(self.model.filename)[0]+'.prof', 'BoaIntFiles')
     if suc and self.stats:
         from Explorers.Explorer import openEx
         transport = openEx(fn)
         transport.save(transport.currentFilename(), marshal.dumps(self.stats), 'wb')
Exemple #3
0
 def OnSaveReport(self, event):
     fn, ok = self.model.editor.saveAsDlg(\
       os.path.splitext(self.model.filename)[0]+'.cycles', '*.cycles')
     if ok:
         from Explorers.Explorer import openEx
         transport = openEx(fn)
         transport.save(transport.currentFilename(), self.report, 'w')
Exemple #4
0
 def OnSaveReport(self, event):
     fn, ok = self.model.editor.saveAsDlg(\
       os.path.splitext(self.model.filename)[0]+'.cycles', '*.cycles')
     if ok:
         from Explorers.Explorer import openEx
         transport = openEx(fn)
         transport.save(transport.currentFilename(), self.report, 'w')
Exemple #5
0
    def loadSizes(self, filename):
        from Explorers.Explorer import openEx, TransportError
        t = openEx(filename)
        try:
            persProps = pickle.loads(t.load())
        except SyntaxError:
            if wx.MessageBox(_('%s is possibly corrupt (cannot be unpickled), delete it?'\
                  'Default layout will be used.')%filename, _('Corrupt file'), 
                  style = wx.YES_NO | wx.ICON_EXCLAMATION) == wx.YES:
                # XXX update to use transport !!
                if filename[:7] != 'file://':
                    wx.LogMessage(_('Sorry, only supported on the filesystem'))
                else:
                    os.remove(filename[7:])

            raise TransportError(_('Corrupt layout file'))

        unmatchedPcls = persProps.keys()
        matchedShapes = []

        for shape in self.shapes:
            if persProps.has_key(shape.unqPclName):
                unmatchedPcls.remove(shape.unqPclName)
            else:
                unmatchedPcls.append(shape.unqPclName)

        for shape in self.shapes:
            if persProps.has_key(shape.unqPclName):
                pos = persProps[shape.unqPclName]
                shape.setPos(pos)

        self.redraw()
 def loadTextInfo(self, viewName):
     from Explorers.Explorer import openEx, TransportError
     fn = os.path.join(os.path.dirname(self.filename), viewName)
     ti = openEx(fn)
     try:
         data = ti.load()
     except TransportError, err:
         data = ''
Exemple #7
0
 def loadTextInfo(self, viewName):
     from Explorers.Explorer import openEx, TransportError
     fn = os.path.join(os.path.dirname(self.filename), viewName)
     ti = openEx(fn)
     try:
         data = ti.load()
     except TransportError, err:
         data = ''
Exemple #8
0
 def OnSaveHTML(self, event):
     from FileDlg import wxFileDialog
     dlg = wx.FileDialog(self, _('Save as...'), '.', '', '*.html',
       wx.SAVE | wx.OVERWRITE_PROMPT)
     try:
         if dlg.ShowModal() == wx.ID_OK:
             from Explorers.Explorer import openEx
             trpt = openEx(dlg.GetPath())
             trpt.save(trpt.currentFilename(), self.data)
     finally:
         dlg.Destroy()
Exemple #9
0
    def refreshCtrl(self):
        ListCtrlView.refreshCtrl(self)

        from Explorers.Explorer import openEx, TransportError
        manifestPath = self.getSetupDir() +'/Manifest'
        try:
            manifest = openEx(manifestPath).load()
        except TransportError, err:
            self.InsertStringItem(0, _('Error'))
            self.SetStringItem(0, 1, str(err))
            self.manifest = None
Exemple #10
0
    def refreshCtrl(self):
        ListCtrlView.refreshCtrl(self)

        from Explorers.Explorer import openEx, TransportError
        manifestPath = self.getSetupDir() +'/Manifest'
        try:
            manifest = openEx(manifestPath).load()
        except TransportError, err:
            self.InsertStringItem(0, _('Error'))
            self.SetStringItem(0, 1, str(err))
            self.manifest = None
Exemple #11
0
 def OnSaveHTML(self, event):
     from FileDlg import wxFileDialog
     dlg = wx.FileDialog(self, _('Save as...'), '.', '', '*.html',
       wx.SAVE | wx.OVERWRITE_PROMPT)
     try:
         if dlg.ShowModal() == wx.ID_OK:
             from Explorers.Explorer import openEx
             trpt = openEx(dlg.GetPath())
             trpt.save(trpt.currentFilename(), self.data)
     finally:
         dlg.Destroy()
 def save(self, overwriteNewer=False):
     ClassModel.save(self, overwriteNewer)
     for tin in self.unsavedTextInfos:
         fn = os.path.join(os.path.dirname(self.filename), tin)
         data = self.textInfos[tin]
         if data:
             from Explorers.Explorer import openEx, TransportError
             try:
                 f = openEx(fn)
                 f.save(f.currentFilename(), data)
             except TransportError, err:
                 pass
Exemple #13
0
 def save(self, overwriteNewer=False):
     ClassModel.save(self, overwriteNewer)
     for tin in self.unsavedTextInfos:
         fn = os.path.join(os.path.dirname(self.filename), tin)
         data = self.textInfos[tin]
         if data:
             from Explorers.Explorer import openEx, TransportError
             try:
                 f = openEx(fn)
                 f.save(f.currentFilename(), data)
             except TransportError, err:
                 pass
Exemple #14
0
 def printSizes(self, filename):
     """ Export the Canvas to Postscript """
     prdata = wx.PrintData()
     from Explorers.Explorer import openEx
     t = openEx(filename)
     prdata.SetFilename(t.currentFilename())
     dc = wx.PostScriptDC(prdata)
     if dc.Ok():
         dc.StartDoc('Export')
         self.Redraw(dc)
         dc.EndDoc()
         
         wx.LogMessage('Exported %s'%filename)
Exemple #15
0
    def generateFileList(self):
        """ Generate a list of modules and packages in the package path """

        from Explorers.Explorer import openEx
        transp = openEx(self.packagePath)

        filtered = []
        for item in transp.openList():
            if item.treename != '__init__.py' and \
                  (os.path.splitext(item.treename)[1] == self.ext or \
                   item.imgIdx == imgPackageModel):
                filtered.append(item)
        return filtered
    def generateFileList(self):
        """ Generate a list of modules and packages in the package path """

        from Explorers.Explorer import openEx
        transp = openEx(self.packagePath)

        filtered = []
        for item in transp.openList():
            if item.treename != '__init__.py' and \
                  (os.path.splitext(item.treename)[1] == self.ext or \
                   item.imgIdx == imgPackageModel):
                filtered.append(item)
        return filtered
Exemple #17
0
    def saveSizes(self, filename):
        """ Build a picklable dictionary of sizes/positions and save. """
        persProps = {}

        for shape in self.shapes:
            try:
                if hasattr(shape, 'unqPclName'):
                    persProps[shape.unqPclName] = shape.getPos()
            except:
                print 'error:', shape
                raise

        from Explorers.Explorer import openEx
        t = openEx(filename)
        t.save(t.currentFilename(), pickle.dumps(persProps))
Exemple #18
0
    def refreshCtrl(self):
        ListCtrlView.refreshCtrl(self)

        from Models.PythonEditorModels import BaseAppModel
        otherApp = BaseAppModel('', self.compareTo, '', self.model.editor,
                                True, {})

        from Explorers.Explorer import openEx
        otherApp.transport = openEx(self.compareTo)

        otherApp.load()
        otherApp.readModules()

        filename, otherFilename = self.model.assertLocalFile(
        ), otherApp.assertLocalFile()

        i = 0
        # Compare apps
        if not cmp(filename, otherFilename):
            i = self.addReportItems(i, (os.path.splitext(
                os.path.basename(filename))[0], otherFilename, _('changed')))

        # Find changed modules and modules not occuring in other module
        for module in self.model.modules.keys():
            if otherApp.modules.has_key(module):
                otherFile = otherApp.assertLocalFile(
                    otherApp.moduleFilename(module))
                filename = self.model.assertLocalFile(
                    self.model.moduleFilename(module))
                try:
                    if not cmp(filename, otherFile):
                        i = self.addReportItems(
                            i, (module, otherFile, _('changed')))
                except OSError:
                    pass
            else:
                i = self.addReportItems(i, (module, '', _('deleted')))

        # Find modules only occuring in other module
        for module in otherApp.modules.keys():
            if not self.model.modules.has_key(module):
                #otherFile = otherApp.moduleFilename(module)
                i = self.addReportItems(i, (module, '', _('added')))

        self.pastelise()
Exemple #19
0
    def refreshCtrl(self):
        ListCtrlView.refreshCtrl(self)

        from Models.PythonEditorModels import BaseAppModel

        otherApp = BaseAppModel("", self.compareTo, "", self.model.editor, True, {})

        from Explorers.Explorer import openEx

        otherApp.transport = openEx(self.compareTo)

        otherApp.load()
        otherApp.readModules()

        filename, otherFilename = self.model.assertLocalFile(), otherApp.assertLocalFile()

        i = 0
        # Compare apps
        if not cmp(filename, otherFilename):
            i = self.addReportItems(i, (os.path.splitext(os.path.basename(filename))[0], otherFilename, _("changed")))

        # Find changed modules and modules not occuring in other module
        for module in self.model.modules.keys():
            if otherApp.modules.has_key(module):
                otherFile = otherApp.assertLocalFile(otherApp.moduleFilename(module))
                filename = self.model.assertLocalFile(self.model.moduleFilename(module))
                try:
                    if not cmp(filename, otherFile):
                        i = self.addReportItems(i, (module, otherFile, _("changed")))
                except OSError:
                    pass
            else:
                i = self.addReportItems(i, (module, "", _("deleted")))

        # Find modules only occuring in other module
        for module in otherApp.modules.keys():
            if not self.model.modules.has_key(module):
                # otherFile = otherApp.moduleFilename(module)
                i = self.addReportItems(i, (module, "", _("added")))

        self.pastelise()
Exemple #20
0
    def refreshCtrl(self):
        from Explorers.Explorer import openEx
        self.SetReadOnly(False)
        self.ClearAll()
        if self.diffWith:
            saveout = sys.stdout
            try:
                sys.stdout = DiffPSOut(self)
                try:
                    src = StringIO(self.model.data).readlines()
                    # XXX could sometimes use data from file open in IDE ???
                    dst = StringIO(openEx(self.diffWith).load('rb')).readlines()
#                    self.model.editor.app.saveStdio = sys.stdout, sys.stderr
                    ndiff_lcompare(src, dst)
                except:
                    (sys.last_type, sys.last_value,
                     sys.last_traceback) = sys.exc_info()
                    linecache.checkcache()
                    traceback.print_exc()
            finally:
                sys.stdout = saveout
        self.SetReadOnly(True)
Exemple #21
0
 def refreshCtrl(self):
     from Explorers.Explorer import openEx
     self.SetReadOnly(False)
     self.ClearAll()
     if self.diffWith:
         saveout = sys.stdout
         try:
             sys.stdout = DiffPSOut(self)
             try:
                 src = StringIO(self.model.data).readlines()
                 # XXX could sometimes use data from file open in IDE ???
                 dst = StringIO(openEx(
                     self.diffWith).load('rb')).readlines()
                 #                    self.model.editor.app.saveStdio = sys.stdout, sys.stderr
                 ndiff_lcompare(src, dst)
             except:
                 (sys.last_type, sys.last_value,
                  sys.last_traceback) = sys.exc_info()
                 linecache.checkcache()
                 traceback.print_exc()
         finally:
             sys.stdout = saveout
     self.SetReadOnly(True)
Exemple #22
0
    def readSpecialAttrs(self, mod, cls):
        """ Read special attributes from __init__ method.

        All instance attributes defined between the top of the __init__ method
        and the _init_ctrls() method call will be available to the Designer
        as valid names bound to properties.

        For an attribute to qualify, it has to have a simple deduceable type;
        Python builtin or wxPython objects.
        If for example the attribute is bound to a variable passed in as a
        parameter, you have to first initialise it to a literal of the same
        type. This value will be used at design time.

        e.g.    def __init__(self, parent, myFrameCaption):
                    self.frameCaption = 'Design time frame caption'
                    self.frameCaption = myFrameCaption
                    self._init_ctrls(parent)

        Now you may add this attribute as a parameter or property value
        in the source by hand.

        In the Inspector property values recognised as special attributes
        will display as bold values and cannot be edited (yet).
        """
        initMeth = cls.methods['__init__']
        # determine end of attrs and possible external attrs init
        startline = initMeth.start
        extAttrInitLine = -1
        extAttrInitName = ''
        for idx in range(startline, initMeth.end):
            line = mod.source[idx].strip()
            if line.startswith('self._init_ctrls('):
                endline = idx
                break
            elif line.find('_AttrMixin.__init__(self') != -1:
                extAttrInitLine = idx
                extAttrInitName = line.split('.__init__')[0]
        else:
            raise Exception, 'self._init_ctrls not found in __init__'

        # build list of attrs
        attrs = []

        def readAttrsFromSrc(attrs, attributes, source, startline, endline):
            for attr, blocks in attributes.items():
                for block in blocks:
                    if startline <= block.start <= endline and attr not in attrs:
                        linePos = block.start - 1
                        line = source[linePos]
                        val = line[line.find('=') + 1:].strip()
                        # handle lines continued with ,
                        while val.endswith(','):
                            linePos += 1
                            val += source[linePos].strip()

                        attrs.append((attr, val))

        if extAttrInitName:
            if not mod.from_imports_names.has_key(extAttrInitName):
                raise Exception, '%s.__init__ called, but not imported in the form: '\
                      'from [ModuleName] import %s'%(extAttrInitName, extAttrInitName)
            # try to load external attrs
            extModName = mod.from_imports_names[extAttrInitName]
            extModFilename = os.path.join(os.path.dirname(self.filename),
                                          extModName + '.py')
            from Explorers.Explorer import openEx
            try:
                data = openEx(extModFilename).load()
            except Exception, error:
                raise Exception, 'Problem loading %s: File expected at: %s' % (
                    extModName, extModFilename)
            exModModel = ModuleModel(data, extModFilename, self.editor, 1)
            extModule = exModModel.getModule()
            extClass = extModule.classes[extAttrInitName]
            extMeth = extClass.methods['__init__']

            readAttrsFromSrc(attrs, extClass.attributes, extModule.source,
                             extMeth.start, extMeth.end)
    def readSpecialAttrs(self, mod, cls):
        """ Read special attributes from __init__ method.

        All instance attributes defined between the top of the __init__ method
        and the _init_ctrls() method call will be available to the Designer
        as valid names bound to properties.

        For an attribute to qualify, it has to have a simple deduceable type;
        Python builtin or wxPython objects.
        If for example the attribute is bound to a variable passed in as a
        parameter, you have to first initialise it to a literal of the same
        type. This value will be used at design time.

        e.g.    def __init__(self, parent, myFrameCaption):
                    self.frameCaption = 'Design time frame caption'
                    self.frameCaption = myFrameCaption
                    self._init_ctrls(parent)

        Now you may add this attribute as a parameter or property value
        in the source by hand.

        In the Inspector property values recognised as special attributes
        will display as bold values and cannot be edited (yet).
        """
        initMeth = cls.methods['__init__']
        # determine end of attrs and possible external attrs init
        startline = initMeth.start
        extAttrInitLine = -1
        extAttrInitName = ''
        for idx in range(startline, initMeth.end):
            line = mod.source[idx].strip()
            if line.startswith('self._init_ctrls('):
                endline = idx
                break
            elif line.find('_AttrMixin.__init__(self') != -1:
                extAttrInitLine = idx
                extAttrInitName = line.split('.__init__')[0]
        else:
            raise Exception, 'self._init_ctrls not found in __init__'

        # build list of attrs
        attrs = []

        def readAttrsFromSrc(attrs, attributes, source, startline, endline):
            for attr, blocks in attributes.items():
                for block in blocks:
                    if startline <= block.start <= endline and attr not in attrs:
                        linePos = block.start-1
                        line = source[linePos]
                        val = line[line.find('=')+1:].strip()
                        # handle lines continued with ,
                        while val.endswith(','):
                            linePos += 1
                            val += source[linePos].strip()

                        attrs.append( (attr, val) )
                            

        if extAttrInitName:
            if not mod.from_imports_names.has_key(extAttrInitName):
                raise Exception, '%s.__init__ called, but not imported in the form: '\
                      'from [ModuleName] import %s'%(extAttrInitName, extAttrInitName)
            # try to load external attrs
            extModName = mod.from_imports_names[extAttrInitName]
            extModFilename = os.path.join(os.path.dirname(self.filename),
                                          extModName+'.py')
            from Explorers.Explorer import openEx
            try:
                data = openEx(extModFilename).load()
            except Exception, error:
                raise Exception, 'Problem loading %s: File expected at: %s'%(extModName,
                                                                 extModFilename)
            exModModel = ModuleModel(data, extModFilename, self.editor, 1)
            extModule = exModModel.getModule()
            extClass = extModule.classes[extAttrInitName]
            extMeth = extClass.methods['__init__']

            readAttrsFromSrc(attrs, extClass.attributes, extModule.source,
                  extMeth.start, extMeth.end)