Re: [PyCrust] 0.6 in the oven, now with PyFilling, should be done cooking soon
Brought to you by:
pobrien
From: Raul C. <co...@uc...> - 2001-09-19 17:58:48
|
Well... I took me a while to get back to normal after last week. Patrick: I think the "run" method needs the following lines, to make sure that the "command" and the "output" are written at the very end. def run(self, command, prompt=1, verbose=1): """Execute command within the shell as if it was typed in directly. >>> shell.run('print "this"') >>> print "this" this >>> """ # Go to the very bottom of the text. endpos = self.GetTextLength() self.SetCurrentPos(endpos) command = command.rstrip() if prompt: self.prompt() if verbose: self.write(command) self.push(command) What do you think? BTW... I'm implementing some small methods for my own purposes: def StartSavingToFile(self, filePath=None, append=false): """Begin saving all the code sent or written to the interpreter""" def CloseFile(self): """Close the file and stop saving commands""" def ChangeFileName(self, filePath, append=false): """Begins saving in a new file, copying all the info from the last file""" They are basically methods to save all the commands written in the interpreter, so the user can load them from a file. Are you interested at all ??? Raúl "Patrick K. O'Brien" wrote: > > The code for runfile should give you one idea for how to get around this. > I'm open to suggestions for improving this mechanism. > > def run(self, command, prompt=1, verbose=1): > """Execute command within the shell as if it was typed in directly. > >>> shell.run('print "this"') > >>> print "this" > this > >>> > """ > command = command.rstrip() > if prompt: self.prompt() > if verbose: self.write(command) > self.push(command) > > def runfile(self, filename): > """Execute all commands in file as if they were typed into the > shell.""" > file = open(filename) > try: > self.prompt() > for command in file.readlines(): > if command[:6] == 'shell.': # Run shell methods silently. > self.run(command, prompt=0, verbose=0) > else: > self.run(command, prompt=0, verbose=1) > finally: > file.close() > > --- > Patrick K. O'Brien > Orbtech (http://www.orbtech.com) > "I am, therefore I think." > > -----Original Message----- > From: pyc...@li... > [mailto:pyc...@li...]On Behalf Of Raul Cota > Sent: Saturday, September 08, 2001 6:33 PM > To: pyc...@li... > Subject: Re: [PyCrust] 0.6 in the oven, now with PyFilling, should be done > cooking soon > > <snip> > > 2) My application uses a lot the run command in shell.py, and there's > something I don't particullary like. The code: > sh.run('r = 5') > sh.run('x = 6') > sh.run('t = 8') > > gives the following output in the interpreter > >>> > >>> r = 5 > >>> > >>> x = 6 > >>> > >>> t = 8 > >>> > > instead of > >>> r = 5 > >>> x = 6 > >>> t = 8 > > the method run, writes the ouptut one line after the active line, so, if > the active line is somewhere above... things like this happen (I ran the > same code several times)... > >>> parentFlowsh.Solve() > myFlash > >>> parentFlowsh.Solve() > myFlash1 > >>> 1 > >>> > >>> parentFlowsh.Solve() > myFlash1 > >>> > >>> parentFlowsh.Solve() > myFlash1 > >>> > >>> par > >>> parentFlowsh.Solve() > myFlash1 > >>> entFlowsh.Solve() > myFlash1 > >>> parentFlowsh.Solve() > myFlash1 > >>> > > Every two lines it should say .... > >>> parentFlowsh.Solve() > myFlash1 > > Right now, I was working on trying to fix > > Raul > > _______________________________________________ > PyCrust-users mailing list > PyC...@li... > https://lists.sourceforge.net/lists/listinfo/pycrust-users |