Mercurial > python-cmd2
comparison cmd2.py @ 355:5972ae04515e
EOF is now the 'unusual' stop signal
author | catherine@dellzilla |
---|---|
date | Wed, 17 Feb 2010 12:32:49 -0500 |
parents | 7cd04727f7f7 |
children | d275d3beceff |
comparison
equal
deleted
inserted
replaced
354:7cd04727f7f7 | 355:5972ae04515e |
---|---|
413 if not self.quiet: | 413 if not self.quiet: |
414 if self.feedback_to_output: | 414 if self.feedback_to_output: |
415 self.poutput(msg) | 415 self.poutput(msg) |
416 else: | 416 else: |
417 print (msg) | 417 print (msg) |
418 _STOP_AND_EXIT = 2 # distinguish end of script file from actual exit | 418 _STOP_AND_EXIT = True # distinguish end of script file from actual exit |
419 _STOP_SCRIPT_NO_EXIT = -999 | |
419 editor = os.environ.get('EDITOR') | 420 editor = os.environ.get('EDITOR') |
420 if not editor: | 421 if not editor: |
421 if sys.platform[:3] == 'win': | 422 if sys.platform[:3] == 'win': |
422 editor = 'notepad' | 423 editor = 'notepad' |
423 else: | 424 else: |
909 except ImportError: | 910 except ImportError: |
910 pass | 911 pass |
911 return stop | 912 return stop |
912 | 913 |
913 def do_EOF(self, arg): | 914 def do_EOF(self, arg): |
914 return True | 915 return self._STOP_SCRIPT_NO_EXIT # End of script; should not exit app |
915 do_eof = do_EOF | 916 do_eof = do_EOF |
916 | 917 |
917 def do_quit(self, arg): | 918 def do_quit(self, arg): |
918 return self._STOP_AND_EXIT | 919 return self._STOP_AND_EXIT |
919 do_exit = do_quit | 920 do_exit = do_quit |
1196 self.current_script_dir = os.path.split(targetname)[0] | 1197 self.current_script_dir = os.path.split(targetname)[0] |
1197 stop = self._cmdloop() | 1198 stop = self._cmdloop() |
1198 self.stdin.close() | 1199 self.stdin.close() |
1199 keepstate.restore() | 1200 keepstate.restore() |
1200 self.lastcmd = '' | 1201 self.lastcmd = '' |
1201 return (stop == self._STOP_AND_EXIT) and self._STOP_AND_EXIT | 1202 return stop and (stop != self._STOP_SCRIPT_NO_EXIT) |
1202 do__load = do_load # avoid an unfortunate legacy use of do_load from sqlpython | 1203 do__load = do_load # avoid an unfortunate legacy use of do_load from sqlpython |
1203 | 1204 |
1204 def do_run(self, arg): | 1205 def do_run(self, arg): |
1205 """run [arg]: re-runs an earlier command | 1206 """run [arg]: re-runs an earlier command |
1206 | 1207 |