| 414 | pass |
| 415 | |
| 416 | def process_one_line(self): |
| 417 | if self.interactive: |
| 418 | try: |
| 419 | try: |
| 420 | prompt = raw_input # Python 2 |
| 421 | except NameError: |
| 422 | prompt = input # Python 3 |
| 423 | line = prompt(self.get_prompt()) |
| 424 | except KeyboardInterrupt: |
| 425 | self.fout.write('\n') |
| 426 | return |
| 427 | else: |
| 428 | line = self.fin.readline() |
| 429 | if len(line) == 0: |
| 430 | raise EOFError() |
| 431 | |
| 432 | line = line.strip() |
| 433 | |
| 434 | if line: |
| 435 | self.last_cmd = line |
| 436 | try: |
| 437 | try: |
| 438 | cmd = self.find_cmd(line + ' ') |
| 439 | func, args = self.bind_args(cmd, line) |
| 440 | self.call_func(func, args) |
| 441 | except: |
| 442 | if not self.interactive: |
| 443 | self.stop_loop = True |
| 444 | raise |
| 445 | |
| 446 | except self.HandledError: |
| 447 | pass |
| 448 | |
| 449 | except self.InvalidCommandError: |
| 450 | pass |
| 451 | |
| 452 | except self.BindError as e: |
| 453 | self.err(e) |
| 454 | |
| 455 | except self.CommandError as e: |
| 456 | self.err(e) |
| 457 | |
| 458 | def save_history(self): |
| 459 | if self.interactive and self.rl and self.history_file: |