comparison cmd2.py @ 22:221095f3a4af

all load done but a bad chop
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Wed, 19 Dec 2007 14:21:30 -0500
parents 8b55aaa52ce9
children 07aae987b754
comparison
equal deleted inserted replaced
21:8b55aaa52ce9 22:221095f3a4af
15 class Cmd(cmd.Cmd): 15 class Cmd(cmd.Cmd):
16 caseInsensitive = True 16 caseInsensitive = True
17 multilineCommands = [] 17 multilineCommands = []
18 continuationPrompt = '> ' 18 continuationPrompt = '> '
19 shortcuts = {'?': 'help', '!': 'shell', '@': 'load'} 19 shortcuts = {'?': 'help', '!': 'shell', '@': 'load'}
20 excludeFromHistory = '''run r list l history hi ed li'''.split() 20 excludeFromHistory = '''run r list l history hi ed li eof'''.split()
21 defaultExtension = 'txt' 21 defaultExtension = 'txt'
22 def __init__(self, *args, **kwargs): 22 def __init__(self, *args, **kwargs):
23 cmd.Cmd.__init__(self, *args, **kwargs) 23 cmd.Cmd.__init__(self, *args, **kwargs)
24 self.history = History() 24 self.history = History()
25 25
74 line = 'EOF' 74 line = 'EOF'
75 else: 75 else:
76 line = line[:-1] # chop \n 76 line = line[:-1] # chop \n
77 return line 77 return line
78 78
79 def do_EOF(self, arg):
80 return True
81 do_eof = do_EOF
82
79 statementEndPattern = re.compile(r'[\n;]\s*$') 83 statementEndPattern = re.compile(r'[\n;]\s*$')
80 def statementHasEnded(self, lines): 84 def statementHasEnded(self, lines):
81 """This version lets statements end with ; or with a blank line. 85 """This version lets statements end with ; or with a blank line.
82 Override for your own needs.""" 86 Override for your own needs."""
83 return bool(self.statementEndPattern.search(lines)) 87 return bool(self.statementEndPattern.search(lines))
162 print 'Problem opening file %s: \n%s' % (fname, e) 166 print 'Problem opening file %s: \n%s' % (fname, e)
163 self.stdin = stdin 167 self.stdin = stdin
164 return 168 return
165 use_rawinput = self.use_rawinput 169 use_rawinput = self.use_rawinput
166 self.use_rawinput = False 170 self.use_rawinput = False
167 print 'stdin = ' + str(self.stdin)
168 self.cmdloop() 171 self.cmdloop()
169 self.stdin.close() 172 self.stdin.close()
170 self.stdin = stdin 173 self.stdin = stdin
171 self.use_rawinput = use_rawinput 174 self.use_rawinput = use_rawinput
172 175