This file is indexed.

/usr/share/doc/phatch/html/lib.safe.html is in phatch-doc 0.2.7.1-3.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!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>safe &mdash; Phatch 0.2 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '0.2',
        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="top" title="Phatch 0.2 documentation" href="index.html" />
    <link rel="up" title="lib" href="lib.html" />
    <link rel="next" title="system" href="lib.system.html" />
    <link rel="prev" title="reverse_translation" href="lib.reverse_translation.html" /> 
  </head>
  <body>
    <div class="related">
      <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="lib.system.html" title="system"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="lib.reverse_translation.html" title="reverse_translation"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Phatch 0.2 documentation</a> &raquo;</li>
          <li><a href="lib.html" accesskey="U">lib</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-lib.safe">
<span id="safe"></span><h1>safe<a class="headerlink" href="#module-lib.safe" title="Permalink to this headline"></a></h1>
<dl class="exception">
<dt id="lib.safe.UnsafeError">
<em class="property">exception </em><tt class="descclassname">lib.safe.</tt><tt class="descname">UnsafeError</tt><a class="headerlink" href="#lib.safe.UnsafeError" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">exceptions.Exception</span></tt></p>
</dd></dl>

<dl class="function">
<dt id="lib.safe.assert_safe">
<tt class="descclassname">lib.safe.</tt><tt class="descname">assert_safe</tt><big>(</big><em>expr</em>, <em>_globals=None</em>, <em>_locals=None</em>, <em>validate=None</em><big>)</big><a class="headerlink" href="#lib.safe.assert_safe" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="lib.safe.assert_safe_expr">
<tt class="descclassname">lib.safe.</tt><tt class="descname">assert_safe_expr</tt><big>(</big><em>meta_expr</em>, <em>_globals=None</em>, <em>_locals=None</em>, <em>validate=None</em>, <em>preprocess=&lt;function &lt;lambda&gt; at 0x7f53de4706e0&gt;</em><big>)</big><a class="headerlink" href="#lib.safe.assert_safe_expr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="lib.safe.compile_expr">
<tt class="descclassname">lib.safe.</tt><tt class="descname">compile_expr</tt><big>(</big><em>meta_expr</em>, <em>_globals=None</em>, <em>_locals=None</em>, <em>validate=None</em>, <em>preprocess=&lt;function &lt;lambda&gt; at 0x7f53de4705f0&gt;</em>, <em>safe=True</em><big>)</big><a class="headerlink" href="#lib.safe.compile_expr" title="Permalink to this definition"></a></dt>
<dd><p>If safe is a list, a restricted evaluation will be executed.
Otherwise if safe is None, a unrestriced eval will be executed.</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>meta_expr</strong> (<em>string</em>) &#8211; meta-expression with &lt;subexpressions&gt;</li>
<li><strong>_globals</strong> (<em>dict</em>) &#8211; globals</li>
<li><strong>_locals</strong> (<em>dict</em>) &#8211; locals</li>
<li><strong>safe</strong> (<em>list or None</em>) &#8211; safe names which will be accepted by the compiler</li>
<li><strong>preprocess</strong> (<em>callable</em>) &#8211; preprocess expression (e.g. for ## formatting)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">compile_expr</span><span class="p">(</span><span class="s">&#39;&lt;1+1&gt;_&lt;abs(2-3)&gt;&#39;</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="go">u&#39;2_1&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">compile_expr</span><span class="p">(</span><span class="s">&#39;&lt;###(index+1)&gt;&#39;</span><span class="p">,</span> <span class="n">_locals</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;index&#39;</span><span class="p">:</span><span class="mi">1</span><span class="p">},</span>
<span class="gp">... </span>    <span class="n">preprocess</span><span class="o">=</span><span class="n">format_expr</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="go">u&#39;002&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="lib.safe.eval_restricted">
<tt class="descclassname">lib.safe.</tt><tt class="descname">eval_restricted</tt><big>(</big><em>s, _globals=None, _locals=None, allowed=['abs', 'int', 'min', 'max', 'pow', 'sum', 'True', 'False', 'denominator', 'numerator', 'chr', 'lower', 'str', 'title', 'upper', 'day', 'hour', 'microsecond', 'minute', 'month', 'monthname', 'second', 'weekday', 'weekdayname', 'year']</em><big>)</big><a class="headerlink" href="#lib.safe.eval_restricted" title="Permalink to this definition"></a></dt>
<dd><p>Evaluate an expression while allowing a restricted set of names.</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"><strong>allowed</strong> (<em>list of string</em>) &#8211; allowed names</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">result</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">eval_restricted</span><span class="p">(</span><span class="s">&#39;max(a, a+b)&#39;</span><span class="p">,</span> <span class="n">_globals</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span> <span class="s">&#39;b&#39;</span><span class="p">:</span><span class="mi">2</span><span class="p">},</span>
<span class="gp">... </span><span class="n">_locals</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span><span class="mi">1</span><span class="p">},</span> <span class="n">allowed</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;max&#39;</span><span class="p">])</span>
<span class="go">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">try</span><span class="p">:</span>
<span class="gp">... </span>    <span class="n">eval_restricted</span><span class="p">(</span><span class="s">&#39;a+b+c&#39;</span><span class="p">,</span> <span class="n">_globals</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span> <span class="s">&#39;b&#39;</span><span class="p">:</span><span class="mi">2</span><span class="p">},</span> <span class="n">_locals</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span><span class="mi">1</span><span class="p">})</span>
<span class="gp">... </span><span class="k">except</span> <span class="n">UnsafeError</span><span class="p">,</span> <span class="n">error</span><span class="p">:</span>
<span class="gp">... </span>    <span class="k">print</span><span class="p">(</span><span class="n">error</span><span class="p">)</span>
<span class="go">The following name(s) are invalid: c</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="lib.safe.eval_safe">
<tt class="descclassname">lib.safe.</tt><tt class="descname">eval_safe</tt><big>(</big><em>expr</em>, <em>_globals=None</em>, <em>_locals=None</em>, <em>validate=None</em><big>)</big><a class="headerlink" href="#lib.safe.eval_safe" title="Permalink to this definition"></a></dt>
<dd><p>Safely evaluate an expression. It will raise a <tt class="docutils literal"><span class="pre">ValueError</span></tt> if
non validated names are used.</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"><strong>expr</strong> (<em>string</em>) &#8211; expression</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">result</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">eval_safe</span><span class="p">(</span><span class="s">&#39;1+1&#39;</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">try</span><span class="p">:</span>
<span class="gp">... </span>    <span class="n">eval_safe</span><span class="p">(</span><span class="s">&#39;&quot;lowercase&quot;.upper()&#39;</span><span class="p">)</span>
<span class="gp">... </span><span class="k">except</span> <span class="n">UnsafeError</span><span class="p">,</span> <span class="n">error</span><span class="p">:</span>
<span class="gp">... </span>    <span class="k">print</span><span class="p">(</span><span class="n">error</span><span class="p">)</span>
<span class="go">The following name(s) are invalid: upper</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="lib.safe.extend_vars">
<tt class="descclassname">lib.safe.</tt><tt class="descname">extend_vars</tt><big>(</big><em>vars</em>, <em>s</em><big>)</big><a class="headerlink" href="#lib.safe.extend_vars" title="Permalink to this definition"></a></dt>
<dd><p>Extend <tt class="docutils literal"><span class="pre">vars</span></tt> with new unique variables from <tt class="docutils literal"><span class="pre">s</span></tt>.</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>vars</strong> (<em>list of string</em>) &#8211; collection of previous variables</li>
<li><strong>s</strong> (<em>string</em>) &#8211; multiple expressions</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="nb">vars</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;a1&#39;</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">extend_vars</span><span class="p">(</span><span class="nb">vars</span><span class="p">,</span> <span class="s">&#39;&lt;a1&gt;_&lt;foo&gt;_&lt;world&gt;_&lt;###index&gt;&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">vars</span>
<span class="go">[&#39;a1&#39;, &#39;foo&#39;, &#39;world&#39;, &#39;index&#39;]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="lib.safe.format_expr">
<tt class="descclassname">lib.safe.</tt><tt class="descname">format_expr</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#lib.safe.format_expr" title="Permalink to this definition"></a></dt>
<dd><p>Returns an expression with <tt class="docutils literal"><span class="pre">####</span></tt> in a pure python expression
which can be evaluated.</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"><strong>s</strong> (<em>expression</em>) &#8211; expression</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">format_expr</span><span class="p">(</span><span class="s">&#39;###(5+1)&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span>
<span class="go">&#39;&quot;%03d&quot;%(5+1)&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">eval</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">&#39;006&#39;</span>
</pre></div>
</div>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="lib.reverse_translation.html"
                        title="previous chapter">reverse_translation</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="lib.system.html"
                        title="next chapter">system</a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <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="lib.system.html" title="system"
             >next</a> |</li>
        <li class="right" >
          <a href="lib.reverse_translation.html" title="reverse_translation"
             >previous</a> |</li>
        <li><a href="index.html">Phatch 0.2 documentation</a> &raquo;</li>
          <li><a href="lib.html" >lib</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009, www.stani.be.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
    </div>
  </body>
</html>