def pythonHelp(self, event=None): '''Prompt for a arg for Python's help function, and put it to the log pane.''' c, k = self.c, self.c.k tag = 'python-help' state = k.getState(tag) if state == 0: c.minibufferWantsFocus() k.setLabelBlue('Python help: ') k.getArg(event, tag, 1, self.pythonHelp) else: k.clearState() k.resetLabel() s = k.arg.strip() if s: # Capture the output of Python's help command. old = sys.stdout try: sys.stdout = stdout = g.FileLikeObject() help(str(s)) s2 = stdout.read() finally: sys.stdout = old # Send it to the vr pane as a <pre> block s2 = '<pre>' + s2 + '</pre>' c.putHelpFor(s2)
def pythonHelp1(self, event): c, k = self.c, self.c.k k.clearState() k.resetLabel() s = k.arg.strip() if s: # Capture the output of Python's help command. old = sys.stdout try: sys.stdout = stdout = g.FileLikeObject() help(str(s)) s2 = stdout.read() finally: sys.stdout = old # Send it to the vr pane as a <pre> block s2 = '<pre>' + s2 + '</pre>' c.putHelpFor(s2)
def make_outline(self, fn, lines, rev): '''Create a temp outline from lines.''' # A specialized version of atFileCommands.read. at = self.c.atFileCommands root = self.file_node.insertAsLastChild() root.h = fn + ':' + rev if rev else fn at.initReadIvars(root, fn, importFileName=None, atShadow=None) at.fromString = ''.join(lines) if at.errors > 0: return None at.inputFile = g.FileLikeObject(fromString=at.fromString) at.initReadLine(at.fromString) at.readOpenFile(root, fn, deleteNodes=True) at.inputFile.close() # Special case the root node. root.b = ''.join(getattr(root.v, 'tempBodyList', [])) # root.clearDirty() if True: ### at.errors == 0: at.deleteUnvisitedNodes(root, redraw=False) at.deleteTnodeList(root) at.deleteAllTempBodyStrings() return root
def make_at_file_outline(self, fn, s, rev): '''Create a hidden temp outline from lines.''' # A specialized version of atFileCommands.read. hidden_c = leoCommands.Commands(fn, gui=g.app.nullGui) at = hidden_c.atFileCommands hidden_c.frame.createFirstTreeNode() root = hidden_c.rootPosition() root.h = fn + ':' + rev if rev else fn at.initReadIvars(root, fn, importFileName=None, atShadow=None) at.fromString = s if at.errors > 0: g.trace('***** errors') return None at.inputFile = g.FileLikeObject(fromString=at.fromString) at.initReadLine(at.fromString) at.readOpenFile(root, fn, deleteNodes=True) at.inputFile.close() # Complete the read. for p in root.self_and_subtree(): p.b = ''.join(getattr(p.v, 'tempBodyList', [])) at.scanAllDirectives(root, importing=False, reading=True) return hidden_c