[Cvsshell-devel] CVS: cvsshell/src cvs_shell.py,1.24,1.25 interactive_app.py,1.7,1.8
Status: Beta
Brought to you by:
stefanheimann
From: Stefan H. <ste...@us...> - 2002-06-03 07:40:51
|
Update of /cvsroot/cvsshell/cvsshell/src In directory usw-pr-cvs1:/tmp/cvs-serv21726/src Modified Files: cvs_shell.py interactive_app.py Log Message: * fixed bug in InteractiveApp * auto-refresh of the directory listing is now invoked when the listing is dirty _and_ should be printed and not only when the listing is out-of-date. Index: cvs_shell.py =================================================================== RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_shell.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** cvs_shell.py 27 May 2002 07:32:29 -0000 1.24 --- cvs_shell.py 3 Jun 2002 07:40:48 -0000 1.25 *************** *** 97,104 **** def getPrompt(self): - if self.autoRefresh and self.dirtyListing and self.cvsRoot: - self.printMsg('getting listing from ' + self.cvsRoot) - self.evalCommand('refresh') - self.dirtyListing = 0 status = '' if self.cvsRootAutoUpdate: status += 'a' --- 97,100 ---- *************** *** 322,325 **** --- 318,327 ---- if not self.listing: self.printErr(self.noListingErrMsg) + return + if self.autoRefresh and self.dirtyListing and self.cvsRoot: + self.printMsg('getting listing from ' + self.cvsRoot + + ". To disable this feature execute `auto-root off'.") + self.evalCommand('refresh') + self.dirtyListing = 0 else: self.listing.printEntries() Index: interactive_app.py =================================================================== RCS file: /cvsroot/cvsshell/cvsshell/src/interactive_app.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** interactive_app.py 28 Mar 2002 23:07:37 -0000 1.7 --- interactive_app.py 3 Jun 2002 07:40:48 -0000 1.8 *************** *** 1,104 **** ! ############################################################################### ! # This file is part of CvsShell ! # ! # CvsShell is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # CvsShell is distributed in the hope that it will be useful, ! # but WITHOUT ANY WARRANTY; without even the implied warranty of ! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! # GNU General Public License for more details. ! # ! # You should have received a copy of the GNU General Public License ! # along with CvsShell; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! # ! # Copyright 2002 by Stefan Heimann ! # Website: http://cvsshell.sourceforge.net/ ! ############################################################################### ! ! import os, types ! from app import App, AppError ! ! class InteractiveApp(App): ! ! def __init__(self): ! App.__init__(self) ! self.BREAK_REPL = 'BREAK_REPL' ! self.DEF_PATTERN = '%%def%%' ! try: ! import readline ! except ImportError: ! self.printErr("Could not import readline.\nHistory browsing " \ ! "and tab completion will not be available.") ! return ! else: ! readline.parse_and_bind("tab: complete") ! ! def setHistoryFile(self,filename): ! self.historyFile = filename ! try: ! import readline ! except ImportError: return ! try: ! readline.read_history_file(self.historyFile) ! except IOError: ! pass ! import atexit ! atexit.register(readline.write_history_file, self.historyFile) ! ! def run(self): # define App.run here ! while 1: ! command = self.readCommand() ! if command == None: ! break ! result = self.evalCommand(command) ! if result is self.BREAK_REPL: break ! elif result is None: continue ! else: self.printMsg(result) ! ! def readCommand(self): # subclass hooks + App.start,stop ! p = self.getPrompt() ! if type(p) == types.TupleType: ! return self.prompt(p[0], p[1]) ! else: ! return self.prompt(p) ! ! def getPrompt(self): ! return '? ' ! ! def prompt(self, msg, default=None): ! """Displayes msg and prompts the user for input. ! If input is EOF, None is returned. ! If input is the emtpy string and default is given, default is returned. ! If a default value is given and msg contains self.DEF_PATTERN, ! this part of msg is replaced by the default value surrounded with []. ! Otherwise the default value is append at the end of msg.""" ! if default is not None: ! i = msg.find(self.DEF_PATTERN) ! if i >= 0: ! msg = msg[:i] + '[' + default + ']'+ msg[i+len(self.DEF_PATTERN):] ! else: ! msg += '[%s] ' % default ! try: ! a = raw_input(msg) ! except EOFError: ! self.printMsg() ! return None ! except KeyboardInterrupt: ! self.printMsg() ! return None ! a = os.path.expandvars(a) ! a = os.path.expanduser(a) ! a = a.strip() ! if a == '' and default is not None: return default ! else: return a ! ! def evalCommand(self, command): ! """Subclasses should override this method. ! If BREAK_REPL is returned, the repl is terminated, ! otherwise the return-value is printed (if not None).""" ! raise AppError, 'evalCommand must be redefined!' ! --- 1,104 ---- ! ############################################################################### ! # This file is part of CvsShell ! # ! # CvsShell is free software; you can redistribute it and/or modify ! # it under the terms of the GNU General Public License as published by ! # the Free Software Foundation; either version 2 of the License, or ! # (at your option) any later version. ! # ! # CvsShell is distributed in the hope that it will be useful, ! # but WITHOUT ANY WARRANTY; without even the implied warranty of ! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! # GNU General Public License for more details. ! # ! # You should have received a copy of the GNU General Public License ! # along with CvsShell; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! # ! # Copyright 2002 by Stefan Heimann ! # Website: http://cvsshell.sourceforge.net/ ! ############################################################################### ! ! import os, types ! from app import App, AppError ! ! class InteractiveApp(App): ! ! def __init__(self): ! App.__init__(self) ! self.BREAK_REPL = 'BREAK_REPL' ! self.DEF_PATTERN = '%%def%%' ! try: ! import readline ! except ImportError: ! self.printErr("Could not import readline.\nHistory browsing " \ ! "and tab completion will not be available.") ! return ! else: ! readline.parse_and_bind("tab: complete") ! ! def setHistoryFile(self,filename): ! self.historyFile = filename ! try: ! import readline ! except ImportError: return ! try: ! readline.read_history_file(self.historyFile) ! except IOError: ! pass ! import atexit ! atexit.register(readline.write_history_file, self.historyFile) ! ! def run(self): ! while 1: ! command = self.readCommand() ! if command == None: ! break ! result = self.evalCommand(command) ! if result is self.BREAK_REPL: break ! elif result is None: continue ! else: self.printMsg(result) ! ! def readCommand(self): ! p = self.getPrompt() ! if type(p) == types.TupleType: ! return self.prompt(p[0], p[1]) ! else: ! return self.prompt(p) ! ! def getPrompt(self): ! return '? ' ! ! def prompt(self, msg, default=None): ! """Displayes msg and prompts the user for input. ! If input is EOF, None is returned. ! If input is the emtpy string and default is given, default is returned. ! If a default value is given and msg contains self.DEF_PATTERN, ! this part of msg is replaced by the default value surrounded with []. ! Otherwise the default value is append at the end of msg.""" ! if default is not None: ! i = msg.find(self.DEF_PATTERN) ! if i >= 0: ! msg = msg[:i] + '[' + default + ']'+ msg[i+len(self.DEF_PATTERN):] ! else: ! msg += '[%s] ' % default ! try: ! a = raw_input(msg) ! except EOFError: ! self.printMsg() ! return None ! except KeyboardInterrupt: ! self.printMsg() ! return None ! a = os.path.expandvars(a) ! a = os.path.expanduser(a) ! a = a.strip() ! if a == '' and default is not None: return default ! else: return a ! ! def evalCommand(self, command): ! """Subclasses should override this method. ! If BREAK_REPL is returned, the repl is terminated, ! otherwise the return-value is printed (if not None).""" ! raise AppError, 'evalCommand must be redefined!' ! |