/usr/share/doc/python-pexpect-doc/html/api/replwrap.html is in python-pexpect-doc 4.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>replwrap - Control read-eval-print-loops — Pexpect 4.2.1 documentation</title>
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '4.2.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="top" title="Pexpect 4.2.1 documentation" href="../index.html" />
<link rel="up" title="API documentation" href="index.html" />
<link rel="next" title="pxssh - control an SSH session" href="pxssh.html" />
<link rel="prev" title="popen_spawn - use pexpect with a piped subprocess" href="popen_spawn.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="pxssh.html" title="pxssh - control an SSH session"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="popen_spawn.html" title="popen_spawn - use pexpect with a piped subprocess"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Pexpect 4.2.1 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">API documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-pexpect.replwrap">
<span id="replwrap-control-read-eval-print-loops"></span><h1>replwrap - Control read-eval-print-loops<a class="headerlink" href="#module-pexpect.replwrap" title="Permalink to this headline">¶</a></h1>
<p>Generic wrapper for read-eval-print-loops, a.k.a. interactive shells</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="class">
<dt id="pexpect.replwrap.REPLWrapper">
<em class="property">class </em><code class="descclassname">pexpect.replwrap.</code><code class="descname">REPLWrapper</code><span class="sig-paren">(</span><em>cmd_or_spawn</em>, <em>orig_prompt</em>, <em>prompt_change</em>, <em>new_prompt=u'[PEXPECT_PROMPT>'</em>, <em>continuation_prompt=u'[PEXPECT_PROMPT+'</em>, <em>extra_init_cmd=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pexpect/replwrap.html#REPLWrapper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pexpect.replwrap.REPLWrapper" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper for a REPL.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>cmd_or_spawn</strong> – This can either be an instance of <a class="reference internal" href="pexpect.html#pexpect.spawn" title="pexpect.spawn"><code class="xref py py-class docutils literal"><span class="pre">pexpect.spawn</span></code></a>
in which a REPL has already been started, or a str command to start a new
REPL process.</li>
<li><strong>orig_prompt</strong> (<em>str</em>) – The prompt to expect at first.</li>
<li><strong>prompt_change</strong> (<em>str</em>) – A command to change the prompt to something more
unique. If this is <code class="docutils literal"><span class="pre">None</span></code>, the prompt will not be changed. This will
be formatted with the new and continuation prompts as positional
parameters, so you can use <code class="docutils literal"><span class="pre">{}</span></code> style formatting to insert them into
the command.</li>
<li><strong>new_prompt</strong> (<em>str</em>) – The more unique prompt to expect after the change.</li>
<li><strong>extra_init_cmd</strong> (<em>str</em>) – Commands to do extra initialisation, such as
disabling pagers.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pexpect.replwrap.REPLWrapper.run_command">
<code class="descname">run_command</code><span class="sig-paren">(</span><em>command</em>, <em>timeout=-1</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pexpect/replwrap.html#REPLWrapper.run_command"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pexpect.replwrap.REPLWrapper.run_command" title="Permalink to this definition">¶</a></dt>
<dd><p>Send a command to the REPL, wait for and return output.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>command</strong> (<em>str</em>) – The command to send. Trailing newlines are not needed.
This should be a complete block of input that will trigger execution;
if a continuation prompt is found after sending input, <code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code>
will be raised.</li>
<li><strong>timeout</strong> (<em>int</em>) – How long to wait for the next prompt. -1 means the
default from the <a class="reference internal" href="pexpect.html#pexpect.spawn" title="pexpect.spawn"><code class="xref py py-class docutils literal"><span class="pre">pexpect.spawn</span></code></a> object (default 30 seconds).
None means to wait indefinitely.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="data">
<dt id="pexpect.replwrap.PEXPECT_PROMPT">
<code class="descclassname">pexpect.replwrap.</code><code class="descname">PEXPECT_PROMPT</code><a class="headerlink" href="#pexpect.replwrap.PEXPECT_PROMPT" title="Permalink to this definition">¶</a></dt>
<dd><p>A string that can be used as a prompt, and is unlikely to be found in output.</p>
</dd></dl>
<p>Using the objects above, it is easy to wrap a REPL. For instance, to use a
Python shell:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">py</span> <span class="o">=</span> <span class="n">REPLWrapper</span><span class="p">(</span><span class="s2">"python"</span><span class="p">,</span> <span class="s2">">>> "</span><span class="p">,</span> <span class="s2">"import sys; sys.ps1=</span><span class="si">{!r}</span><span class="s2">; sys.ps2=</span><span class="si">{!r}</span><span class="s2">"</span><span class="p">)</span>
<span class="n">py</span><span class="o">.</span><span class="n">run_command</span><span class="p">(</span><span class="s2">"4+7"</span><span class="p">)</span>
</pre></div>
</div>
<p>Convenience functions are provided for Python and bash shells:</p>
<dl class="function">
<dt id="pexpect.replwrap.python">
<code class="descclassname">pexpect.replwrap.</code><code class="descname">python</code><span class="sig-paren">(</span><em>command='python'</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pexpect/replwrap.html#python"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pexpect.replwrap.python" title="Permalink to this definition">¶</a></dt>
<dd><p>Start a Python shell and return a <a class="reference internal" href="#pexpect.replwrap.REPLWrapper" title="pexpect.replwrap.REPLWrapper"><code class="xref py py-class docutils literal"><span class="pre">REPLWrapper</span></code></a> object.</p>
</dd></dl>
<dl class="function">
<dt id="pexpect.replwrap.bash">
<code class="descclassname">pexpect.replwrap.</code><code class="descname">bash</code><span class="sig-paren">(</span><em>command='bash'</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/pexpect/replwrap.html#bash"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pexpect.replwrap.bash" title="Permalink to this definition">¶</a></dt>
<dd><p>Start a bash shell and return a <a class="reference internal" href="#pexpect.replwrap.REPLWrapper" title="pexpect.replwrap.REPLWrapper"><code class="xref py py-class docutils literal"><span class="pre">REPLWrapper</span></code></a> object.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="popen_spawn.html"
title="previous chapter">popen_spawn - use pexpect with a piped subprocess</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="pxssh.html"
title="next chapter">pxssh - control an SSH session</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/api/replwrap.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="pxssh.html" title="pxssh - control an SSH session"
>next</a> |</li>
<li class="right" >
<a href="popen_spawn.html" title="popen_spawn - use pexpect with a piped subprocess"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Pexpect 4.2.1 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" >API documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2016, Noah Spurrier and contributors.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9.
</div>
</body>
</html>
|