diff options
| author | Thomas Kluyver <takowl@gmail.com> | 2014-05-18 15:25:22 -0700 |
|---|---|---|
| committer | Thomas Kluyver <takowl@gmail.com> | 2014-05-18 15:25:22 -0700 |
| commit | e1672a21e1da319bbf7c7fbdc5e9e515a8196f14 (patch) | |
| tree | 448ee0055f4c203a25f6e6e50603fa18b41cad2b /pexpect/replwrap.py | |
| parent | c0a7554c7c8160d6a7b4023441c3cbe5e2f46ee5 (diff) | |
| download | pexpect-e1672a21e1da319bbf7c7fbdc5e9e515a8196f14.tar.gz | |
Format the new prompts into the prompt change command, simplifying instantiation of a REPLWrapper
Diffstat (limited to 'pexpect/replwrap.py')
| -rw-r--r-- | pexpect/replwrap.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pexpect/replwrap.py b/pexpect/replwrap.py index 288d269..4f74aca 100644 --- a/pexpect/replwrap.py +++ b/pexpect/replwrap.py @@ -38,13 +38,14 @@ class REPLWrapper(object): if prompt_change is None: self.prompt = orig_prompt else: - self.set_prompt(orig_prompt, prompt_change, new_prompt) + self.set_prompt(orig_prompt, + prompt_change.format(new_prompt, continuation_prompt)) self.prompt = new_prompt self.continuation_prompt = continuation_prompt self._expect_prompt() - def set_prompt(self, orig_prompt, prompt_change, new_prompt=PEXPECT_PROMPT): + def set_prompt(self, orig_prompt, prompt_change): self.child.expect_exact(orig_prompt) self.child.sendline(prompt_change) @@ -84,10 +85,8 @@ class REPLWrapper(object): def python(command="python"): """Start a Python shell and return a :class:`REPLWrapper` object.""" - return REPLWrapper(command, u(">>> "), u("import sys; sys.ps1=%r; sys.ps2=%r") % - (PEXPECT_PROMPT, PEXPECT_CONTINUATION_PROMPT)) + return REPLWrapper(command, u(">>> "), u("import sys; sys.ps1={!r}; sys.ps2={!r}")) def bash(command="bash", orig_prompt=u("$")): """Start a bash shell and return a :class:`REPLWrapper` object.""" - return REPLWrapper(command, orig_prompt, u("PS1=%r; PS2=%r") % - (PEXPECT_PROMPT, PEXPECT_CONTINUATION_PROMPT)) + return REPLWrapper(command, orig_prompt, u("PS1={!r}; PS2={!r}")) |
