MCPcopy Create free account
hub / github.com/pexpect/pexpect / __init__

Method __init__

pexpect/replwrap.py:33–58  ·  view source on GitHub ↗
(self, cmd_or_spawn, orig_prompt, prompt_change,
                 new_prompt=PEXPECT_PROMPT,
                 continuation_prompt=PEXPECT_CONTINUATION_PROMPT,
                 extra_init_cmd=None)

Source from the content-addressed store, hash-verified

31 disabling pagers.
32 """
33 def __init__(self, cmd_or_spawn, orig_prompt, prompt_change,
34 new_prompt=PEXPECT_PROMPT,
35 continuation_prompt=PEXPECT_CONTINUATION_PROMPT,
36 extra_init_cmd=None):
37 if isinstance(cmd_or_spawn, basestring):
38 self.child = pexpect.spawn(cmd_or_spawn, echo=False, encoding='utf-8')
39 else:
40 self.child = cmd_or_spawn
41 if self.child.echo:
42 # Existing spawn instance has echo enabled, disable it
43 # to prevent our input from being repeated to output.
44 self.child.setecho(False)
45 self.child.waitnoecho()
46
47 if prompt_change is None:
48 self.prompt = orig_prompt
49 else:
50 self.set_prompt(orig_prompt,
51 prompt_change.format(new_prompt, continuation_prompt))
52 self.prompt = new_prompt
53 self.continuation_prompt = continuation_prompt
54
55 self._expect_prompt()
56
57 if extra_init_cmd is not None:
58 self.run_command(extra_init_cmd)
59
60 def set_prompt(self, orig_prompt, prompt_change):
61 self.child.expect(orig_prompt)

Callers

nothing calls this directly

Calls 6

set_promptMethod · 0.95
_expect_promptMethod · 0.95
run_commandMethod · 0.95
setechoMethod · 0.80
waitnoechoMethod · 0.80
spawnMethod · 0.45

Tested by

no test coverage detected