def __init__(self): frame = JFrame("jTODO", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(400, 350), layout=BorderLayout()) treeTrunk = DefaultMutableTreeNode('Contexts') treeTrunk.add(DefaultMutableTreeNode('Sample Context')) self.tree = JTree(treeTrunk) leftPanel = JPanel() leftScrollPane = JScrollPane(self.tree) #leftScrollPane.setPreferredSize( Dimension( 300,250 ) ) leftScrollPane.getViewport().setView((self.tree)) leftPanel.add(leftScrollPane) label2 = JLabel("right") rightPanel = JPanel() rightPanel.add(label2) splitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) splitPane.setLeftComponent(leftPanel) splitPane.setRightComponent(rightPanel) #splitPane.setDividerLocation( 200 ) frame.add(splitPane) frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) frame.show()
def set_checklist_tree(self): self.checklist_tree = DefaultMutableTreeNode("HUNT - Methodology") for item in self.checklist: node = DefaultMutableTreeNode(item) self.checklist_tree.add(node) is_functionality = node.toString() == "Functionality" if is_functionality: functionality_node = node functionality = self.checklist["Functionality"] # Sorts the functionality by name and by test name functionality_list = [] for functionality_name in functionality: functionality_list.append(functionality_name) for functionality_name in sorted(functionality_list): tests = functionality[functionality_name]["tests"] node = DefaultMutableTreeNode(functionality_name) tests_list = [] for test_name in tests: tests_list.append(test_name) for test_name in sorted(tests_list): node.add(DefaultMutableTreeNode(test_name)) functionality_node.add(node)
def __init__(self, dir, packages=[]): DefaultMutableTreeNode.__init__(self) self.dir = dir self.packages = packages self.isJar = (self.dir.find(".jar") >= 0) self.isZip = (self.dir.find(".zip") >= 0) for subitem in self.getSubList(): self.add(subitem)
def __init__(self, *args, **kwargs): DefaultMutableTreeNode.__init__(self, *args, **kwargs) self.expanded = 0 self.m_children = [] self.children = Vector() self.model = ObjectNodeModel() self.nodes = {} self.is_leaf = -1
def __appendCaseMethodsHelper(self, case, caseNode, metaName, entityName): ''' helper for appendCommands, appendFixture & appendHelpers ''' mtdMeta = DefaultMutableTreeNode(metaName) caseNode.add(mtdMeta) mtds = [edge.getNode2() for edge in case->(entity == entityName)] mtds.sort(cmpTc) for mtd in mtds: mtdNode = DefaultMutableTreeNode(mtd.label) mtdMeta.add(mtdNode)
def addEvent(self, event): sPath = self.tree.getSelectionModel().getSelectionPath() if sPath: # Use selected node parent = sPath.getLastPathComponent() else: # Nothing selected, use root parent = self.model.getRoot() kids = parent.getChildCount() child = DefaultMutableTreeNode('New node %d' % self.getSuffix()) self.model.insertNodeInto(child, parent, kids) self.tree.scrollPathToVisible(TreePath(child.getPath()))
def makeTree(self): #----------------------------------------------------------------------- # First, build the hierarchy of Tree nodes #----------------------------------------------------------------------- root = DefaultMutableTreeNode('Root Node') for name in 'Parent 1,Parent 2'.split(','): here = DefaultMutableTreeNode(name) for child in 'Child 1,Child 2'.split(','): here.add(DefaultMutableTreeNode(child)) root.add(here) #----------------------------------------------------------------------- # Next, use the hierarchy to create a Tree Model, with a listener #----------------------------------------------------------------------- model = DefaultTreeModel(root, treeModelListener=myTreeModelListener()) #----------------------------------------------------------------------- # Then, build our editable JTree() using this model #----------------------------------------------------------------------- tree = JTree(model, editable=1, showsRootHandles=1, valueChanged=self.select) #----------------------------------------------------------------------- # Only allow one node to be selectable at a time #----------------------------------------------------------------------- tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION) return tree
def groupTree(self): data = AdminTask.help('-commandGroups').expandtabs().splitlines() root = DefaultMutableTreeNode('command groups') for line in data[1:]: mo = re.match('([a-zA-Z ]+) -', line) if mo: groupName = mo.group(1) group = None text = AdminTask.help(groupName) cmds = text.find('Commands:') if cmds > 0: for line in text[cmds + 9:].splitlines(): mo = re.match('([a-zA-Z_2]+) -', line) if mo: if not group: group = DefaultMutableTreeNode(groupName) group.add(DefaultMutableTreeNode(mo.group(1))) if group: root.add(group) else: print 'Empty group:', groupName return JTree( root, rootVisible=0 #, # valueChanged = self.select )
def make_tree(self): print('make_tree') root = DefaultMutableTreeNode(self.exper.name) sb = br.SimilarityBuilder() for hseg in self.exper.hsegs(): all_file_dict = hseg.file_dict() all_file_dict.update(hseg.cell_file_dict()) all_file_dict.update(hseg.bin_file_dict()) sb.add_group(hseg.name, all_file_dict) simprofile, comparisons = sb.simprofile_comparison() sim_str = '' for val in simprofile: sim_str += str(val) + '\n' tp = JTextArea(sim_str) stp = JScrollPane() stp.getViewport().setView(tp) # # stp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); # stp.setPreferredSize(Dimension(250, 250)); # tp.setPreferredSize(Dimension(250, 250)) stp_panel = JPanel(BorderLayout()) stp_panel.add(tp, BorderLayout.CENTER) # self.add(stp_panel, 'grow') for hseg in self.exper.hsegs(): hseg_node = DefaultMutableTreeNode(hseg.name) root.add(hseg_node) if len(comparisons[hseg.name]) > 0: for definer, file_names in comparisons[hseg.name].items(): for file_name in file_names: node_str = definer + ': ' + file_name hseg_node.add(DefaultMutableTreeNode(node_str)) # for file_suf in hseg.file_dict() : # hseg_node.add(DefaultMutableTreeNode(file_suf)) self.tree = JTree(root) scrollPane = JScrollPane() scrollPane.getViewport().setView((self.tree)) # scrollPan # scrollPane.setPreferredSize(Dimension(300,250)) tree_panel = JPanel(BorderLayout()) tree_panel.add(scrollPane, BorderLayout.CENTER) combo_panel = JPanel(GridLayout(0, 2, 10, 10)) # combo_panel.setLayout(BoxLayout(combo_panel, BoxLayout.X_AXIS)) combo_panel.add(stp_panel) #, BorderLayout.LINE_START) combo_panel.add(tree_panel) #, BorderLayout.LINE_END) self.panel.add(combo_panel) # self.add(scrollPane, 'grow') self.revalidate()
def buildReducedTreeFromLayers(root, layers): folders = dict() for path,layer in layers: dirname = os.path.dirname(path) leafs = folders.get(dirname,None) if leafs == None: leafs=list() folders[dirname] = leafs leafs.append((path,layer)) paths = folders.keys() paths.sort() for path in paths: # select icon and insert in tree folderPath = folders[path] if not os.path.isdir(path): properIcon = getIconByPath(gvsig.getResource(__file__,"images","Database.png")) if path=="": i18n = ToolsLocator.getI18nManager() path=i18n.getTranslation("_Services") folder = DefaultMutableTreeNode(DataGroup(path,path,properIcon)) else: properIcon = getIconByName("librarybrowser-folder") folder = DefaultMutableTreeNode(DataGroup(path,path,properIcon)) root.insert(folder, root.getChildCount()) for pathLayer,layer in folderPath: leaf = DefaultMutableTreeNode(DataLayer(pathLayer,layer)) folder.insert(leaf, folder.getChildCount())
def createUpdatedModel(self): """When the user does any changes in the tree, the underlaying kconfig structure will change. Nodes may change visibility and value. The tree control cannot hide nodes, so a new datamodel must be generated that does not include invisible nodes.""" shadowTreeRoot = self.shadowModel.getRoot() rootNode = DefaultMutableTreeNode("Root") self.addVisibleNodes(rootNode, shadowTreeRoot) return DefaultTreeModel(rootNode)
def cellTree(self): # Use the cellName as the tree root node cell = AdminConfig.list('Cell') root = DefaultMutableTreeNode(self.getName(cell)) for node in AdminConfig.list('Node').splitlines(): here = DefaultMutableTreeNode(self.getName(node)) servers = AdminConfig.list('Server', node) for server in servers.splitlines(): leaf = DefaultMutableTreeNode(self.getName(server)) here.add(leaf) root.add(here) return JTree(root, editable=1)
def createTreeModel(mapContext, reducedTree=True): i18n = ToolsLocator.getI18nManager() root = DefaultMutableTreeNode(i18n.getTranslation("_Root")) localLayers = DefaultMutableTreeNode(DataFolder(i18n.getTranslation("_Local_layers"),None)) remoteLayers = DefaultMutableTreeNode(DataFolder(i18n.getTranslation("_Remote_layers"),None)) root.insert(localLayers, root.getChildCount()) root.insert(remoteLayers, root.getChildCount()) layers = list() remotes = list() for layer in iter(mapContext.deepiterator()): getDataStore = getattr(layer,"getDataStore",None) if getDataStore == None: continue if getDataStore() == None: # asumimos que es raster uri = layer.getURI() if uri != None: layers.append((uri.getPath(),layer)) else: remotes.append((layer.getName(), layer)) continue params = getDataStore().getParameters() getFile = getattr(params, "getFile", None) if getFile != None and getFile() !=None: getTable = getattr(params, "getTable", None) if getTable != None and getTable() !=None: layers.append((os.path.join(getFile().getAbsolutePath(),getTable()),layer)) else: layers.append((getFile().getAbsolutePath(),layer)) else: remotes.append((layer.getName(), layer)) layers.sort(cmp = lambda x,y: cmp(x[0],y[0])) if reducedTree: buildReducedTreeFromLayers(localLayers,layers) buildReducedTreeFromLayers(remoteLayers,remotes) else: for path,layer in layers: buildTreeFromPath(localLayers,path,layer) model = DefaultTreeModel(root) return model
def __appendCases(self, pkg, pkgNode): ''' append the test cases of a single package to the tree ''' testcases = [edge.getNode2() for edge in (pkg->g.nodes)] testcases.sort(cmpTc) for tc in testcases: tcNode = DefaultMutableTreeNode(tc.label.split('::')[-1]) pkgNode.add(tcNode) self.__appendCommands(tc, tcNode) self.__appendFixture(tc, tcNode) self.__appendHelpers(tc, tcNode)
def __initTree(self): ''' construct the suite tree ''' top = DefaultMutableTreeNode("RootSuite") self.__createNodes(top) self.tree = JTree(top) self.__setupRenderer() self.scrollpane = JScrollPane(self.tree) self.add(self.scrollpane,self.__setupLayout()) self.tree.addTreeSelectionListener(NodeHighlighter()) self.tree.addMouseListener(TreeMouseListener())
def addNodes(self, parent, node): """Recursively traverse the KConfig structure and add to the shadow model""" while node: newUiNode = DefaultMutableTreeNode(TreeNodeData(node, self)) parent.add(newUiNode) if node.list: self.addNodes(newUiNode, node.list) node = node.next
def addLevel2Items(self, branch, branchData=None): ''' add data to tree branch requires branch and data to add to branch ''' # this does not check to see if its a valid branch if branchData == None: branch.add(DefaultMutableTreeNode('No valid data')) else: for item in branchData: # add the data from the specified list to the branch branch.add(self.DefaultMutableTreeNode(item))
def performAction(self, row): model = self._extender.tree.getModel() root = model.getRoot() root.removeAllChildren() model.reload() self.xssroot = DefaultMutableTreeNode('Cross-Site-Scripting') root.add(self.xssroot) self.sqliroot = DefaultMutableTreeNode('SQL Injection') root.add(self.sqliroot) self.sstiroot = DefaultMutableTreeNode('Server Side Template Injection') root.add(self.sstiroot) resultxss = [] resultsqli = [] resultssti = [] logEntry = self._extender._log.get(self._extender.logTable.convertRowIndexToModel(row)) resultxss = logEntry._resultxss resultsqli = logEntry._resultsqli resultssti = logEntry._resultssti parameter = logEntry._parameter for i in range(len(parameter)): if resultxss[i] == self._extender.CHECK or resultxss[i] == self._extender.FOUND: array = [] array.append(parameter[i].getName()) self._extender.addIssues(self.xssroot, array) if resultsqli[i] == self._extender.CHECK or resultsqli[i] == self._extender.FOUND: array = [] array.append(parameter[i].getName()) self._extender.addIssues(self.sqliroot, array) if resultssti[i] == self._extender.CHECK or resultssti[i] == self._extender.FOUND: array = [] array.append(parameter[i].getName()) self._extender.addIssues(self.sstiroot, array) self._extender.rowSelected = row return
def issuesTab(self): self.root = DefaultMutableTreeNode('Issues') frame = JFrame("Issues Tree") self.tree = JTree(self.root) self.rowSelected = '' self.tree.addMouseListener(mouseclick(self)) self.issuepanel = JScrollPane() self.issuepanel.setPreferredSize(Dimension(300,450)) self.issuepanel.getViewport().setView((self.tree)) frame.add(self.issuepanel,BorderLayout.CENTER)
def _add_nodes(self, curTop, dir): """ Recursive implementation to fill the tree with filenames and directories :param curTop: current top directory :param dir: next directory :return: None """ curPath = dir.getPath() if os.path.isdir(curPath): nodePath = os.path.basename(curPath) curDir = DefaultMutableTreeNode(nodePath) if curTop != None: # should only be null at root curTop.add(curDir) ol = Vector() tmp = dir.list() for i in xrange(0, len(tmp)): ol.addElement(tmp[i]) thisObject = None files = Vector() # Make two passes, one for Dirs and one for Files. This is #1. for i in xrange(0, ol.size()): thisObject = ol.elementAt(i) if curPath == self._dir: newPath = thisObject else: newPath = os.path.join(curPath, thisObject) f = File(newPath) if f.isDirectory(): self._add_nodes(curDir, f) else: files.addElement(thisObject) # Pass two: for files. Collections.sort(files) for i in xrange(0, files.size()): f = files.elementAt(i) #if f.split('.')[-1] != 'html': curDir.add(DefaultMutableTreeNode(files.elementAt(i))) return curDir
def make_tree(self): root = DefaultMutableTreeNode(self.exper.name) for hseg in self.exper.hsegs(): hseg_node = DefaultMutableTreeNode(hseg.name) root.add(hseg_node) for file_suf in hseg.file_dict(): hseg_node.add(DefaultMutableTreeNode(file_suf)) self.tree = JTree(root) scrollPane = JScrollPane() scrollPane.getViewport().setView((self.tree)) # scrollPane.setPreferredSize(Dimension(300,250)) tree_panel = JPanel() tree_panel.add(scrollPane) box_layout = BoxLayout(self.panel, BoxLayout.Y_AXIS) self.panel.setLayout(box_layout) self.panel.add(tree_panel) self.revalidate()
def set_vuln_tree(self): self.vuln_tree = DefaultMutableTreeNode("HUNT Scanner") vulns = self.json["issues"] for vuln_name in sorted(vulns): vuln = DefaultMutableTreeNode(vuln_name) self.vuln_tree.add(vuln) parameters = self.json["issues"][vuln_name]["params"] for parameter in sorted(parameters): param_node = DefaultMutableTreeNode(parameter) vuln.add(param_node) self.vuln_tree.add(DefaultMutableTreeNode("Settings"))
def __init__(self, channels, item_model): print "ChannelTree __init__" self.item_model = item_model root = DefaultMutableTreeNode("Root") tree_model = DefaultTreeModel(root) idx = 0 print "channels", channels for channel in channels: node = ChannelTreeNode(channel) tree_model.insertNodeInto(node, root, idx) idx = idx + 1 JTree.__init__(self, tree_model)
def __init__(self): mCitiesData = ['Memphis', 'Melbourne', 'Milan', 'Marrakech', 'Moscow', 'Munich'] sCitiesData = ['San Francisco', 'Salzburg', 'Santiago', 'Sydney', 'Sandnessjoen', 'Stockholm'] frame = JFrame("Jython JTree Example") frame.setSize(400, 350) frame.setLayout(BorderLayout()) root = DefaultMutableTreeNode('Cities') mCities = DefaultMutableTreeNode('Cities starting with M') sCities = DefaultMutableTreeNode('Cities starting with S') root.add(mCities) root.add(sCities) #now add the cities starting with M & S self.addCities(mCities, mCitiesData) self.addCities(sCities, sCitiesData) self.tree = JTree(root) scrollPane = JScrollPane() # add a scrollbar to the viewport scrollPane.setPreferredSize(Dimension(300,250)) scrollPane.getViewport().setView((self.tree)) panel = JPanel() panel.add(scrollPane) frame.add(panel, BorderLayout.CENTER) btn = JButton('Select', actionPerformed = self.citySelect) frame.add(btn,BorderLayout.SOUTH) self.label = JLabel('Select city') frame.add(self.label, BorderLayout.NORTH) frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) frame.setVisible(True) self.addCities
def createToCContextMenu(mapContext, selectedLayer): # TOC.java menu = JPopupMenu() ep = ToolsLocator.getExtensionPointManager().get("View_TocActions") from org.gvsig.app.project.documents.view.toc.actions import ZoomAlTemaTocMenuEntry #from org.gvsig.app.project.documents.view.ViewManager import ContextMenuActionAdapterToExtensionBuilder #ep.append("ZoomAlTema", "", ZoomAlTemaTocMenuEntry()) tocItem = TocItemLeaf(None, selectedLayer.getName(),selectedLayer.getShapeType()) nodeValue = DefaultMutableTreeNode(tocItem) #menu = FPopupMenu(mapContext, nodeValue) #return menu activesLayers = mapContext.getLayers().getActives() actions = [] for epx in ep.iterator(): action = epx.create() actions.append([action,action.getGroupOrder(), action.getGroup(), action.getOrder()]) sortedActions = sorted(actions, key = lambda x: (x[1], x[2],x[3])) group = None z = ZoomAlTemaTocMenuEntry() z.setMapContext(mapContext) zitem = LayerMenuItem(z, selectedLayer,tocItem, mapContext) menu.add(zitem) menu.addSeparator() for actionList in sortedActions: action = actionList[0] if action.isVisible(tocItem, activesLayers): #(layer,)): if group == None: pass elif group != action.getGroup(): menu.addSeparator() group = action.getGroup() if isinstance(action, AbstractTocContextMenuAction): action.setMapContext(mapContext) if action.isEnabled(tocItem, activesLayers): newItem = LayerMenuItem(action, selectedLayer, tocItem, mapContext) menu.add(newItem) else: newItem = LayerMenuItem(action, selectedLayer, tocItem, mapContext) newItem.setEnabled(False) menu.add(newItem) return menu
def buildTreeFromPath(root, path, layer): if path[0]=="/": path=path[1:] pathsegments = path.split("/") node = root curpath = "" for segment in pathsegments: curpath = os.path.join(curpath,segment) index = childIndex(node, segment) if index < 0: newChild = DefaultMutableTreeNode(DataFolder(segment,curpath)) node.insert(newChild, node.getChildCount()) node = newChild else: node = node.getChildAt(index) node.setUserObject(DataLayer(path,layer))
def addVisibleNodes(self, visibleParent, shadowParent): """Adds visible nodes from the shadow tree model to the update tree model. If there is an active search operation, only search matches will be added. If showAll is set, all nodes are added regardless of visibility.""" childrenEnum = shadowParent.children() while childrenEnum.hasMoreElements(): shadowChild = childrenEnum.nextElement() if shadowChild.getUserObject().getVisible() > 0 or self.showAll: if not self.isSearching or shadowChild.getUserObject( ).isSearchMatch(): visibleChild = DefaultMutableTreeNode( shadowChild.getUserObject()) visibleParent.add(visibleChild) if shadowChild.getChildCount() > 0: self.addVisibleNodes(visibleChild, shadowChild)
def set_vuln_tree(self): self.vuln_tree = DefaultMutableTreeNode("Vulnerability Classes") vulns = self.json["issues"] # TODO: Sort the functionality by name and by vuln class for vuln_name in vulns: vuln = DefaultMutableTreeNode(vuln_name) self.vuln_tree.add(vuln) parameters = self.json["issues"][vuln_name]["params"] for parameter in parameters: param_node = DefaultMutableTreeNode(parameter) vuln.add(param_node)
def cellTree(self): #----------------------------------------------------------------------- # Use the cellName as the tree root node #----------------------------------------------------------------------- cell = AdminConfig.list('Cell') cellName = self.getName(cell) root = DefaultMutableTreeNode(cellName) #----------------------------------------------------------------------- # Build an item name to configId dictionary #----------------------------------------------------------------------- result = {cellName: cell} #----------------------------------------------------------------------- # Use the node name for the branches #----------------------------------------------------------------------- for node in AdminConfig.list('Node').splitlines(): nodeName = self.getName(node) here = DefaultMutableTreeNode(nodeName) #------------------------------------------------------------------- # Add this node to the dictionary #------------------------------------------------------------------- result[nodeName] = node #------------------------------------------------------------------- # and the server name for each leaf #------------------------------------------------------------------- servers = AdminConfig.list('Server', node) for server in servers.splitlines(): name = self.getName(server) leaf = DefaultMutableTreeNode(name) #--------------------------------------------------------------- # Add this server to the dictionary # Note: Server names are not guaranteed to be unique in the cell #--------------------------------------------------------------- result[(nodeName, name)] = server here.add(leaf) root.add(here) return JTree(root), result
def make_hseg_tree_panel(self): root = DefaultMutableTreeNode(self.exper.name) for hseg in self.exper.hsegs(): hseg_node = DefaultMutableTreeNode(hseg.name) root.add(hseg_node) hseg_at_deviations = self.exper.hseg_all_files_cab( ).archetype_deviations if len(hseg_at_deviations[hseg.name]) > 0: for definer, file_names in hseg_at_deviations[ hseg.name].items(): for file_name in file_names: node_str = definer + ': ' + file_name temp = DefaultMutableTreeNode(node_str) hseg_node.add(temp) hseg_tree = JTree(root) hseg_tree.setCellRenderer(BobPyTreeCellRenderer()) hseg_scroll_pane = JScrollPane() hseg_scroll_pane.getViewport().setView((hseg_tree)) return hseg_scroll_pane
def make_hseg_tree_panel(self): root = DefaultMutableTreeNode(self.exper.name) for hseg in self.exper.hsegs(): hseg_node = DefaultMutableTreeNode(hseg.name) root.add(hseg_node) hseg_at_deviations = self.exper.hseg_files_cab( ).archetype_deviations if len(hseg_at_deviations[hseg.name]) > 0: for definer, file_names in hseg_at_deviations[ hseg.name].items(): for file_name in file_names: node_str = definer + ': ' + file_name temp = DefaultMutableTreeNode(node_str) hseg_node.add(temp) hseg_tree = JTree(root) hseg_tree.setCellRenderer(BobPyTreeCellRenderer()) hseg_scroll_pane = JScrollPane() hseg_scroll_pane.getViewport().setView((hseg_tree)) hseg_panel = JPanel(MigLayout('insets 0')) hseg_panel.add(hseg_scroll_pane, 'grow, span, push, wrap') run_button = JButton('Run') run_button.addActionListener(ActionListenerFactory(self, self.run_al)) rerun_button = JButton('Rerun') rerun_button.addActionListener( ActionListenerFactory(self, self.rerun_al)) hseg_panel.add(run_button) hseg_panel.add(rerun_button) return hseg_panel
def createTree(self,xnode): if xnode.hasChildNodes(): tnode = DefaultMutableTreeNode(xnode.getNodeName()) else: tnode = DefaultMutableTreeNode(xnode) return tnode child_nodes = xnode.getChildNodes() child_count = child_nodes.getLength() for i in range(child_count): element = child_nodes.item(i) if xnode.getTagName() == "table_row": continue if isinstance(element,ElementNode): tnode.add( self.createTree(child_nodes.item(i)) ) return tnode
def __init__(self, klass, parent, buffer, next_start): bases = [] if len(klass.super): for superclass in klass.super: if isinstance(superclass, pyclbr.Class): bases.append(superclass.name) else: bases.append(superclass) name = 'class ' + klass.name + '(' + ','.join(bases) + '):' PyAsset.__init__(self, name, klass.lineno, buffer) self.createPositions(buffer, klass.lineno, next_start) node = DefaultMutableTreeNode(self) parent.add(node) methods = klass.methods.items() # sort by line numbers (name,line) methods.sort(lambda (name1,line1),(name2,line2): line1 - line2) for i in range(len(methods)): name,lineno = methods[i] _next_start = next_start try: _next_start = methods[i+1][-1] except IndexError: pass MethodAsset(name,lineno,node,buffer,_next_start)
def __init__(self, channel): self.channel = channel DefaultMutableTreeNode.__init__(self, channel.getTitle())