def openAndHandleCategoryErrors(self, uri, catFile=''): if catFile: if uri.startswith('zip://') and uri.endswith('.zip'): openuri = uri +'://'+ catFile else: openuri = os.path.join(uri, catFile) else: openuri = uri try: prot, cat, res, _uri = Explorer.splitURI(openuri) if prot not in ExplorerNodes.fileOpenDlgProtReg: return None if catFile: res = os.path.dirname(res) return Explorer.getTransport(prot, cat, res, self.transports) except Explorer.TransportCategoryError, err: prot = string.split(uri, ':')[0] # bare protocol entered, route to right toplevel node if err.args[0] == _('Category not found') and err.args[1]==catFile: if prot == 'root': self.open(self.transports) return self.transports elif self.transportsByProtocol.has_key(prot): node = self.transportsByProtocol[prot] self.open(node) return node else: raise else: raise
def GetFilePath(self): prot, cat, res, uri = Explorer.splitURI(self.GetPath()) assert prot == 'file', _('Only filesystem paths allowed') return res
def OnGotoSource(self, event=None): selection = self.getSelection() if selection != -1: entry = self.stack[selection] lineno = entry['lineno'] modname = entry['modname'] filename = entry['client_filename'] if not filename: return editor = self.debugger.editor editor.SetFocus() try: editor.openOrGotoModule(filename) except Explorer.TransportLoadError, err: serverPath = entry['filename'] if serverPath[0] == '<' and serverPath[-1] == '>': wx.LogError( _('Not a source file: %s, probably an executed ' 'string.') % serverPath) return res = wx.MessageBox( _('Could not open file: %s.\n\nIf This is a ' 'server path for which you\nhave not defined a mapping ' 'click "Yes" to browse to the file to the mapping can ' 'be computed.\nPress "No" to open the path dialog.') % filename, _('File Open Error, try to compute path?'), wx.ICON_WARNING | wx.YES_NO | wx.CANCEL) if res == wx.YES: clientPath = editor.openFileDlg( curfile=os.path.basename(filename)) if clientPath: clientPath = prevClientPath = Explorer.splitURI( clientPath)[2] prevServerPath = serverPath while 1: serverPath, serverBase = os.path.split(serverPath) clientPath, clientBase = os.path.split(clientPath) if serverBase != clientBase: paths = self.debugger.serverClientPaths[:] paths.append((prevServerPath, prevClientPath)) if self.debugger.OnPathMappings(paths=paths): self.refreshClientFilenames() break if not serverPath or not clientPath: wx.LogError(_('Paths are identical')) break prevClientPath = clientPath prevServerPath = serverPath elif res == wxNO: if self.debugger.OnPathMappings(): self.refreshClientFilenames() return model = editor.getActiveModulePage().model view = model.getSourceView() if view is not None: view.focus() view.SetFocus() view.selectLine(lineno - 1)
def OnGotoSource(self, event=None): selection = self.getSelection() if selection != -1: entry = self.stack[selection] lineno = entry["lineno"] modname = entry["modname"] filename = entry["client_filename"] if not filename: return editor = self.debugger.editor editor.SetFocus() try: editor.openOrGotoModule(filename) except Explorer.TransportLoadError, err: serverPath = entry["filename"] if serverPath[0] == "<" and serverPath[-1] == ">": wx.LogError(_("Not a source file: %s, probably an executed " "string.") % serverPath) return res = wx.MessageBox( _( "Could not open file: %s.\n\nIf This is a " "server path for which you\nhave not defined a mapping " 'click "Yes" to browse to the file to the mapping can ' 'be computed.\nPress "No" to open the path dialog.' ) % filename, _("File Open Error, try to compute path?"), wx.ICON_WARNING | wx.YES_NO | wx.CANCEL, ) if res == wx.YES: clientPath = editor.openFileDlg(curfile=os.path.basename(filename)) if clientPath: clientPath = prevClientPath = Explorer.splitURI(clientPath)[2] prevServerPath = serverPath while 1: serverPath, serverBase = os.path.split(serverPath) clientPath, clientBase = os.path.split(clientPath) if serverBase != clientBase: paths = self.debugger.serverClientPaths[:] paths.append((prevServerPath, prevClientPath)) if self.debugger.OnPathMappings(paths=paths): self.refreshClientFilenames() break if not serverPath or not clientPath: wx.LogError(_("Paths are identical")) break prevClientPath = clientPath prevServerPath = serverPath elif res == wx.NO: if self.debugger.OnPathMappings(): self.refreshClientFilenames() return model = editor.getActiveModulePage().model view = model.getSourceView() if view is not None: view.focus() view.SetFocus() view.selectLine(lineno - 1)