(self, args)
| 505 | return regexp.sub(ImpalaShell.COMMENTS_BEFORE_SET_REPLACEMENT, line, 1) |
| 506 | |
| 507 | def sanitise_input(self, args): |
| 508 | # A command terminated by a semi-colon is legal. Check for the trailing |
| 509 | # semi-colons and strip them from the end of the command. |
| 510 | if not self.interactive: |
| 511 | # Strip all the non-interactive commands of the delimiter. |
| 512 | args = self._remove_comments_before_set(args) |
| 513 | tokens = args.strip().split(' ') |
| 514 | return ' '.join(tokens).rstrip(ImpalaShell.CMD_DELIM) |
| 515 | # Handle EOF if input is interactive |
| 516 | tokens = args.strip().split(' ') |
| 517 | if tokens[0].lower() == 'eof': |
| 518 | if not self.partial_cmd: |
| 519 | # The first token is the command. |
| 520 | # If it's EOF, call do_quit() |
| 521 | return 'quit' |
| 522 | else: |
| 523 | # If a command is in progress and the user hits a Ctrl-D, clear its state |
| 524 | # and reset the prompt. |
| 525 | self.prompt = self.cached_prompt |
| 526 | self.partial_cmd = str() |
| 527 | # The print statement makes the new prompt appear in a new line. |
| 528 | # Also print an extra newline to indicate that the current command has |
| 529 | # been cancelled. |
| 530 | print('\n') |
| 531 | return str() |
| 532 | args = self._check_for_command_completion(args) |
| 533 | args = self._remove_comments_before_set(args) |
| 534 | tokens = args.strip().split(' ') |
| 535 | args = ' '.join(tokens).strip() |
| 536 | return args.rstrip(ImpalaShell.CMD_DELIM) |
| 537 | |
| 538 | def _shlex_split(self, line): |
| 539 | """Reimplement shlex.split() so that escaped single quotes |
no test coverage detected