rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.splitter = wxSplitterWindow(self, -1, style=wxSP_NOBORDER | wxSP_3DSASH | wxSP_FULLSASH)
self.splitter = wxSplitterWindow(self, -1, style=wxSP_NOBORDER | wxSP_3DSASH | wxSP_FULLSASH) use_images = (1 or wxPlatform == '__WXMSW__') if use_images: (stackImgIdx, breaksImgIdx, watchesImgIdx, localsImgIdx, globalsImgIdx) = range(5) else: stackImgIdx=breaksImgIdx=watchesImgIdx=localsImgIdx=globalsImgIdx=-1
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger')
use_images = (1 or wxPlatform == '__WXMSW__')
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger')
if use_images: self.nbTop.AddPage(self.stackView, 'Stack', imageId = 0) else: self.nbTop.AddPage(self.stackView, 'Stack')
self.nbTop.AddPage(self.stackView, 'Stack', imageId=stackImgIdx)
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger')
if use_images: self.nbTop.AddPage(self.breakpts, 'Breakpoints', imageId = 1) else: self.nbTop.AddPage(self.breakpts, 'Breakpoints')
self.nbTop.AddPage(self.breakpts, 'Breakpoints', imageId=breaksImgIdx)
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger')
if use_images: self.nbBottom.AddPage(self.watches, 'Watches', imageId = 2) else: self.nbBottom.AddPage(self.watches, 'Watches')
self.nbBottom.AddPage(self.watches, 'Watches', imageId=watchesImgIdx)
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger')
if use_images: self.nbBottom.AddPage(self.locs, 'Locals', imageId = 3) else: self.nbBottom.AddPage(self.locs, 'Locals')
self.nbBottom.AddPage(self.locs, 'Locals', imageId=localsImgIdx)
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger')
if use_images: self.nbBottom.AddPage(self.globs, 'Globals', imageId = 4) else: self.nbBottom.AddPage(self.globs, 'Globals')
self.nbBottom.AddPage(self.globs, 'Globals', imageId=globalsImgIdx)
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger')
if bplist.hasBreakpoint(filename, lineno): bplist.clearTemporaryBreakpoints(filename, lineno) self.sb.updateState('Breakpoint.', 'break')
def receiveDebuggerStatus(self, info): # Get stdout and stderr if available. errout = self.editor.erroutFrm data = info.get('stdout', None) if data: errout.appendToOutput(data) #self.appendToOutputWindow(data) data = info.get('stderr', None) if data: errout.appendToErrors(data) #self.appendToOutputWindow(data)
print mess, mess.__class__, mess.args[0]
def ShowErrorMessage(parent, caption, mess): print mess, mess.__class__, mess.args[0] dlg = wxMessageDialog(parent, mess.__class__.__name__ +': '+mess.args[0], caption, wxOK | wxICON_EXCLAMATION) try: dlg.ShowModal() finally: dlg.Destroy()
nId = NewId()
nId = wxNewId()
def AddToolButtonBmpObject(frame, toolbar, thebitmap, hint, triggermeth, toggleBitmap = wxNullBitmap): nId = NewId()
return nId
def AddToolButtonBmpObject(frame, toolbar, thebitmap, hint, triggermeth, toggleBitmap = wxNullBitmap): nId = NewId()
AddToolButtonBmpObject(frame, toolbar, wxBitmap(filename, wxBITMAP_TYPE_BMP),
return AddToolButtonBmpObject(frame, toolbar, wxBitmap(filename, wxBITMAP_TYPE_BMP),
def AddToolButtonBmpFile(frame, toolbar, filename, hint, triggermeth): AddToolButtonBmpObject(frame, toolbar, wxBitmap(filename, wxBITMAP_TYPE_BMP), hint, triggermeth)
AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth, IS.load(toggleBmp))
return AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth, IS.load(toggleBmp))
def AddToolButtonBmpIS(frame, toolbar, name, hint, triggermeth, toggleBmp = ''): if toggleBmp: AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth, IS.load(toggleBmp)) else: AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth)
AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth)
return AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth)
def AddToolButtonBmpIS(frame, toolbar, name, hint, triggermeth, toggleBmp = ''): if toggleBmp: AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth, IS.load(toggleBmp)) else: AddToolButtonBmpObject(frame, toolbar, IS.load(name), hint, triggermeth)
self.winConfOption = 'filedialog' self.loadDims()
def __init__(self, parent, message='Choose a file', defaultDir='.', defaultFile='', wildcard='', style=wxOPEN, pos=wxDefaultPosition): self.htmlBackCol = wxColour(192, 192, 192) self.htmlBackCol = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNFACE) self.filterOpts = ['Boa files', 'Internal files', 'Image files', 'All files']
self.dont_pop = 0
self.winConfOption = 'filedialog' self.loadDims()
def __init__(self, parent, message='Choose a file', defaultDir='.', defaultFile='', wildcard='', style=wxOPEN, pos=wxDefaultPosition): self.htmlBackCol = wxColour(192, 192, 192) self.htmlBackCol = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNFACE) self.filterOpts = ['Boa files', 'Internal files', 'Image files', 'All files']
self.lcFiles.destroy(dont_pop=self.dont_pop)
self.lcFiles.destroy()
def Destroy(self): self.htmlBackCol = None self.lcFiles.destroy(dont_pop=self.dont_pop) wxDialog.Destroy(self)
if Utils.startswith(name, partial):
if name.startswith(partial):
def OnTcfilenameKeyDown(self, event): key = event.GetKeyCode() if key == WXK_TAB: names = self.lcFiles.getAllNames() partial = self.GetFilename() for name in names: if Utils.startswith(name, partial): self.lcFiles.selectItemNamed(name) self.SetFilename(name) self.tcFilename.SetSelection(len(partial), len(name)) return else: event.Skip()
syspathnode = ExplorerNodes.nodeRegByProt['sys.path'](None, transports, None) transports.entries.append(syspathnode) transportsByProtocol[syspathnode.protocol] = syspathnode
if ExplorerNodes.nodeRegByProt.has_key('sys.path'): syspathnode = ExplorerNodes.nodeRegByProt['sys.path']( None, transports, None) transports.entries.append(syspathnode) transportsByProtocol[syspathnode.protocol] = syspathnode
def buildExplorerNodes(self): transports = ExplorerNodes.RootNode('Transport', EditorHelper.imgFolder) transports.parent = transports transports.protocol = 'root'
def destroy(self, dont_pop=0):
def destroy(self):
def destroy(self, dont_pop=0): self.menu.Destroy() Explorer.BaseExplorerList.destroy(self, dont_pop)
Explorer.BaseExplorerList.destroy(self, dont_pop)
Explorer.BaseExplorerList.destroy(self)
def destroy(self, dont_pop=0): self.menu.Destroy() Explorer.BaseExplorerList.destroy(self, dont_pop)
ExplorerNodes.fileOpenDlgProtReg.append('zip')
def OnFDEndLabelEdit(self, event): newText = event.GetText() event.Skip() if newText != self.oldLabelVal:# and isinstance(self.list.node, ZopeItemNode): self.node.renameItem(self.oldLabelVal, newText) self.refreshCurrent() self.selectItemNamed(newText) self.EnsureVisible(self.selected)
raise 'Unauthorized', 'X-Auth header missing or incorrect'
raise Exception, 'Unauthorized: X-Auth header missing or incorrect'
def _authenticate(self): h = self.headers if auth_str and (not h.has_key('x-auth') or h['x-auth'] != auth_str): raise 'Unauthorized', 'X-Auth header missing or incorrect'
self.extend_extent(lineend)
self.extent = self.extent + (lineend - linestart)
def _addmethod(self, name, sig, linestart, lineend = None, to_bottom = 1): if not lineend: lineend = linestart self.methods[name] = CodeBlock(sig, linestart, lineend) if to_bottom: self.method_order.append(name) else: self.method_order.insert(0, name) self.extend_extent(lineend)
lst.append(self.id)
if self.id in EventCollections.reservedWxIds: name, wId = self.newUnusedItemNames(0) else: wId = self.id lst.append(wId)
def addIds(self, lst): if self.id is not None: lst.append(self.id)
lst.append(constr.params[self.idProp])
wId = constr.params[self.idProp] if wId in EventCollections.reservedWxIds: name, wId = self.newUnusedItemNames(0) lst.append(wId)
def addIds(self, lst): for constr in self.textConstrLst: lst.append(constr.params[self.idProp])
return UtilityDTC.vetoedMethods(self)+['GetPosition', 'SetPosition', 'GetSize', 'SetSize']
return UtilityDTC.vetoedMethods(self)+['GetPosition', 'SetPosition', 'GetSize', 'SetSize', 'GetRect', 'SetRect']
def vetoedMethods(self): return UtilityDTC.vetoedMethods(self)+['GetPosition', 'SetPosition', 'GetSize', 'SetSize']
import urllib class GUIFancyURLopener(urllib.FancyURLopener): _user_prompt = '' _passwd_prompt = '' def prompt_user_passwd(self, host, realm): return self._user_prompt, self._passwd_prompt
def OnSave(self, event): ZopeController.OnSave(self, event) # trigger a reload after saving so that errors saved as comments in the # source are displayed self.OnReload(event)
url = 'http://%s:%d/%s/source.html'%(props['host'], props['httpport'],
url = 'http://%s:%s@%s:%d/%s/source.html'%(props['username'], props['passwd'], props['host'], props['httpport'],
def generatePage(self): props = self.model.zopeObj.properties url = 'http://%s:%d/%s/source.html'%(props['host'], props['httpport'], self.model.zopeObj.whole_name()) urllib._urlopener = gfurlo = GUIFancyURLopener() gfurlo._user_prompt = props['name'] gfurlo._passwd_prompt = props['passwd'] try: f = urllib.urlopen(url) return f.read() finally: urllib._urlopener = None
urllib._urlopener = gfurlo = GUIFancyURLopener() gfurlo._user_prompt = props['name'] gfurlo._passwd_prompt = props['passwd'] try: f = urllib.urlopen(url) return f.read() finally: urllib._urlopener = None
import urllib f = urllib.urlopen(url) return f.read()
def generatePage(self): props = self.model.zopeObj.properties url = 'http://%s:%d/%s/source.html'%(props['host'], props['httpport'], self.model.zopeObj.whole_name()) urllib._urlopener = gfurlo = GUIFancyURLopener() gfurlo._user_prompt = props['name'] gfurlo._passwd_prompt = props['passwd'] try: f = urllib.urlopen(url) return f.read() finally: urllib._urlopener = None
return f.__name, lambda: None
return f.__name__, lambda: None
def class_get(f): if hasattr(f, '__init__'): return f.__name__, f.__init__.im_func else: return f.__name, lambda: None
('wxWinButton.png', 'Images/Shared/wxWinButton.png', wxBITMAP_TYPE_PNG)]:
('wxWinButton.png', 'Images/Shared/wxWinButton.png', wxBITMAP_TYPE_PNG), ('Debian.png', 'Images/Shared/Debian.png', wxBITMAP_TYPE_PNG), ('Gentoo.png', 'Images/Shared/Gentoo.png', wxBITMAP_TYPE_PNG)]:
def addImagesToFS(): for name, path, type in [ ('Boa.jpg', 'Images/Shared/Boa.jpg', wxBITMAP_TYPE_JPEG), ('PythonPowered.png', 'Images/Shared/PythonPowered.png', wxBITMAP_TYPE_PNG), ('wxPyButton.png', 'Images/Shared/wxPyButton.png', wxBITMAP_TYPE_PNG), ('wxWinButton.png', 'Images/Shared/wxWinButton.png', wxBITMAP_TYPE_PNG)]: if name not in addImagesToFS.addedImages: wxMemoryFSHandler_AddFile(name, Preferences.IS.load(path), type) addImagesToFS.addedImages.append(name)
'memory:wxWinButton.png'))
'memory:wxWinButton.png', 'memory:Debian.png', 'memory:Gentoo.png',))
def OnLinkClick(self, event): clicked = event.linkinfo[0] if clicked == 'Credits': self.html.SetPage(credits_html % ('memory:PythonPowered.png', 'memory:wxPyButton.png', 'memory:wxWinButton.png')) elif clicked == 'Back': self.setPage() #self.html.HistoryBack() elif clicked == 'Python': self.gotoInternetUrl('http://www.python.org') elif clicked == 'wxPython': self.gotoInternetUrl('http://wxpython.org') elif clicked == 'wxWindows': self.gotoInternetUrl('http://www.wxwindows.org') elif clicked == 'Boa': self.gotoInternetUrl('http://boa-constructor.sourceforge.net') elif clicked == 'TBS': self.gotoInternetUrl('http://www.tbs.co.za') elif clicked == 'MailMe': self.gotoInternetUrl('mailto:[email protected]')
if sys and len(sys.modules) >= self.moduleTotal:
if self and sys and len(sys.modules) >= self.moduleTotal:
def monitorModuleCount(self): self._live = true lastCnt = 0 if sys and len(sys.modules) >= self.moduleTotal: wx.wxPostEvent(self, ModCntUpdateEvent(self.moduleTotal, 'importing')) else: while self and self._live and sys and len(sys.modules) < self.moduleTotal: mc = len(sys.modules) if mc > lastCnt: lastCnt = mc wx.wxPostEvent(self, ModCntUpdateEvent(mc, 'importing')) time.sleep(0.125)
mod = editor.openOrGotoModule(startupModules[0])
mod = editor.openOrGotoModule(startupModules[0])[0]
def OnInit(self): wxInitAllImageHandlers()
defaultName = 'wx.Wizard'
defaultName = 'wx.wizard.Wizard'
def getSimpleRunnerSrc(self): return ''
defaultName = 'wx.PyWizardPage'
defaultName = 'wx.wizard.PyWizardPage'
\tdef GetPrev(self):
defaultName = 'wx.WizardPageSimple'
defaultName = 'wx.wizard.WizardPageSimple'
def getSimpleRunnerSrc(self): return ''
script_fn = os.path.join(os.path.dirname(__file__),
if hasattr(sys, 'frozen'): script_fn = os.path.join(os.path.dirname(sys.executable), 'Debugger', 'ChildProcessServerStart.py') else: script_fn = os.path.join(os.path.dirname(__file__),
def spawnChild(monitor, process, args=''): """Returns an xmlrpclib.Server, a connection to an xml-rpc server, and the input and error streams. """ # Start ChildProcessServerStart.py in a new process. script_fn = os.path.join(os.path.dirname(__file__), 'ChildProcessServerStart.py') pyIntpPath = Preferences.getPythonInterpreterPath() cmd = '%s "%s" %s' % (pyIntpPath, script_fn, args) try: pid = wx.Execute(cmd, wx.EXEC_NOHIDE, process) line = '' if monitor.isAlive(): istream = process.GetInputStream() estream = process.GetErrorStream() err = '' # read in the port and auth hash while monitor.isAlive() and line.find('\n') < 0: # don't take more time than the process we wait for ;) time.sleep(0.00001) if istream.CanRead(): line = line + istream.read(1) # test for tracebacks on stderr if estream.CanRead(): err = estream.read() if LOG_TRACEBACKS: fn = os.path.join(os.path.dirname(__file__), 'DebugTracebacks.txt') open(fn, 'a').write(err) errlines = err.split('\n') while not errlines[-1].strip(): del errlines[-1] try: exctype, excvalue = errlines[-1].split(':') except ValueError: # XXX non standard output on stderr # XXX possibly warnings # XXX for now ignore it (it's non fatal) #raise UnknownError, errlines[-1] continue while errlines and errlines[-1][:7] != ' File ': del errlines[-1] if errlines: errfile = ' (%s)' % errlines[-1].strip() else: errfile = '' try: Error, val = __builtins__[exctype.strip()], (excvalue.strip()+errfile) except KeyError: Error, val = UnknownError, (exctype.strip()+':'+excvalue.strip()+errfile) raise Error, val if not KEEP_STREAMS_OPEN: process.CloseOutput() if monitor.isAlive(): line = line.strip() if not line: raise RuntimeError, ( 'The debug server address could not be read') port, auth = line.strip().split() if USE_TCPWATCH: # Start TCPWatch as a connection forwarder. from thread import start_new_thread new_port = 20202 # Hopefully free def run_tcpwatch(port1, port2): os.system("tcpwatch -L %d:127.0.0.1:%d" % ( int(port1), int(port2))) start_new_thread(run_tcpwatch, (new_port, port)) time.sleep(3) port = new_port trans = TransportWithAuth(auth) server = xmlrpclib.Server( 'http://127.0.0.1:%d' % int(port), trans) return server, istream, estream, pid, pyIntpPath else: raise RuntimeError, 'The debug server failed to start' except: if monitor.isAlive(): process.CloseOutput() monitor.kill() raise
fn = os.path.join(os.path.dirname(__file__), 'DebugTracebacks.txt')
if hasattr(sys, 'frozen'): fn = os.path.join(os.path.dirname(sys.executable), 'DebugTracebacks.txt') else: fn = os.path.join(os.path.dirname(__file__), 'DebugTracebacks.txt')
def spawnChild(monitor, process, args=''): """Returns an xmlrpclib.Server, a connection to an xml-rpc server, and the input and error streams. """ # Start ChildProcessServerStart.py in a new process. script_fn = os.path.join(os.path.dirname(__file__), 'ChildProcessServerStart.py') pyIntpPath = Preferences.getPythonInterpreterPath() cmd = '%s "%s" %s' % (pyIntpPath, script_fn, args) try: pid = wx.Execute(cmd, wx.EXEC_NOHIDE, process) line = '' if monitor.isAlive(): istream = process.GetInputStream() estream = process.GetErrorStream() err = '' # read in the port and auth hash while monitor.isAlive() and line.find('\n') < 0: # don't take more time than the process we wait for ;) time.sleep(0.00001) if istream.CanRead(): line = line + istream.read(1) # test for tracebacks on stderr if estream.CanRead(): err = estream.read() if LOG_TRACEBACKS: fn = os.path.join(os.path.dirname(__file__), 'DebugTracebacks.txt') open(fn, 'a').write(err) errlines = err.split('\n') while not errlines[-1].strip(): del errlines[-1] try: exctype, excvalue = errlines[-1].split(':') except ValueError: # XXX non standard output on stderr # XXX possibly warnings # XXX for now ignore it (it's non fatal) #raise UnknownError, errlines[-1] continue while errlines and errlines[-1][:7] != ' File ': del errlines[-1] if errlines: errfile = ' (%s)' % errlines[-1].strip() else: errfile = '' try: Error, val = __builtins__[exctype.strip()], (excvalue.strip()+errfile) except KeyError: Error, val = UnknownError, (exctype.strip()+':'+excvalue.strip()+errfile) raise Error, val if not KEEP_STREAMS_OPEN: process.CloseOutput() if monitor.isAlive(): line = line.strip() if not line: raise RuntimeError, ( 'The debug server address could not be read') port, auth = line.strip().split() if USE_TCPWATCH: # Start TCPWatch as a connection forwarder. from thread import start_new_thread new_port = 20202 # Hopefully free def run_tcpwatch(port1, port2): os.system("tcpwatch -L %d:127.0.0.1:%d" % ( int(port1), int(port2))) start_new_thread(run_tcpwatch, (new_port, port)) time.sleep(3) port = new_port trans = TransportWithAuth(auth) server = xmlrpclib.Server( 'http://127.0.0.1:%d' % int(port), trans) return server, istream, estream, pid, pyIntpPath else: raise RuntimeError, 'The debug server failed to start' except: if monitor.isAlive(): process.CloseOutput() monitor.kill() raise
resetUndo = not self.CanUndo()
resetUndo = not self.CanUndo() and not curData
def refreshCtrl(self):
dsgn.ctrlEvtHandler.OnControlSelect(event, self.GetParent())
dsgn.ctrlEvtHandler.OnControlSelect(event)
def OnControlSelect(self, event): """ Select parent of proxy container or create new control, update page reference to it and resize new ctrl to fill proxy container """ dsgn = self.designer new = dsgn.compPal.selection if self.ctrl: dsgn.selectControlByPos(self.ctrl, event.GetPosition(), event.ShiftDown()) else: dsgn.ctrlEvtHandler.OnControlSelect(event, self.GetParent())
bmp = wxImage(fn, imgs[string.lower(os.path.splitext(fn)[-1])]).ConvertToBitmap()
bmp = wxImage(fn, imgs[os.path.splitext(fn)[-1].lower()]).ConvertToBitmap()
def showImage(self, filename, node = None): if node is not None: fn = tempfile.mktemp(os.path.splitext(node.name)[-1]) open(fn, 'wb').write(node.load()) else: fn = filename
self.pasteFileSysFolder(file, newNodepath, zopeConn)
self.pasteFileSysFolder(file, newNodepath, ftpConn)
def pasteFileSysFolder(self, folderpath, nodepath, ftpConn): ftpConn.add_folder(os.path.basename(folderpath), nodepath) files = os.listdir(folderpath) folder = os.path.basename(folderpath) newNodepath = nodepath+'/'+folder for file in files: file = os.path.join(folderpath, file) if os.path.isdir(file): self.pasteFileSysFolder(file, newNodepath, zopeConn) else: ftpConn.upload(file, newNodepath)
x['keyword'] = self.func.func_code.co_varnames[n+1]
try: x['keyword'] = self.func.func_code.co_varnames[n+1] except IndexError: x['keyword'] = x['positional'] del x['positional']
def special_args(self): n = self.func.func_code.co_argcount x = {} # # # if self.func.func_code.co_flags & (self.POS_LIST|self.KEY_DICT): x['positional'] = self.func.func_code.co_varnames[n] x['keyword'] = self.func.func_code.co_varnames[n+1] elif self.func.func_code.co_flags & self.POS_LIST: x['positional'] = self.func.func_code.co_varnames[n] elif self.func.func_code.co_flags & self.KEY_DICT: x['keyword'] = self.func.func_code.co_varnames[n] return x
print "signature:", f
print "signature:",
def foo(x, y, z=-1.0, *args, **kw): return (x+y)**z
return self.GetSashPosition() != self.GetClientSize().y - self.GetSashSize()
return self.GetSashPosition()+1 != self.GetClientSize().y - self.GetSashSize()
def bottomWindowIsOpen(self): return self.GetSashPosition() != self.GetClientSize().y - self.GetSashSize()
print "Created directory: %s" % rcPath
print 'Created directory: %s' % rcPath
def toPyPath(filename): return os.path.join(pyPath, filename)
superItem = self.tree.AppendItem(suprItem, supers.name)
try: superItem = self.tree.AppendItem(suprItem, supers.name) except AttributeError: superItem = self.tree.AppendItem(suprItem, supers)
def __init__(self, parent): self._init_ctrls(parent)
if len(classes[name].super) == 0:
if not classes.has_key(name): if not root.has_key(name): root[name] = {} return root[name] elif len(classes[name].super) == 0:
def travTilBase(name, classes, root): if len(classes[name].super) == 0: if not root.has_key(name): root[name] = {} return root[name] else: c = travTilBase(classes[name].super[0].name, classes, root) if not c.has_key(name): c[name] = {} return c[name]
c = travTilBase(classes[name].super[0].name, classes, root)
super1 = classes[name].super[0] if type(super1) != type(''): super1 = super1.name c = travTilBase(super1, classes, root)
def travTilBase(name, classes, root): if len(classes[name].super) == 0: if not root.has_key(name): root[name] = {} return root[name] else: c = travTilBase(classes[name].super[0].name, classes, root) if not c.has_key(name): c[name] = {} return c[name]
return self.TALSourceToURL(source_file), ln
return self.TALSourceToURL(source_file, frame), ln
def getFilenameAndLine(self, frame): """Returns the filename and line number for the frame. Invoked often.
def TALSourceToURL(self, source_file):
def TALSourceToURL(self, source_file, frame):
def TALSourceToURL(self, source_file): if source_file.startswith('traversal:'): path = source_file[10:] if path.startswith('/'): path = path[1:] meta_type = 'Page Template' host = 'localhost:8080' # XXX XXX! return 'zopedebug://%s/%s/%s' % (host, path, meta_type) return source_file # TODO: something better
saved_source = caller.f_locals.get('saved_source') position = caller.f_locals.get('saved_position')
saved_source = caller.f_locals.get('prev_source') position = 0
def getStackInfo(self): """Returns a tuple describing the current stack. """ exc_type, exc_value, stack, frame_stack_len = ( DebugServer.getStackInfo(self))
is_import = re.compile('^[ \t]*import[ \t]*(?P<imp>[^
is_import = re.compile('^[ \t]*import[ \t]+(?P<imp>[^
obj_def = '[A-Za-z_][A-Za-z0-9_.]*'
raise 'Method exists'
raise Exception, 'Method exists'
def addMethod(self, class_name, method_name, method_params, method_body, to_bottom = 1): new_length = len(method_body) + 2 if not method_body: return a_class = self.classes[class_name] if method_name in a_class.method_order: raise 'Method exists'
return self.objectDict[self.stripThis(eventObject.GetEventObject())]
evtObj = eventObject.GetEventObject() if evtObj: return self.objectDict[self.stripThis(eventObject.GetEventObject())] else: print 'no evt obj'
def getObject(self, eventObject): return self.objectDict[self.stripThis(eventObject.GetEventObject())]
className = aclass
className = ctrl.class_name
def refreshCtrl(self): self.DeleteAllItems()
if len(module.classes[aclass].super): base = module.classes[aclass].super[0]
if len(module.classes[className].super): base = module.classes[className].super[0]
def refreshCtrl(self): self.DeleteAllItems()
idx1 = self.il.Add(PaletteMapping.bitmapForComponent(aclass, base, gray = true))
idx1 = self.il.Add(PaletteMapping.bitmapForComponent(className, base, gray = true))
def refreshCtrl(self): self.DeleteAllItems()
idx1 = self.il.Add(PaletteMapping.bitmapForComponent(aclass, 'Component'))
idx1 = self.il.Add(PaletteMapping.bitmapForComponent(className, 'Component'))
def refreshCtrl(self): self.DeleteAllItems()
Explorer.PackageFolderList.Destroy()
Explorer.PackageFolderList.destroy(self)
def destroy(self): self.menu.Destroy() from Explorers import Explorer Explorer.PackageFolderList.Destroy()
StyledTextCtrls.PythonStyledTextCtrlMix.__init__(self, wId, -1)
StyledTextCtrls.PythonStyledTextCtrlMix.__init__(self, wId, ())
def __init__(self, parent, wId): StyledTextCtrls.wxStyledTextCtrl.__init__(self, parent, wId, style = wxCLIP_CHILDREN) StyledTextCtrls.CallTipCodeHelpSTCMix.__init__(self) StyledTextCtrls.PythonStyledTextCtrlMix.__init__(self, wId, -1)
def setDebugNamespace(self, ns): pass
def setDebugNamespace(self, ns): pass
if self.interp.push(line):
if self._debugger: prompt = Preferences.ps3 val = self._debugger.getVarValue(line) if val is not None: print val return false elif self.interp.push(line):
def pushLine(self, line): self.AddText('\n') prompt = '' try: self.stdin.clear() tmpstdout,tmpstderr,tmpstdin = sys.stdout,sys.stderr,sys.stdin sys.stdout,sys.stderr,sys.stdin = self.stdout,self.stderr,self.stdin self.lastResult = '' if self.interp.push(line): prompt = Preferences.ps2 self.stdout.fin(); self.stderr.fin() return true else: # check if already destroyed if not hasattr(self, 'stdin'): return false
ll = self.GetCurrentLine()
def OnShellEnter(self, event): self.BeginUndoAction() try:
except ValueError, TypeError:
except (ValueError, TypeError):
def getTipValue(self, word, lnNo): try: obj = eval(word, self.interp.locals) except: docs = '' else: # we want to reroute wxPython objects to their doc strings # if they are defined docs = '' if hasattr(obj, '__doc__') and obj.__doc__: wxNS = Utils.getEntireWxNamespace() if type(obj) is types.ClassType: if wxNS.has_key(obj.__name__): docs = obj.__init__.__doc__ elif type(obj) is types.InstanceType: if wxNS.has_key(obj.__class__.__name__): docs = obj.__doc__ elif type(obj) is types.MethodType: if wxNS.has_key(obj.im_class.__name__): docs = obj.__doc__ # Get docs from builtin's docstrings or from Signature module if not docs: if type(obj) is types.BuiltinFunctionType: try: docs = obj.__doc__ except AttributeError: docs = '' else: from ExternalLib import Signature try: sig = str(Signature.Signature(obj)) docs = string.replace(sig, '(self, ', '(') docs = string.replace(docs, '(self)', '()') except ValueError, TypeError: try: docs = obj.__doc__ except AttributeError: docs = ''
pos = self.GetCurrentPos()
def OnShellHome(self, event): pos = self.GetCurrentPos() lnNo = self.GetCurrentLine() lnStPs = self.PositionFromLine(lnNo) line = self.GetCurLine()[0] if len(line) >=4 and line[:4] in (Preferences.ps1, Preferences.ps2): self.SetCurrentPos(lnStPs+4) self.SetAnchor(lnStPs+4) else: self.SetCurrentPos(lnStPs) self.SetAnchor(lnStPs)
'Images/Debug/Debug.png', 'Debug/Continue - %s\nRuns in debugger, ' 'stops at breaks and exceptions'%keyDefs['Debug'][2], self.OnDebug)
'Images/Debug/Debug.png', 'Debug/Continue - %s'%keyDefs['Debug'][2], self.OnDebug)
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger', style=wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|Preferences.childFrameStyle)
'Images/Debug/DebugFullSpeed.png', 'Debug/Continue full speed\nStops ' 'only at hard (code) breaks and exceptions', self.OnDebugFullSpeed)
'Images/Debug/DebugFullSpeed.png', 'Debug/Continue full speed', self.OnDebugFullSpeed)
def __init__(self, editor, filename=None, slave_mode=1): wxFrame.__init__(self, editor, -1, 'Debugger', style=wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|Preferences.childFrameStyle)
self.updateOutputWindow() def updateOutputWindow(self):
self.updateErrOutWindow() def updateErrOutWindow(self):
def OnStreamTimer(self, event=None): if self.stream_timer: self.updateOutputWindow()
if prot == 'file': return filepath elif prot == 'zope':
if prot == 'zope':
def clientFNToServerFN(self, filename): """Converts a filename on the client to a filename on the server.
else: if self.serverClientPaths: normFilepath = os.path.normcase(filepath) for serverPath, clientPath in self.serverClientPaths: normClientPath = os.path.normcase(clientPath) if normFilepath.startswith(normClientPath): return serverPath+normFilepath[len(normClientPath):] return filepath
def clientFNToServerFN(self, filename): """Converts a filename on the client to a filename on the server.
errout = self.editor.erroutFrm data = info.get('stdout', None) if data: errout.appendToOutput(data) data = info.get('stderr', None) if data: errout.appendToErrors(data)
self.updateErrOutWindow()
def receiveDebuggerStatus(self, info): # Get stdout and stderr if available. errout = self.editor.erroutFrm data = info.get('stdout', None) if data: errout.appendToOutput(data) #self.appendToOutputWindow(data) data = info.get('stderr', None) if data: errout.appendToErrors(data) #self.appendToOutputWindow(data)
self.updateOutputWindow()
self.updateErrOutWindow()
def receiveDebuggerStatus(self, info): # Get stdout and stderr if available. errout = self.editor.erroutFrm data = info.get('stdout', None) if data: errout.appendToOutput(data) #self.appendToOutputWindow(data) data = info.get('stderr', None) if data: errout.appendToErrors(data) #self.appendToOutputWindow(data)
self.toolbar.EnableTool(wid, enabled)
if wid != -1: self.toolbar.EnableTool(wid, enabled)
def enableTools(self, stepping, running): for wid, enabled in ((self.runId, stepping), (self.runFullSpdId, stepping), (self.stepId, stepping), (self.overId, stepping), (self.outId, stepping), (self.pauseId, not stepping), (self.stopId, running), (self.debugBrowseId, running), (self.shellNamespaceId, running)): self.toolbar.EnableTool(wid, enabled)
parent.AddPage(bSelect=true, imageId=-1, pPage=self.constr, strText=self.constr_name) parent.AddPage(bSelect=false, imageId=-1, pPage=self.props, strText=self.props_name) parent.AddPage(bSelect=false, imageId=-1, pPage=self.events, strText=self.events_name)
parent.AddPage(select=true, imageId=-1, page=self.constr, text=self.constr_name) parent.AddPage(select=false, imageId=-1, page=self.props, text=self.props_name) parent.AddPage(select=false, imageId=-1, page=self.events, text=self.events_name)
def _init_coll_pages_Pages(self, parent): # generated method, don't edit
wxSize(12, 14))
wxSize(13, 14))
def __init__(self, inspector, nameParent, valueParent, companion, rootCompanion, name, propWrapper, idx, indent, editor=None, options=None, names=None, ownerPropEdit=None):
def AddPage(self, pPage, strText, bSelect=false, imageId=-1): wxNotebook.AddPage(self, pPage, strText) self.pages[strText] = pPage
def AddPage(self, page, text, select=false, imageId=-1): wxNotebook.AddPage(self, page, text) self.pages[text] = page
def AddPage(self, pPage, strText, bSelect=false, imageId=-1): wxNotebook.AddPage(self, pPage, strText) self.pages[strText] = pPage
def organiseCollection(self): """ Restructures an ObjectCollection into propery and event dicts keyed on the control name. """ props = {} events = {} objColl = ObjectCollection() if self.model.objectCollections.has_key(self.collectionMethod): objColl = self.model.objectCollections[self.collectionMethod] objColl.indexOnCtrlName() props = objColl.propertiesByName events = objColl.eventsByName return objColl, props, events
def organiseCollection(self): # deprc """ Restructures an ObjectCollection into propery and event dicts keyed on the control name. """
def applyDepsForCtrl(self, ctrlName, depLinks): if depLinks.has_key(ctrlName): for prop in depLinks[ctrlName]: ctrl = self.objects[prop.comp_name][1] if ctrlName == '': value = self else: ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value) def initObjDeps(self, dependents): for ctrlName in dependents.keys(): ctrl = self.objects[ctrlName][1] for prop in dependents[ctrlName]: if name == 'self': value = self elif len(name) > 5 and name[:5] == 'self.': ord, objs = self.model.allObjects() name = name[5:] if objs.has_key(name): value = objs[name][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value)
def applyDepsForCtrl(self, ctrlName, depLinks): if depLinks.has_key(ctrlName): for prop in depLinks[ctrlName]: ctrl = self.objects[prop.comp_name][1] if ctrlName == '': value = self else: ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value)
def ctrlNameFromSrc(self, link): if link == 'self': return '' else: return link[5:]
def initObjCreator(self, constrPrs): # Assumes all design time ctrls are imported in global scope ctrlClass = PaletteMapping.evalCtrl(constrPrs.class_name) ctrlCompnClass = PaletteMapping.compInfo[ctrlClass][1] ctrlName = self.loadControl(ctrlClass, ctrlCompnClass, constrPrs.comp_name, constrPrs.params) ctrlCompn = self.objects[ctrlName][0] ctrlCompn.setConstr(constrPrs)
def addDepLink(self, prop, name, dependents, depLinks): if not dependents.has_key(name): dependents[name] = [] dependents[name].append(prop) link = self.ctrlNameFromSrc(prop.params[0]) if not depLinks.has_key(link): depLinks[link] = [] depLinks[link].append(prop)
def addDepLink(self, prop, name, dependents, depLinks): if not dependents.has_key(name): dependents[name] = [] dependents[name].append(prop)
comp = self.objects[name][0] ctrl = self.objects[name][1]
comp, ctrl = self.objects[name][0:2]
def initObjProps(self, props, name, creator, dependents, depLinks): """ Initialise property list by evaluating 1st parameter and calling prop's setter with it. Also associate companion name with prop parse objs """ if props.has_key(name): comp = self.objects[name][0] ctrl = self.objects[name][1] # initialise live component's properies for prop in props[name]: prop.prop_name = comp.getPropNameFromSetter(prop.prop_setter) # Dependent properties if prop.prop_name in comp.dependentProps(): self.addDepLink(prop, name, dependents, depLinks) # Collection initialisers elif prop.params[0][:11] == 'self._init_': from methodparse import CollectionInitParse collItem = CollectionInitParse(prop.params[0]) self.addCollView(name, collItem.method, false) # Normal property, eval value and apply it else: try: value = PaletteMapping.evalCtrl(prop.params[0]) except AttributeError, name: if self.objects.has_key(name): value = self.objects[name][1] else: raise RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value)
def initObjColls(self, collInits, name, creator, dependents = {}):
def initObjColls(self, collInits, name, creator, dependents = None):
def initObjProps(self, props, name, creator, dependents, depLinks): """ Initialise property list by evaluating 1st parameter and calling prop's setter with it. Also associate companion name with prop parse objs """ if props.has_key(name): comp = self.objects[name][0] ctrl = self.objects[name][1] # initialise live component's properies for prop in props[name]: prop.prop_name = comp.getPropNameFromSetter(prop.prop_setter) # Dependent properties if prop.prop_name in comp.dependentProps(): self.addDepLink(prop, name, dependents, depLinks) # Collection initialisers elif prop.params[0][:11] == 'self._init_': from methodparse import CollectionInitParse collItem = CollectionInitParse(prop.params[0]) self.addCollView(name, collItem.method, false) # Normal property, eval value and apply it else: try: value = PaletteMapping.evalCtrl(prop.params[0]) except AttributeError, name: if self.objects.has_key(name): value = self.objects[name][1] else: raise RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value)
def initObjEvts(self, events, name, creator): if events.has_key(name): self.objects[name][0].setEvents(events[name])
def initObjColls(self, collInits, name, creator, dependents = {}): """ Initialise collection properties by creating a collection view for it and applying it. Also associate companion name with prop parse objs """
def initObjEvts(self, events, name, creator): if events.has_key(name): self.objects[name][0].setEvents(events[name])
def checkAndAddDepLink(self, ctrlName, prop, dependentProps, deps, depLinks, definedCtrls): if prop.prop_name in dependentProps: target = Utils.ctrlNameFromSrcRef(prop.params[0]) if target not in definedCtrls: self.addDepLink(prop, ctrlName, deps, depLinks) return true return false def applyDepsForCtrl(self, ctrlName, depLinks): if depLinks.has_key(ctrlName): for prop in depLinks[ctrlName]: ctrl = self.objects[prop.comp_name][1] if ctrlName == '': value = self else: ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value) def addDepLink(self, prop, name, dependents, depLinks): if not dependents.has_key(name): dependents[name] = [] dependents[name].append(prop) link = Utils.ctrlNameFromSrcRef(prop.params[0]) if not depLinks.has_key(link): depLinks[link] = [] depLinks[link].append(prop)
def initObjEvts(self, events, name, creator): if events.has_key(name): self.objects[name][0].setEvents(events[name])
def saveEvts(self, compn, newBody): """ For every event definition not defined in source add an empty method to the bottom of the class """ for evt in compn.textEventList: if evt.trigger_meth != '(delete)': newBody.append(bodyIndent + evt.asText()) if not self.model.module.classes[\ self.model.main].methods.has_key(evt.trigger_meth): self.model.module.addMethod(self.model.main, evt.trigger_meth, 'self, event', [' pass']) def saveDepsForCtrl(self, ctrlName, depLinks, newBody): if depLinks.has_key(ctrlName): for prop in depLinks[ctrlName]: newBody.append(bodyIndent + prop.asText())
def saveEvts(self, compn, newBody): """ For every event definition not defined in source add an empty method to the bottom of the class """ for evt in compn.textEventList: if evt.trigger_meth != '(delete)': newBody.append(bodyIndent + evt.asText()) if not self.model.module.classes[\ self.model.main].methods.has_key(evt.trigger_meth): self.model.module.addMethod(self.model.main, evt.trigger_meth, 'self, event', [' pass'])
try: if compn.textConstr: newBody.append(bodyIndent + compn.textConstr.asText()) if compn.textConstr.comp_name == '' and \ self.collectionMethod == '_init_ctrls': newBody.append(bodyIndent + 'self._init_utils()') except: print 'no constr:', ctrlName for prop in compn.textPropList: if prop.prop_name in compn.dependentProps(): target = self.ctrlNameFromSrc(prop.params[0]) if target not in definedCtrls: self.addDepLink(prop, ctrlName, deps, depLinks) continue newBody.append(bodyIndent + prop.asText()) for collInit in compn.textCollInitList: if collInit.getPropName() in compn.dependentProps(): collDeps.append(bodyIndent + collInit.asText()) else: newBody.append(bodyIndent + collInit.asText()) self.saveEvts(compn, newBody)
def saveCtrls(self, definedCtrls): """ Replace current source of method in collectionMethod with values from constructors, properties and events. """
self.saveDepsForCtrl(ctrlName, depLinks, newBody)
compn.writeConstructor(newBody, self.collectionMethod) compn.writeProperties(newBody, ctrlName, definedCtrls, deps, depLinks) compn.writeCollections(newBody, collDeps) compn.writeEvents(newBody, addModuleMethod = true) compn.writeDependencies(newBody, ctrlName, depLinks)
def saveCtrls(self, definedCtrls): """ Replace current source of method in collectionMethod with values from constructors, properties and events. """
newName = '%s%s'%(string.lower(className[2:3]), className[3:]) while self.objects.has_key(newName + `num`): num = num + 1 return newName + `num`
if className[:2] == 'wx': newName = '%s%s'%(string.lower(className[2:3]), className[3:]) else: newName = '%s%s'%(string.lower(className[0]), className[1:]) return Utils.getValidName(self.objects.keys(), newName)
def newObjName(self , className): """ Return a name for a control unique in the scope of the model. """
self.multiSelection = []
def __init__(self, parent, inspector, model, compPal, companionClass, dataView): args = self.setupArgs(model.main, model.mainConstr.params, ['parent', 'id'], parent, companionClass) wxFrame.__init__(self, parent, -1, args['title'], args['pos'], args['size'])#, args['style'], args['name']) InspectableObjectCollectionView.__init__(self, inspector, model, compPal)
EVT_MENU(self, wxID_EDITALIGN, self.OnAlignSelected) EVT_MENU(self, wxID_EDITSIZE, self.OnSizeSelected) EVT_MENU(self, wxID_CTRLPARENT, self.OnSelectParent) EVT_MENU(self, wxID_EDITCUT, self.OnCutSelected) EVT_MENU(self, wxID_EDITCOPY, self.OnCopySelected) EVT_MENU(self, wxID_EDITPASTE, self.OnPasteSelected)
def __init__(self, parent, inspector, model, compPal, companionClass, dataView): args = self.setupArgs(model.main, model.mainConstr.params, ['parent', 'id'], parent, companionClass) wxFrame.__init__(self, parent, -1, args['title'], args['pos'], args['size'])#, args['style'], args['name']) InspectableObjectCollectionView.__init__(self, inspector, model, compPal)
('ContextHelp', wxID_CTRLHELP)):
('ContextHelp', wxID_CTRLHELP), ('Escape', wxID_CTRLPARENT)):
def __init__(self, parent, inspector, model, compPal, companionClass, dataView): args = self.setupArgs(model.main, model.mainConstr.params, ['parent', 'id'], parent, companionClass) wxFrame.__init__(self, parent, -1, args['title'], args['pos'], args['size'])#, args['style'], args['name']) InspectableObjectCollectionView.__init__(self, inspector, model, compPal)
self.selection = SelectionGroup(self, self.senderMapper,
self.selection = SingleSelectionGroup(self, self.senderMapper,
def refreshCtrl(self): if self.destroying: return
self.selection = SelectionGroup(self, self.senderMapper, self.inspector, self)
self.selection = SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
def initSelection(self): self.selection = SelectionGroup(self, self.senderMapper, self.inspector, self)
def getAllObjects(self, theClass):
def getAllObjects(self):
def getAllObjects(self, theClass): results = InspectableObjectCollectionView.getAllObjects(self) for objName in self.dataView.objects.keys(): if objName: results['self.'+objName] = self.dataView.objects[objName][1] else: results['self'] = self.dataView.objects[objName][1] return results
if self.selection:
if self.selection or self.multiSelection: if self.multiSelection: self.clearMultiSelection() self.assureSingleSelection()
def selectParent(self, ctrl): """ Change the selection to the parent of the currently selected control. """ if self.selection: if ctrl != self: parent = ctrl.GetParent() parentName = parent.GetName() if parentName == self.GetName(): parentName = '' self.inspector.containment.selectName(parentName)
def checkChildCtrlClick(self, ctrlName, ctrl, companion, clickPos): selCtrl, selCompn, selPos = ctrl, companion, clickPos if companion.container: parent = ctrl else: parent = ctrl.GetParent() tbOffset = 0 if parent == self: tb = self.GetToolBar() if tb: tbOffset = tb.GetSize().y * -1 parRel, parRef = self.buildParentRelationship() if ctrl == self: children = parRef[''] else: children = parRef[ctrlName] for childName in children.keys(): childCompn, childCtrl = self.objects[childName][:2] try: pos = childCtrl.GetPosition() sze = childCtrl.GetSize() except: print 'could not get child ctrl size', childCtrl else: if wxIntersectRect((clickPos.x, clickPos.y + tbOffset, 1, 1), (pos.x, pos.y, sze.x, sze.y)) is not None: selCtrl = childCtrl selCompn = childCompn selPos = wxPoint(clickPos.x - pos.x, clickPos.y + tbOffset - pos.y) break; return selCtrl, selCompn, selPos def clearMultiSelection(self): for sel in self.multiSelection: sel.destroy() self.multiSelection = [] def assureSingleSelection(self): if not self.selection: self.selection = SingleSelectionGroup(self, self.senderMapper, self.inspector, self) def flattenParentRelationship(self, rel, lst): for itm in rel.keys(): lst.append(itm) self.flattenParentRelationship(rel[itm], lst) def expandNamesToContainers(self, ctrlNames): exp = ctrlNames[:] rel, ref = self.buildParentRelationship() for ctrl in ctrlNames: children = [] self.flattenParentRelationship(ref[ctrl], children) exp.extend(children) return exp
def disconnectToolBar(self, toolBar): parRel, parRef = self.buildParentRelationship() children = parRef[''] for childName in children.keys(): childCompn, childCtrl = self.objects[childName][:2] if not childCtrl.__class__ in self.ignoreWindows: pos = childCtrl.GetPosition() childCtrl.SetPosition( (pos.x, pos.y - toolBar.GetSize().y) )
self.selection.moving(ctrl, pos)
if self.selection: self.selection.moving(ctrl, pos) elif self.multiSelection: for sel in self.multiSelection: sel.moving(ctrl, pos, self.mainMultiDrag)
def OnMouseOver(self, event): if event.Dragging(): pos = event.GetPosition() ctrl = self.senderMapper.getObject(event)