comparison cmd2.py @ 32:ebefe2d57e3b

multiline stops after line 2
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Fri, 21 Dec 2007 15:31:17 -0500
parents 5e2f6ec2e383
children 061f40299ed5
comparison
equal deleted inserted replaced
31:5e2f6ec2e383 32:ebefe2d57e3b
92 self.stdout.flush() 92 self.stdout.flush()
93 line = self.stdin.readline() 93 line = self.stdin.readline()
94 if not len(line): 94 if not len(line):
95 line = 'EOF' 95 line = 'EOF'
96 else: 96 else:
97 line = line[:-1] # chop \n 97 if line[-1] == '\n': # this was always true in Cmd
98 line = line[:-1]
98 return line 99 return line
99 100
101 def cmdloop(self, intro=None):
102 """Repeatedly issue a prompt, accept input, parse an initial prefix
103 off the received input, and dispatch to action methods, passing them
104 the remainder of the line as argument.
105 """
106
107 # An almost perfect copy from Cmd; however, the pseudo_raw_input portion
108 # has been split out so that it can be called separately
109
110 self.preloop()
111 if self.use_rawinput and self.completekey:
112 try:
113 import readline
114 self.old_completer = readline.get_completer()
115 readline.set_completer(self.complete)
116 readline.parse_and_bind(self.completekey+": complete")
117 except ImportError:
118 pass
119 try:
120 if intro is not None:
121 self.intro = intro
122 if self.intro:
123 self.stdout.write(str(self.intro)+"\n")
124 stop = None
125 while not stop:
126 if self.cmdqueue:
127 line = self.cmdqueue.pop(0)
128 else:
129 line = self.pseudo_raw_input(self.prompt)
130 line = self.precmd(line)
131 stop = self.onecmd(line)
132 stop = self.postcmd(stop, line)
133 self.postloop()
134 finally:
135 if self.use_rawinput and self.completekey:
136 try:
137 import readline
138 readline.set_completer(self.old_completer)
139 except ImportError:
140 pass
141
142
100 def do_EOF(self, arg): 143 def do_EOF(self, arg):
101 return True 144 return True
102 do_eof = do_EOF 145 do_eof = do_EOF
103 146
104 statementEndPattern = re.compile(r'([%s]\s*)|(EOF)$' % terminators) 147 statementEndPattern = re.compile(r'([%s]\s*)|(EOF)$' % terminators)