rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if Utils.startswith(string.strip(mod.source[idx]), 'self._init_ctrls('):
line = string.strip(mod.source[idx]) if Utils.startswith(line, 'self._init_ctrls('):
e.g. def __init__(self, parent, myFrameCaption): self.frameCaption = 'Design time frame caption' self.frameCaption = myFrameCaption self._init_ctrls(parent)
for attr, blocks in cls.attributes.items(): for block in blocks: if startline <= block.start <= endline and attr not in attrs: line = mod.source[block.start-1] val = line[string.find(line, '=')+1:] attrs.append( (attr, val) )
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: line = source[block.start-1] val = string.strip(line[string.find(line, '=')+1:]) attrs.append( (attr, val) ) if extAttrInitName: if not mod.from_imports_names.has_key(extAttrInitName): raise '%s.__init__ called, but not imported in the form: '\ 'from [ModuleName] import %s'%(extAttrInitName, extAttrInitName) 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 '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) readAttrsFromSrc(attrs, cls.attributes, mod.source, startline, endline)
e.g. def __init__(self, parent, myFrameCaption): self.frameCaption = 'Design time frame caption' self.frameCaption = myFrameCaption self._init_ctrls(parent)
if self.objectCollections.has_key(init_ctrls):
if self.objectCollections.has_key(sourceconst.init_ctrls):
def readComponents(self): """ Setup object collection dict by parsing all designer controlled methods """ module = self.getModule() # Parse all _init_* methods self.objectCollections = {} if module.classes.has_key(self.main): main = module.classes[self.main]
self.mainConstr = self.objectCollections[init_ctrls].creators[0]
self.mainConstr = \ self.objectCollections[sourceconst.init_ctrls].creators[0]
def readComponents(self): """ Setup object collection dict by parsing all designer controlled methods """ module = self.getModule() # Parse all _init_* methods self.objectCollections = {} if module.classes.has_key(self.main): main = module.classes[self.main]
reWinIds = re.compile(srchWindowIds % colMeth)
reWinIds = re.compile(sourceconst.srchWindowIds % colMeth)
def removeWindowIds(self, colMeth): """ Remove a method's corresponding window ids from the source code """ # find windowids in source winIdIdx = -1 reWinIds = re.compile(srchWindowIds % colMeth) module = self.getModule() for idx in range(len(module.source)): match = reWinIds.match(module.source[idx]) if match: del module.source[idx] del module.source[idx] module.renumber(-2, idx) break
reWinIds = re.compile(srchWindowIds % colMeth)
reWinIds = re.compile(sourceconst.srchWindowIds % colMeth)
def writeWindowIds(self, colMeth, companions): """ Write a method's corresponding window ids to the source code """ # To integrate efficiently with Designer.SaveCtrls this method # modifies module.source but doesn't refresh anything
[string.strip(defWindowIds % (string.join(lst, ', '), colMeth, len(lst))), '']
[string.strip(sourceconst.defWindowIds % ( string.join(lst, ', '), colMeth, len(lst))), '']
def writeWindowIds(self, colMeth, companions): """ Write a method's corresponding window ids to the source code """ # To integrate efficiently with Designer.SaveCtrls this method # modifies module.source but doesn't refresh anything
string.strip(defWindowIds % (string.join(lst, ', '), colMeth, len(lst)))
string.strip(sourceconst.defWindowIds % (string.join(lst, ', '), colMeth, len(lst)))
def writeWindowIds(self, colMeth, companions): """ Write a method's corresponding window ids to the source code """ # To integrate efficiently with Designer.SaveCtrls this method # modifies module.source but doesn't refresh anything
return simpleAppFrameRunSrc
return sourceconst.simpleAppFrameRunSrc
def getSimpleRunnerSrc(self): """ Return template of source code that will run this module type as a stand-alone file """ return simpleAppFrameRunSrc
return simpleAppDialogRunSrc
return sourceconst.simpleAppDialogRunSrc
def getSimpleRunnerSrc(self): return simpleAppDialogRunSrc
return simpleAppPopupRunSrc
return sourceconst.simpleAppPopupRunSrc
def getSimpleRunnerSrc(self): return simpleAppPopupRunSrc
self.data = (defEnvPython + defSig + defImport + defApp) \ %(self.modelIdentifier, boaClass, mainModule, mainModule, mainModule, mainModule)
self.data = (sourceconst.defEnvPython + sourceconst.defSig + \ sourceconst.defImport + sourceconst.defApp)%( self.modelIdentifier, sourceconst.boaClass, mainModule, mainModule, mainModule, mainModule)
def new(self, mainModule): self.data = (defEnvPython + defSig + defImport + defApp) \ %(self.modelIdentifier, boaClass, mainModule, mainModule, mainModule, mainModule) self.saved = false self.modified = true self.update() self.notify()
cnt = 0
def extractKVParams(self, paramsStr): params = safesplitfields(paramsStr, ',') result = {} cnt = 0 for param in params: try: sidx = string.index(param, '=') except ValueError: result[`cnt`] = string.strip(param[sidx+1:]) else: result[string.strip(param[:sidx])] = string.strip(param[sidx+1:]) cnt = cnt + 1 return result
result[`cnt`] = string.strip(param[sidx+1:])
pass
def extractKVParams(self, paramsStr): params = safesplitfields(paramsStr, ',') result = {} cnt = 0 for param in params: try: sidx = string.index(param, '=') except ValueError: result[`cnt`] = string.strip(param[sidx+1:]) else: result[string.strip(param[:sidx])] = string.strip(param[sidx+1:]) cnt = cnt + 1 return result
cnt = cnt + 1
def extractKVParams(self, paramsStr): params = safesplitfields(paramsStr, ',') result = {} cnt = 0 for param in params: try: sidx = string.index(param, '=') except ValueError: result[`cnt`] = string.strip(param[sidx+1:]) else: result[string.strip(param[:sidx])] = string.strip(param[sidx+1:]) cnt = cnt + 1 return result
client = ChildProcessClient(self)
client = ChildProcessClient(self, '--zope')
def setDebugClient(self, client=None): if client is None: from ChildProcessClient import ChildProcessClient client = ChildProcessClient(self) self.debug_client = client
frame['client_filename'] = \ self.serverFNToClientFN(frame['filename'])
frame['client_filename'] = ( self.serverFNToClientFN(frame['filename']))
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.prodsDir = path.join(zopeDir, 'lib','python','Products')
self.prodsDir = os.path.join(zopeDir, 'lib','python','Products')
def __init__(self, zopeDir): self.zopeDir = zopeDir if self.zopeDir: self.prodsDir = path.join(zopeDir, 'lib','python','Products') else: self.prodsDir = ''
mods = self._addPyMods(path.join(self.zopeDir, 'Extensions'))
mods = self._addPyMods(os.path.join(self.zopeDir, 'Extensions'))
def getModules(self): mods = self._addPyMods(path.join(self.zopeDir, 'Extensions'))
if path.exists(path.join(self.prodsDir, p)) and \ path.exists(path.join(self.prodsDir, p, 'Extensions')): mods.extend(self._addPyMods(path.join(self.prodsDir, p,
if os.path.exists(os.path.join(self.prodsDir, p)) and \ os.path.exists(os.path.join(self.prodsDir, p, 'Extensions')): mods.extend(self._addPyMods(os.path.join(self.prodsDir, p,
def getModules(self): mods = self._addPyMods(path.join(self.zopeDir, 'Extensions'))
mods.append(prod +(prod and '.')+path.splitext(file)[0])
mods.append(prod +(prod and '.')+os.path.splitext(file)[0])
def _addPyMods(self, pypath, prod=''): from Explorers import Explorer Explorer.listdirEx(pypath, '.zexp') mods = [] fls = Explorer.listdirEx(pypath, '.py') for file in fls: mods.append(prod +(prod and '.')+path.splitext(file)[0]) return mods
modLst = string.split(module, '.')
modLst = module.split('.')
def getExtPath(self, module): modLst = string.split(module, '.') if len(modLst) == 1: modpath = path.join(self.zopeDir, 'Extensions', modLst[0] + '.py') else: modpath = path.join(self.prodsDir, modLst[0], 'Extensions', modLst[1]+'.py') return string.replace(modpath, '<LocalFS::directory>', '<LocalFS::file>')
modpath = path.join(self.zopeDir, 'Extensions', modLst[0] + '.py')
modpath = os.path.join(self.zopeDir, 'Extensions', modLst[0] + '.py')
def getExtPath(self, module): modLst = string.split(module, '.') if len(modLst) == 1: modpath = path.join(self.zopeDir, 'Extensions', modLst[0] + '.py') else: modpath = path.join(self.prodsDir, modLst[0], 'Extensions', modLst[1]+'.py') return string.replace(modpath, '<LocalFS::directory>', '<LocalFS::file>')
modpath = path.join(self.prodsDir, modLst[0], 'Extensions', modLst[1]+'.py') return string.replace(modpath, '<LocalFS::directory>', '<LocalFS::file>')
modpath = os.path.join(self.prodsDir, modLst[0], 'Extensions', modLst[1]+'.py') return modpath.replace('<LocalFS::directory>', '<LocalFS::file>')
def getExtPath(self, module): modLst = string.split(module, '.') if len(modLst) == 1: modpath = path.join(self.zopeDir, 'Extensions', modLst[0] + '.py') else: modpath = path.join(self.prodsDir, modLst[0], 'Extensions', modLst[1]+'.py') return string.replace(modpath, '<LocalFS::directory>', '<LocalFS::file>')
sep = string.count(src, '\r\n') < string.count(src, '\n') and '\n' or '\r\n' srclines = string.split(src, sep)
sep = src.count('\r\n') < src.count('\n') and '\n' or '\r\n' srclines = src.split(sep)
def getFunctions(self, module): from Explorers import Explorer extPath = self.getExtPath(module)
sidx = string.find(param, '=')
sidx = string.index(param, '=')
def extractKVParams(self, paramsStr): params = safesplitfields(paramsStr, ',') result = {} cnt = 0 for param in params: try: sidx = string.find(param, '=') except ValueError: result[`cnt`] = string.strip(param[sidx+1:]) else: result[string.strip(param[:sidx])] = string.strip(param[sidx+1:]) cnt = cnt + 1 return result
py_compile.compile(self.filename)
import py_compile py_compile.compile(filename)
def run(self, filename): py_compile.compile(self.filename)
filesegs, cvssegs = string.split(filets), string.split(timestamp)
if conflict and len(ismerge) ==1: filesegs, cvssegs = 1, 0
def cvsFileLocallyModified(filename, timestamp): """ cvsFileLocallyModified -> modified, conflict """ filets = time.asctime(time.gmtime(os.stat(filename)[stat.ST_MTIME])) filesegs, cvssegs = string.split(filets), string.split(timestamp) # convert day to int to avoid zero padded differences filesegs[2], cvssegs[2] = int(filesegs[2]), int(cvssegs[2]) return ( filesegs != cvssegs, string.split(timestamp, '+')[0] == 'Result of merge')
filesegs[2], cvssegs[2] = int(filesegs[2]), int(cvssegs[2])
else: if conflict: filesegs, cvssegs = string.split(filets), string.split(ismerge[1]) else: filesegs, cvssegs = string.split(filets), string.split(timestamp) filesegs[2], cvssegs[2] = int(filesegs[2]), int(cvssegs[2])
def cvsFileLocallyModified(filename, timestamp): """ cvsFileLocallyModified -> modified, conflict """ filets = time.asctime(time.gmtime(os.stat(filename)[stat.ST_MTIME])) filesegs, cvssegs = string.split(filets), string.split(timestamp) # convert day to int to avoid zero padded differences filesegs[2], cvssegs[2] = int(filesegs[2]), int(cvssegs[2]) return ( filesegs != cvssegs, string.split(timestamp, '+')[0] == 'Result of merge')
string.split(timestamp, '+')[0] == 'Result of merge')
conflict)
def cvsFileLocallyModified(filename, timestamp): """ cvsFileLocallyModified -> modified, conflict """ filets = time.asctime(time.gmtime(os.stat(filename)[stat.ST_MTIME])) filesegs, cvssegs = string.split(filets), string.split(timestamp) # convert day to int to avoid zero padded differences filesegs[2], cvssegs[2] = int(filesegs[2]), int(cvssegs[2]) return ( filesegs != cvssegs, string.split(timestamp, '+')[0] == 'Result of merge')
%(os.environ.get('CVSROOT', '(not defined)'), os.environ.get('CVS_RSH', '(not defined)'), inDir, help),
%(cvsroot, os.environ.get('CVS_RSH', '(not defined)'), inDir, help),
def cvsCmdPrompt(self, wholeCommand, inDir, help = ''): dlg = wxTextEntryDialog(self.list, 'CVSROOT: %s\nCVS_RSH: %s\n(in dir %s)\n\n%s'\ %(os.environ.get('CVSROOT', '(not defined)'), os.environ.get('CVS_RSH', '(not defined)'), inDir, help), 'CVS command line', wholeCommand) if wxPlatform == '__WXMSW__': te = Utils.getCtrlsFromDialog(dlg, 'wxTextCtrlPtr')[0] try: te.SetSelection(string.index(wholeCommand, '['), string.index(wholeCommand, ']')+1) except ValueError: te.SetInsertionPoint(len(wholeCommand)) try: if dlg.ShowModal() == wxID_OK: return dlg.GetValue() else: return '' finally: dlg.Destroy()
err = ErrorStack.crashError(os.path.splitext(self.filename)[0]+'.trace')
err = ErrorStack.crashError(os.path.splitext(self.assertLocalFile())[0]+'.trace')
def crashLog(self): err = ErrorStack.crashError(os.path.splitext(self.filename)[0]+'.trace') if err: frm = self.editor.erroutFrm if frm: frm.updateCtrls(err) frm.display(err) return frm else: wx.wxLogError('Trace file not found. Run with command line param -T') return None
if selItems[0] < 1: return
if not selItems or selItems[0] < 1: return
def OnBbUpFirstButton(self, event): selItems = self.lbObjects.GetSelections() if selItems[0] < 1: return for item in selItems: self.moveObject(item, item - selItems[0])
if selItems[0] < 1: return
if not selItems or selItems[0] < 1: return
def OnBbupButton(self, event): selItems = self.lbObjects.GetSelections() if selItems[0] < 1: return for item in selItems: self.moveObject(item, item - 1)
if selItems[cnt-1] > ( len(self.ctrlNames) - 2 ): return
if not selItems or selItems[cnt-1] > ( len(self.ctrlNames) - 2 ): return
def OnBbdownButton(self, event): selItems = self.lbObjects.GetSelections() cnt = len(selItems) if selItems[cnt-1] > ( len(self.ctrlNames) - 2 ): return for i in range( cnt ): item = selItems[cnt - i - 1] self.moveObject(item, item + 1)
if selItems[cnt-1] > ( len(self.ctrlNames) - 2 ): return
if not selItems or selItems[cnt-1] > ( len(self.ctrlNames) - 2 ): return
def OnBbDownLastButton(self, event): selItems = self.lbObjects.GetSelections() cnt = len(selItems) if selItems[cnt-1] > ( len(self.ctrlNames) - 2 ): return shift = len(self.ctrlNames) - 1 - selItems[cnt - 1] for i in range( cnt ): item = selItems[cnt - i - 1] self.moveObject(item, item + shift)
props = CollectionDTC.properties(self)
props = CollectionIddDTC.properties(self)
def properties(self): props = CollectionDTC.properties(self) props.update({'Label': ('IndexRoute', wxMenu.GetLabel, wxMenu.SetLabel)}) return props
props = CollectionDTC.properties(self)
props = UtilityDTC.properties(self)
def properties(self): props = CollectionDTC.properties(self) props.update({'Menus': ('NoneRoute', None, None)}) return props
def events(self): return ['MenuEvent']
def designTimeDefaults(self, vals): dtd = {} for param in vals.keys(): if param == 'menu': name = vals[param] if name[:4] == 'self': dtd[param] = self.designer.objects[name[5:]][1] elif name == 'wxMenu()': dtd[param] = wxMenu() else: raise 'Invalid menu reference' else: try: dtd[param] = eval(vals[param]) except Exception, message: print 'could not eval 4', vals[param], message
'Cut (not implemented)', self.OnCut)
'Cut selection', self.OnCut)
def __init__(self, parent): self._init_ctrls(parent)
'Copy (not implemented)', self.OnCopy)
'Copy selection', self.OnCopy)
def __init__(self, parent): self._init_ctrls(parent)
'Paste (not implemented)', self.OnPaste)
'Paste selection', self.OnPaste) AddToolButtonBmpIS(self, self.toolBar, 'Images/Editor/Refresh.bmp', 'Recreate selection', self.OnRecreateSelection)
def __init__(self, parent): self._init_ctrls(parent)
if self.selCmp.designer: sb = self.selCmp.designer.model.editor.statusBar.progress
if self.selDesgn: sb = self.selDesgn.model.editor.statusBar.progress
def selectObject(self, compn, selectInContainment = true): """ Select an object in the inspector by populating the property pages. This method is called from the InspectableObjectCollection derived classes """
comp.persistProp(comp.name, 'SetPosition', comp.control.GetPosition())
print 'directPositionUpdate', comp.name comp.persistProp('Position', 'SetPosition', `comp.control.GetPosition()`)
def directPositionUpdate(self, comp): comp.persistProp(comp.name, 'SetPosition', comp.control.GetPosition())
comp.persistProp(comp.name, 'SetSize', comp.control.GetSize())
comp.persistProp('Size', 'SetSize', `comp.control.GetSize()`)
def directSizeUpdate(self, comp): comp.persistProp(comp.name, 'SetSize', comp.control.GetSize())
if self.selCmp and self.selCmp.designer: self.selCmp.designer.deleteCtrl(self.selCmp.name)
if self.selDesgn: self.selDesgn.OnControlDelete(event)
def OnDelete(self, event): if self.selCmp and self.selCmp.designer: self.selCmp.designer.deleteCtrl(self.selCmp.name)
if self.selCmp and self.selCmp.designer: self.selCmp.designer.selectParent(self.selObj)
if self.selDesgn: self.selDesgn.OnSelectParent(event)
def OnUp(self, event): if self.selCmp and self.selCmp.designer: self.selCmp.designer.selectParent(self.selObj)
pass
if self.selDesgn: self.selDesgn.OnCutSelected(event)
def OnCut(self, event): pass
pass
if self.selDesgn: self.selDesgn.OnCopySelected(event)
def OnCopy(self, event): pass
pass
if self.selDesgn: self.selDesgn.OnPasteSelected(event) def OnRecreateSelection(self, event): if self.selDesgn: self.selDesgn.OnRecreateSelected(event)
def OnPaste(self, event): pass
if self.selCmp and self.selCmp.designer: self.selCmp.designer.saveOnClose = true self.selCmp.designer.Close()
if self.selDesgn: self.selDesgn.saveOnClose = true self.selDesgn.Close()
def OnPost(self, event): if self.selCmp and self.selCmp.designer: self.selCmp.designer.saveOnClose = true self.selCmp.designer.Close()
if self.selCmp and self.selCmp.designer: self.selCmp.designer.saveOnClose = false self.selCmp.designer.Close()
if self.selDesgn: self.selDesgn.saveOnClose = false self.selDesgn.Close()
def OnCancel(self, event): if self.selCmp and self.selCmp.designer: self.selCmp.designer.saveOnClose = false self.selCmp.designer.Close()
if self.selCmp and self.selCmp.designer:
if self.selDesgn:
def OnHelp(self, event): if self.selCmp and self.selCmp.designer: url = self.pages.extendHelpUrl(self.selectedCtrlHelpFile()) Help.showHelp(self, Help.wxWinHelpFrame, url) else: Help.showHelp(self, Help.BoaHelpFrame, 'Inspector.html')
if to_bottom:
if to_bottom or not a_class.method_order:
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]
ins_point = a_class.block.start
ins_point = a_class.methods[a_class.method_order[0]].start-1
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]
a_class.add_method(method_name, method_params, ins_point, ins_point + \
self.renumber(new_length, ins_point) a_class.add_method(method_name, method_params, ins_point+1, ins_point + \
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]
self.renumber(new_length, ins_point)
pre_blank + [' def %s(%s):' % (method_name, method_params)] + \
if len(self.class_order):
if self.class_order:
def getModuleDoc(self): """ Return doc string for module. Scan the area from the start of the file up to the first occurence of a doc string containing structure like func or class """ if len(self.class_order): classStart = self.classes[self.class_order[0]].block.start -1 else: classStart = len(self.source)
if len(self.function_order):
if self.function_order:
def getModuleDoc(self): """ Return doc string for module. Scan the area from the start of the file up to the first occurence of a doc string containing structure like func or class """ if len(self.class_order): classStart = self.classes[self.class_order[0]].block.start -1 else: classStart = len(self.source)
for i in modTop: if not string.strip(i):
for line in lines: if not string.strip(line):
def getModuleDoc(self): """ Return doc string for module. Scan the area from the start of the file up to the first occurence of a doc string containing structure like func or class """ if len(self.class_order): classStart = self.classes[self.class_order[0]].block.start -1 else: classStart = len(self.source)
l.append(i) return self.searchDoc(string.join(l))
l.append(line) return l
def getModuleDoc(self): """ Return doc string for module. Scan the area from the start of the file up to the first occurence of a doc string containing structure like func or class """ if len(self.class_order): classStart = self.classes[self.class_order[0]].block.start -1 else: classStart = len(self.source)
cb = string.join(self.source[cls.block.start: min(methStart, cls.block.end)]) return self.searchDoc(cb)
classDoc = self.source[cls.block.start: min(methStart, cls.block.end)] return self.searchDoc(string.join(self.formatDocStr(classDoc)))
def getClassDoc(self, class_name): #delete all method bodies # XXX broken, returns first doc str in class
cb = string.join(self.extractMethodBody(class_name, meth_name)) return self.searchDoc(cb)
methDoc = self.extractMethodBody(class_name, meth_name) return self.searchDoc(string.join(self.formatDocStr(methDoc))) def getFunctionDoc(self, function_name): funcDoc = self.extractFunctionBody(function_name) return self.searchDoc(string.join(self.formatDocStr(funcDoc)))
def getClassMethDoc(self, class_name, meth_name): """ Extract the doc string for a method """ cb = string.join(self.extractMethodBody(class_name, meth_name)) return self.searchDoc(cb)
ins_point = self.source
ins_point = len(self.source)
def addFunction(self, func_name, func_params, func_body):
if type(prnt) == type(self):
if isinstance(prnt, moduleparse.Class):
def getAttribs(self, cls, methsOnly=false): loopCls = cls lst = [] while loopCls: lst.extend(loopCls.methods.keys()) if not methsOnly: lst.extend(loopCls.attributes.keys())
installedTransports = ['Explorers.PrefsExplorer'] + \
installTransports = ['Explorers.PrefsExplorer'] + \
def importExplorers(self, conf): """ Import names defined in the config files to register them """ installedTransports = ['Explorers.PrefsExplorer'] + \ eval(conf.get('explorer', 'installedtransports'))
for moduleName in installedTransports: try: __import__(moduleName, globals()) except ImportError, error: wxLogWarning('%s not installed: %s' %(moduleName, str(error))) warned = true else: ExplorerNodes.installedModules.append(moduleName)
for moduleName in installTransports: warned = importTransport(moduleName)
def importExplorers(self, conf): """ Import names defined in the config files to register them """ installedTransports = ['Explorers.PrefsExplorer'] + \ eval(conf.get('explorer', 'installedtransports'))
'is not rectifiable,\nconsider removing the transport from the ' '"installedtransports" list in the Explorer config. Click "Details"')
'is not rectifiable,\nconsider removing the transport under ' 'Preferences->Plug-ins->Transports. Click "Details"')
def importExplorers(self, conf): """ Import names defined in the config files to register them """ installedTransports = ['Explorers.PrefsExplorer'] + \ eval(conf.get('explorer', 'installedtransports'))
renameNode = self.list.getSelection() assert renameNode, 'No selection after rename' self.editor.explorerRenameNotify(oldURI, renameNode)
renamedNode = self.list.getSelection() if renamedNode: self.editor.explorerRenameNotify(oldURI, renamedNode)
def OnEndLabelEdit(self, event): newText = event.GetText() renameNode = self.list.getSelection() assert renameNode, 'There must be a selection to rename' oldURI = renameNode.getURI() if newText != self.oldLabelVal: event.Skip() self.list.node.renameItem(self.oldLabelVal, newText) self.list.refreshCurrent() self.list.selectItemNamed(newText) renameNode = self.list.getSelection() assert renameNode, 'No selection after rename' self.editor.explorerRenameNotify(oldURI, renameNode) else: event.Skip()
new_port = 9100
new_port = 20202
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') os.environ['PYTHONPATH'] = string.join(sys.path, os.pathsep) cmd = '%s "%s" %s' % (sys.executable, script_fn, args) try: pid = wx.wxExecute(cmd, 0, process) line = '' if monitor.isAlive(): istream = process.GetInputStream() estream = process.GetErrorStream() err = '' # read in the port and auth hash while monitor.isAlive() and string.find(line, '\n') < 0: # don't take more time than the process we wait for ;) time.sleep(0.00001) if not istream.eof(): line = line + istream.read(1) # test for tracebacks on stderr if not estream.eof(): err = estream.read() errlines = string.split(err, '\n') while not string.strip(errlines[-1]): del errlines[-1] exctype, excvalue = string.split(errlines[-1], ':') while errlines and errlines[-1][:7] != ' File ': del errlines[-1] if errlines: errfile = ' (%s)' % string.strip(errlines[-1]) else: errfile = '' raise __builtins__[string.strip(exctype)], ( string.strip(excvalue)+errfile) if not KEEP_STREAMS_OPEN: process.CloseOutput() if monitor.isAlive(): line = string.strip(line) if not line: raise RuntimeError, ( 'The debug server address could not be read') port, auth = string.split(string.strip(line)) if USE_TCPWATCH: # Start TCPWatch as a connection forwarder. from thread import start_new_thread new_port = 9100 def run_tcpwatch(port1, port2): os.system("tcpwatch -L %d:%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 else: raise RuntimeError, 'The debug server failed to start' except: if monitor.isAlive(): process.CloseOutput() monitor.kill() raise
os.system("tcpwatch -L %d:%d" % (int(port1), int(port2)))
os.system("tcpwatch -L %d:127.0.0.1:%d" % ( int(port1), int(port2)))
def run_tcpwatch(port1, port2): os.system("tcpwatch -L %d:%d" % (int(port1), int(port2)))
methodparse.decorateParseItems(objCol.eventsByName[name], name, self.model.main)
if objCol.eventsByName.has_key(name): methodparse.decorateParseItems(objCol.eventsByName[name], name, self.model.main)
elif line[:5] == '\tdef ': meth = line[5:string.find(line, '(', 6)] currMeth = [meth] methList.append(currMeth)
def dontPersistProps(self): return ContainerDTC.dontPersistProps(self)
def dontPersistProps(self): # skip the code that removes ClientSize from the 'remove' list return ContainerDTC.dontPersistProps(self)
print event.GetString()
def OnfgColCombobox(self, event): print event.GetString() try: self.editColTCProp(self.fgColCb, self.fgColBtn, 'fore', event.GetString()) except AssertionError: wxLogError('Not a valid colour value')
print 'asdf'
def OnDblClick(evt, stc=stc): dlg = STCStyleEditDlg(None, 'Python', 'python', config, (stc,)) try: dlg.ShowModal() finally: dlg.Destroy()
del self.images
self.images = None
def destroy(self): del self.images
self.findTxt = wxComboBox(choices = [], id = wxID_FINDREPLACEDLGFINDTXT, name = 'findTxt', parent = self, pos = wxPoint(88, 4), size = wxSize(268, 21), style = wxTE_PROCESS_ENTER, value = '') self.replaceTxt = wxComboBox(choices = [], id = wxID_FINDREPLACEDLGREPLACETXT, name = 'replaceTxt', parent = self, pos = wxPoint(88, 28), size = wxSize(268, 21), style = wxTE_PROCESS_ENTER, value = '')
self.findTxt = wxComboBox(choices = [], id = wxID_FINDREPLACEDLGFINDTXT, name = 'findTxt', parent = self, pos = wxPoint(88, 4), size = wxSize(268, 21), style = 0, value = '') self.replaceTxt = wxComboBox(choices = [], id = wxID_FINDREPLACEDLGREPLACETXT, name = 'replaceTxt', parent = self, pos = wxPoint(88, 28), size = wxSize(268, 21), style = 0, value = '')
def _init_ctrls(self, prnt): wxDialog.__init__(self, id = wxID_FINDREPLACEDLG, name = 'FindReplaceDlg', parent = prnt, pos = wxPoint(394, 361), size = wxSize(372, 234), style = wxDEFAULT_DIALOG_STYLE, title = 'Find/Replace') self._init_utils() self.SetAutoLayout(true) self.SetClientSize(wxSize(364, 207))
from PythonEditorModels import ModuleModel
from Models.PythonEditorModels import ModuleModel
def addNewView(self, name, View): return createFramedView(name, View, self.model, self.parent, (400, 200))[1]
os.environ['PYTHONPATH'] = os.pathsep.join(sys.path) cmd = '%s "%s" %s' % (sys.executable, script_fn, args)
pyIntpPath = Preferences.getPythonInterpreterPath() if pyIntpPath == sys.executable: os.environ['PYTHONPATH'] = os.pathsep.join(sys.path) else: os.environ['PYTHONPATH'] = Preferences.pyPath cmd = '%s "%s" %s' % (pyIntpPath, script_fn, args)
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') os.environ['PYTHONPATH'] = os.pathsep.join(sys.path) cmd = '%s "%s" %s' % (sys.executable, script_fn, args) try: if wx.wxVERSION > (2, 3, 2): flags = wx.wxEXEC_NOHIDE else: flags = 0 pid = wx.wxExecute(cmd, flags, 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 canReadStream(istream): line = line + istream.read(1) # test for tracebacks on stderr if canReadStream(estream): err = estream.read() errlines = err.split('\n') while not errlines[-1].strip(): del errlines[-1] exctype, excvalue = errlines[-1].split(':') while errlines and errlines[-1][:7] != ' File ': del errlines[-1] if errlines: errfile = ' (%s)' % errlines[-1].strip() else: errfile = '' raise __builtins__[exctype.strip()], (excvalue.strip()+errfile) 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 else: raise RuntimeError, 'The debug server failed to start' except: if monitor.isAlive(): process.CloseOutput() monitor.kill() raise
raise __builtins__[exctype.strip()], (excvalue.strip()+errfile)
try: Error, val = __builtins__[exctype.strip()], (excvalue.strip()+errfile) except KeyError: Error, val = UnknownError, (exctype.strip()+':'+excvalue.strip()+errfile) raise Error, val
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') os.environ['PYTHONPATH'] = os.pathsep.join(sys.path) cmd = '%s "%s" %s' % (sys.executable, script_fn, args) try: if wx.wxVERSION > (2, 3, 2): flags = wx.wxEXEC_NOHIDE else: flags = 0 pid = wx.wxExecute(cmd, flags, 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 canReadStream(istream): line = line + istream.read(1) # test for tracebacks on stderr if canReadStream(estream): err = estream.read() errlines = err.split('\n') while not errlines[-1].strip(): del errlines[-1] exctype, excvalue = errlines[-1].split(':') while errlines and errlines[-1][:7] != ' File ': del errlines[-1] if errlines: errfile = ' (%s)' % errlines[-1].strip() else: errfile = '' raise __builtins__[exctype.strip()], (excvalue.strip()+errfile) 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 else: raise RuntimeError, 'The debug server failed to start' except: if monitor.isAlive(): process.CloseOutput() monitor.kill() raise
t, v = sys.exc_info()[:2]
t, v, tb = sys.exc_info()
def OnDebuggerStart(self, evt): try: wx.wxBeginBusyCursor() try: if self.server is None: # Start the subprocess. process = wx.wxProcess(self.event_handler, self.win_id) process.Redirect() self.process = process wx.EVT_END_PROCESS(self.event_handler, self.win_id, self.OnProcessEnded) (self.server, self.input_stream, self.error_stream, self.processId) = spawnChild( self, process, self.process_args) self.taskHandler.addTask(evt.GetTask()) except: t, v = sys.exc_info()[:2] evt = self.createEvent(wxEVT_DEBUGGER_EXC) evt.SetExc(t, v) self.postEvent(evt) finally: wx.wxEndBusyCursor()
return [' %s = []'%self.__class__.sourceObjName, '']
return ['%s%s = []'%(sourceconst.bodyIndent, self.__class__.sourceObjName), '']
def initialiser(self): return [' %s = []'%self.__class__.sourceObjName, '']
return ['', ' return %s' %self.__class__.sourceObjName]
return ['', '%sreturn %s' %(sourceconst.bodyIndent, self.__class__.sourceObjName)]
def finaliser(self): return ['', ' return %s' %self.__class__.sourceObjName]
def generateWindowId(self, idx): return
def generateWindowId(self, idx): return
def generateWindowId(self, idx): return
def defaultAction(self): # select sub menu obj in data view pass
return [' %s = wxLayoutConstraints()'%self.__class__.sourceObjName, '']
return ['%s%s = wxLayoutConstraints()'%(sourceconst.bodyIndent, self.__class__.sourceObjName), '']
def initialiser(self): return [' %s = wxLayoutConstraints()'%self.__class__.sourceObjName, '']
except Exception, message: print 'invalid config entry for', self.resourcepath[cat_option], message self.entries = copy.copy(self.defaultstruct)
except: message = sys.exc_info()[1] print 'invalid config entry for', \ self.resourcepath[cat_option], message self.entries = copy.copy(self.defaultStruct)
def refresh(self): try: self.entries = eval(self.config.get(self.resourcepath[cat_section], self.resourcepath[cat_option])) except Exception, message: print 'invalid config entry for', self.resourcepath[cat_option], message self.entries = copy.copy(self.defaultstruct)
global edWidth, inspWidth, paletteHeight, bottomHeight, underPalette
global edWidth, inspWidth, paletteHeight, bottomHeight, underPalette global oglBoldFont, oglStdFont
def initScreenVars(): global screenWidth, screenHeight, wxDefaultFramePos, wxDefaultFrameSize global edWidth, inspWidth, paletteHeight, bottomHeight, underPalette screenWidth = wx.wxSystemSettings_GetSystemMetric(wx.wxSYS_SCREEN_X) screenHeight = wx.wxSystemSettings_GetSystemMetric(wx.wxSYS_SCREEN_Y) if wx.wxPlatform == '__WXMSW__': _x, _y, screenWidth, screenHeight = wxGetClientDisplayRect() screenHeight -= topMenuHeight else: # handle dual monitors on Linux if screenWidth / screenHeight >= 2: screenWidth = screenWidth / 2 screenWidth = int(screenWidth - verticalTaskbarWidth) screenHeight = int(screenHeight - horizontalTaskbarHeight - topMenuHeight) if wx.wxPlatform == '__WXMSW__': wxDefaultFramePos = wx.wxDefaultPosition wxDefaultFrameSize = wx.wxDefaultSize else: wxDefaultFramePos = (screenWidth / 4, screenHeight / 4) wxDefaultFrameSize = (int(round(screenWidth / 1.5)), int(round(screenHeight / 1.5))) edWidth = int(screenWidth * editorScreenWidthPerc - windowManagerSide * 2) inspWidth = screenWidth - edWidth + 1 - windowManagerSide * 4 paletteHeight = paletteHeights[paletteStyle] bottomHeight = screenHeight - paletteHeight underPalette = paletteHeight + windowManagerTop + windowManagerBottom + topMenuHeight if wxPlatform == '__WXMSW__': oglBoldFont = wxFont(7, wxDEFAULT, wxNORMAL, wxBOLD, false) oglStdFont = wxFont(7, wxDEFAULT, wxNORMAL, wxNORMAL, false) else: oglBoldFont = wxFont(12, wxDEFAULT, wxNORMAL, wxBOLD, false) oglStdFont = wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL, false)
for idx, col in zip(range(len(rows)), cols):
for idx, col in zip(range(len(cols)), cols):
def setGrowables(self, rows, cols): self.textConstrLst = [] for idx, row in zip(range(len(rows)), rows): if row: self._appendItem('AddGrowableRow', idx) for idx, col in zip(range(len(rows)), cols): if col: self._appendItem('AddGrowableCol', idx)
(wx.NotebookSizer, 'wx.NotebookSizer', NotebookSizerDTC),
def defaultAction(self): pass
self.main.editor.openModule(sys.argv[1])
import getopt optlist, args = getopt.getopt(sys.argv[1:], 'D') if len(args): if ('-D', '') in optlist: mod = self.main.editor.openModule(args[0]) mod.debug() else: self.main.editor.openModule(args[0])
def OnInit(self): wxImage_AddHandler(wxJPEGHandler()) wxImage_AddHandler(wxPNGHandler()) wxImage_AddHandler(wxGIFHandler())
main()
if __name__ == '__main__' or hasattr(wxApp, 'debugger'): main()
def main(): app = BoaApp(0) app.quit = false while not app.quit: app.MainLoop()
res = self.getNameSig(objPth[0], objPth[1], objmodule, codeBlock)
res = self.getNameSig(objPth[0], objPth[1], module, codeBlock)
def getTipValue(self, word, lnNo): """ Overwritten Mixin method, returns string to display as tool tip """ module = self.model.getModule() objPth = word.split('.') safesplit = methodparse.safesplitfields
def runInThread(self, filename, args, app, interpreterPath, inpLines=[]):
def runInThread(self, filename, args, interpreterPath, inpLines=[], execStart=None, execFinish=None):
def runInThread(self, filename, args, app, interpreterPath, inpLines=[]): cwd = os.path.abspath(os.getcwd()) newCwd = os.path.dirname(os.path.abspath(filename)) os.chdir(newCwd) try: cmd = '"%s" %s %s'%(interpreterPath, os.path.basename(filename), args)
from ModRunner import PopenModuleRunner, ExecFinishEvent runner = PopenModuleRunner(None, app, newCwd) runner.run(cmd, inpLines) wx.wxPostEvent(self.editor, ExecFinishEvent(runner))
from ModRunner import PopenModuleRunner runner = PopenModuleRunner(None, newCwd) runner.run(cmd, inpLines, execStart) if execFinish: wx.wxCallAfter(execFinish, runner)
def runInThread(self, filename, args, app, interpreterPath, inpLines=[]): cwd = os.path.abspath(os.getcwd()) newCwd = os.path.dirname(os.path.abspath(filename)) os.chdir(newCwd) try: cmd = '"%s" %s %s'%(interpreterPath, os.path.basename(filename), args)
def run(self, args = ''):
def run1(self, args = '', execStart=None, execFinish=None):
def run(self, args = ''): """ Excecute the current saved image of the application. """ if self.savedAs: filename = self.assertLocalFile()
self.app, Preferences.getPythonInterpreterPath(), inpLines))
Preferences.getPythonInterpreterPath(), inpLines, execStart, execFinish)) def run(self, args = '', execStart=None, execFinish=None): """ Excecute the current saved image of the application. """ if self.savedAs: filename = self.assertLocalFile() self.editor.statusBar.setHint('Running %s...' % filename) if Preferences.minimizeOnRun: self.editor.minimizeBoa() inpLines = [] if self.useInputStream and self.editor.erroutFrm.inputPage: inpLines = StringIO( self.editor.erroutFrm.inputPage.GetValue()).readlines() cwd = os.path.abspath(os.getcwd()) newCwd = os.path.dirname(os.path.abspath(filename)) interp = Preferences.getPythonInterpreterPath() basename = os.path.basename(filename) os.chdir(newCwd) try: cmd = '"%s" %s %s'%(interp, basename, args) from ModRunner import wxPopenModuleRunner runner = wxPopenModuleRunner(None, newCwd) runner.run(cmd, inpLines, execFinish) execStart(runner.pid, os.path.basename(interp), basename) finally: if os: os.chdir(cwd)
def run(self, args = ''): """ Excecute the current saved image of the application. """ if self.savedAs: filename = self.assertLocalFile()
cmr = ModRunner.CompileModuleRunner(self.editor.erroutFrm, self.app)
cmr = ModRunner.CompileModuleRunner(self.editor.erroutFrm)
def compile(self): import ModRunner oldErr = sys.stderr sys.stderr = ErrorStack.RecFile() try: cmr = ModRunner.CompileModuleRunner(self.editor.erroutFrm, self.app) cmr.run(self.filename, self.data+'\n\n', self.modified)
def cyclops(self):
def cyclops(self, args='', execStart=None, execFinish=None):
def cyclops(self): """ Run the saved application thru Cyclops """ if self.savedAs: cwd = os.path.abspath(os.getcwd()) filename = self.assertLocalFile() os.chdir(os.path.dirname(filename)) page = '' try: name = os.path.basename(filename) report = tempfile.mktemp()
runner = ExecuteModuleRunner(None, app, profDir)
runner = ExecuteModuleRunner(None, profDir)
def profile(self): filename = self.assertLocalFile() #statFile = os.path.splitext(filename)[0]+'.prof' statFile = tempfile.mktemp() if os.path.exists(statFile): modtime = os.stat(statFile)[stat.ST_MTIME] else: modtime = None profDir = os.path.dirname(filename)