comparison cmd2.py @ 19:25f22e742a68

statement ends fixed
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Wed, 19 Dec 2007 11:30:13 -0500
parents d0f0b3e0b89b
children d6d64c2e3b98
comparison
equal deleted inserted replaced
18:d0f0b3e0b89b 19:25f22e742a68
83 return statement 83 return statement
84 # assembling a list of lines and joining them at the end would be faster, 84 # assembling a list of lines and joining them at the end would be faster,
85 # but statementHasEnded needs a string arg; anyway, we're getting 85 # but statementHasEnded needs a string arg; anyway, we're getting
86 # user input and users are slow. 86 # user input and users are slow.
87 87
88 statementEndPattern = re.compile(r'[\n;]\s*$')
88 def statementHasEnded(self, lines): 89 def statementHasEnded(self, lines):
89 """This version lets statements end with ; or with a blank line. 90 """This version lets statements end with ; or with a blank line.
90 Override for your own needs.""" 91 Override for your own needs."""
91 print '>%s<' % (lines.splitlines()[-1]) 92 return bool(self.statementEndPattern.search(lines))
92 if not lines.splitlines()[-1].strip(): 93
93 return True
94 return (lines.strip()[-1] == ';')
95
96 def do_history(self, arg): 94 def do_history(self, arg):
97 """history [arg]: lists past commands issued 95 """history [arg]: lists past commands issued
98 96
99 no arg -> list all 97 no arg -> list all
100 arg is integer -> list one history item, by index 98 arg is integer -> list one history item, by index