/usr/share/doc/python-argvalidate/html/argvalidate.html is in python-argvalidate 0.9.0-2.
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 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | <!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>argvalidate Module — argvalidate - Python argument validator library 0.9.0 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.9.0',
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="argvalidate - Python argument validator library 0.9.0 documentation" href="index.html" />
<link rel="next" title="argvalidate environment variables" href="envvars.html" />
<link rel="prev" title="argvalidate - Python argument validator library documentation" href="index.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="envvars.html" title="argvalidate environment variables"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="argvalidate - Python argument validator library documentation"
accesskey="P">previous</a> |</li>
<li><a href="index.html">argvalidate - Python argument validator library 0.9.0 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-argvalidate">
<span id="id1"></span><span id="argvalidate-module"></span><h1>argvalidate Module<a class="headerlink" href="#module-argvalidate" title="Permalink to this headline">¶</a></h1>
<p>Below you can find the documentation of the public API of argvalidate.</p>
<p>Even though more constants, decorators, exceptions and functions may be
specified in the argvalidate module, only those described here form the API
and are intended for public use.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>Do <em>not</em> rely on any internals of argvalidate, as these may change at any
time, without further notice.</p>
<p class="last">The API described here forms the public interface to argvalidate and as such
will have functionality pending for removal deprecated first.</p>
</div>
<div class="section" id="decorators">
<h2>Decorators<a class="headerlink" href="#decorators" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="argvalidate.accepts">
<tt class="descclassname">argvalidate.</tt><tt class="descname">accepts</tt><big>(</big><em>*type_args</em>, <em>**type_kwargs</em><big>)</big><a class="headerlink" href="#argvalidate.accepts" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator used for checking arguments passed to a function or method.</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 simple">
<li><strong>start</strong> – method/function-detection override. The number of arguments
defined with start are ignored in all checks.</li>
<li><strong>type_args</strong> – type definitions of non-keyword arguments.</li>
<li><strong>type_kwargs</strong> – type definitions of keyword arguments.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
<li><strong>DecoratorNonKeyLengthException</strong> – Raised if the number of non-keyword
arguments specified in the decorator does not match the number of
non-keyword arguments the function accepts.</li>
<li><strong>DecoratorKeyLengthException</strong> – Raised if the number of keyword
arguments specified in the decorator does not match the number of
non-keyword arguments the function accepts.</li>
<li><strong>DecoratorKeyUnspecifiedException</strong> – Raised if a keyword argument’s
type has not been specified in the decorator.</li>
<li><strong>ArgumentTypeException</strong> – Raised if an argument type passed to the
function does not match the type specified in the decorator.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre>class MyClass:
@accepts(int, str)
def my_method(self, x_is_int, y_is_str):
[...]
@accepts(int, str)
def my_function(x_is_int, y_is_str):
[....]
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="argvalidate.returns">
<tt class="descclassname">argvalidate.</tt><tt class="descname">returns</tt><big>(</big><em>expected_type</em><big>)</big><a class="headerlink" href="#argvalidate.returns" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator used for checking the return value of a function or method.</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>expected_type</strong> – expected type or return value</td>
</tr>
<tr class="field-even field"><th class="field-name" colspan="2">Raises ReturnValueTypeException:</th></tr>
<tr class="field-even field"><td> </td><td class="field-body">Raised if the return value’s type does not
match the definition in the decorator’s <cite>expected_type</cite> parameter.</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="nd">@return_value</span><span class="p">(</span><span class="nb">int</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">my_func</span><span class="p">():</span>
<span class="k">return</span> <span class="mi">5</span>
</pre></div>
</div>
</dd></dl>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>Stacking of decorator of the same type (ie. <a class="reference internal" href="#argvalidate.accepts" title="argvalidate.accepts"><tt class="xref py py-func docutils literal"><span class="pre">accepts()</span></tt></a>
and <a class="reference internal" href="#argvalidate.accepts" title="argvalidate.accepts"><tt class="xref py py-func docutils literal"><span class="pre">accepts()</span></tt></a>, <a class="reference internal" href="#argvalidate.returns" title="argvalidate.returns"><tt class="xref py py-func docutils literal"><span class="pre">returns()</span></tt></a> and <a class="reference internal" href="#argvalidate.returns" title="argvalidate.returns"><tt class="xref py py-func docutils literal"><span class="pre">returns()</span></tt></a>) is not possible
and will cause a <a class="reference internal" href="#argvalidate.DecoratorStackingException" title="argvalidate.DecoratorStackingException"><tt class="xref py py-exc docutils literal"><span class="pre">DecoratorStackingException</span></tt></a> to be raised.</p>
<p class="last">Stacking of different types of decorators (ie. <a class="reference internal" href="#argvalidate.returns" title="argvalidate.returns"><tt class="xref py py-func docutils literal"><span class="pre">returns()</span></tt></a> and
<a class="reference internal" href="#argvalidate.accepts" title="argvalidate.accepts"><tt class="xref py py-func docutils literal"><span class="pre">accepts()</span></tt></a>)
is possible though and will neither raise an exception nor break anything.</p>
</div>
<dl class="function">
<dt id="argvalidate.func_args">
<tt class="descclassname">argvalidate.</tt><tt class="descname">func_args</tt><big>(</big><em>*type_args</em>, <em>**type_kwargs</em><big>)</big><a class="headerlink" href="#argvalidate.func_args" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper for backwards-compatibility.</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">Deprecated:</th><td class="field-body">This decorator has been replaced with <a class="reference internal" href="#argvalidate.accepts" title="argvalidate.accepts"><tt class="xref py py-func docutils literal"><span class="pre">accepts()</span></tt></a>.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="argvalidate.method_args">
<tt class="descclassname">argvalidate.</tt><tt class="descname">method_args</tt><big>(</big><em>*type_args</em>, <em>**type_kwargs</em><big>)</big><a class="headerlink" href="#argvalidate.method_args" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper for backwards-compatibility.</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">Deprecated:</th><td class="field-body">This decorator has been replaced with <a class="reference internal" href="#argvalidate.accepts" title="argvalidate.accepts"><tt class="xref py py-func docutils literal"><span class="pre">accepts()</span></tt></a>.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="argvalidate.return_value">
<tt class="descclassname">argvalidate.</tt><tt class="descname">return_value</tt><big>(</big><em>expected_type</em><big>)</big><a class="headerlink" href="#argvalidate.return_value" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper for backwards-compatibility.</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">Deprecated:</th><td class="field-body">This decorator has been replaced with <a class="reference internal" href="#argvalidate.returns" title="argvalidate.returns"><tt class="xref py py-func docutils literal"><span class="pre">returns()</span></tt></a>.</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="helpers">
<h2>Helpers<a class="headerlink" href="#helpers" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="argvalidate.one_of">
<tt class="descclassname">argvalidate.</tt><tt class="descname">one_of</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#argvalidate.one_of" title="Permalink to this definition">¶</a></dt>
<dd><p>Simple helper function to create a tuple from every argument passed to it.</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>args</strong> – type definitions</td>
</tr>
</tbody>
</table>
<p>A tuple can be used instead of calling this function, however, the tuple
returned by this function contains a customized __repr__ method, which
makes Exceptions easier to read.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="nd">@func_check_args</span><span class="p">(</span><span class="n">one_of</span><span class="p">(</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="nb">float</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">my_func</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="k">pass</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="argvalidate.raises_exceptions">
<tt class="descclassname">argvalidate.</tt><tt class="descname">raises_exceptions</tt><big>(</big><big>)</big><a class="headerlink" href="#argvalidate.raises_exceptions" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if argvalidate raises exceptions, False if argvalidate
creates warnings instead.</p>
<p>This behaviour can be controlled via the environment variable
<span class="target" id="index-0"></span><a class="reference internal" href="envvars.html#envvar-ARGVALIDATE_WARN"><tt class="xref std std-envvar docutils literal"><span class="pre">ARGVALIDATE_WARN</span></tt></a>.</p>
</dd></dl>
<dl class="function">
<dt id="argvalidate.warns_kwarg_as_arg">
<tt class="descclassname">argvalidate.</tt><tt class="descname">warns_kwarg_as_arg</tt><big>(</big><big>)</big><a class="headerlink" href="#argvalidate.warns_kwarg_as_arg" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if argvalidate generates warnings for keyword arguments
passed as arguments.</p>
<p>This behaviour can be controlled via the environment variable
<span class="target" id="index-1"></span><a class="reference internal" href="envvars.html#envvar-ARGVALIDATE_WARN_KWARG_AS_ARG"><tt class="xref std std-envvar docutils literal"><span class="pre">ARGVALIDATE_WARN_KWARG_AS_ARG</span></tt></a>.</p>
</dd></dl>
</div>
<div class="section" id="exceptions">
<span id="argvalidate-exceptions"></span><h2>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h2>
<dl class="exception">
<dt id="argvalidate.ArgvalidateException">
<em class="property">exception </em><tt class="descclassname">argvalidate.</tt><tt class="descname">ArgvalidateException</tt><a class="headerlink" href="#argvalidate.ArgvalidateException" title="Permalink to this definition">¶</a></dt>
<dd><p>Base argvalidate exception.</p>
<p>Used as base for all exceptions.</p>
</dd></dl>
<dl class="exception">
<dt id="argvalidate.ArgumentTypeException">
<em class="property">exception </em><tt class="descclassname">argvalidate.</tt><tt class="descname">ArgumentTypeException</tt><big>(</big><em>func_name</em>, <em>arg_name</em>, <em>expected_type</em>, <em>passed_type</em><big>)</big><a class="headerlink" href="#argvalidate.ArgumentTypeException" title="Permalink to this definition">¶</a></dt>
<dd><p>Exception for invalid argument type.</p>
<p>This exception provides the following attributes:</p>
<ul>
<li><dl class="first docutils">
<dt>func_name</dt>
<dd><p class="first last">Name of function that caused the exception to be raised
(str, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>arg_name</dt>
<dd><p class="first last">Name of the keyword argument passed to the function, but not specified
in the decorator (str, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>expected_type</dt>
<dd><p class="first last">Argument type that was expected (type, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>passed_type</dt>
<dd><p class="first last">Argument type that was passed to the function (type, read-only).</p>
</dd>
</dl>
</li>
</ul>
</dd></dl>
<dl class="exception">
<dt id="argvalidate.ReturnValueTypeException">
<em class="property">exception </em><tt class="descclassname">argvalidate.</tt><tt class="descname">ReturnValueTypeException</tt><big>(</big><em>func_name</em>, <em>expected_type</em>, <em>passed_type</em><big>)</big><a class="headerlink" href="#argvalidate.ReturnValueTypeException" title="Permalink to this definition">¶</a></dt>
<dd><p>Exception for invalid return value type.</p>
<p>This exception provides the following attributes:</p>
<ul>
<li><dl class="first docutils">
<dt>func_name</dt>
<dd><p class="first last">Name of function that caused the exception to be raised
(string, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>expected_type</dt>
<dd><p class="first last">Argument type that was expected (type, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>passed_type</dt>
<dd><p class="first last">Type of value returned by the function (type, read-only).</p>
</dd>
</dl>
</li>
</ul>
</dd></dl>
<dl class="exception">
<dt id="argvalidate.DecoratorNonKeyLengthException">
<em class="property">exception </em><tt class="descclassname">argvalidate.</tt><tt class="descname">DecoratorNonKeyLengthException</tt><big>(</big><em>func_name</em>, <em>expected_count</em>, <em>passed_count</em><big>)</big><a class="headerlink" href="#argvalidate.DecoratorNonKeyLengthException" title="Permalink to this definition">¶</a></dt>
<dd><p>Exception for invalid decorator non-keyword argument count.</p>
<p>This exception provides the following attributes:</p>
<ul>
<li><dl class="first docutils">
<dt>func_name</dt>
<dd><p class="first last">Name of function that caused the exception to be raised
(str, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>expected_count</dt>
<dd><p class="first last">Number of arguments that were expected (int, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>passed_count</dt>
<dd><p class="first last">Number of arguments that were passed to the function (int, read-only).</p>
</dd>
</dl>
</li>
</ul>
</dd></dl>
<dl class="exception">
<dt id="argvalidate.DecoratorKeyUnspecifiedException">
<em class="property">exception </em><tt class="descclassname">argvalidate.</tt><tt class="descname">DecoratorKeyUnspecifiedException</tt><big>(</big><em>func_name</em>, <em>arg_name</em><big>)</big><a class="headerlink" href="#argvalidate.DecoratorKeyUnspecifiedException" title="Permalink to this definition">¶</a></dt>
<dd><p>Exception for unspecified decorator keyword argument.</p>
<p>This exception provides the following attributes:</p>
<ul>
<li><dl class="first docutils">
<dt>func_name</dt>
<dd><p class="first last">Name of function that caused the exception to be raised
(str, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>arg_name</dt>
<dd><p class="first last">Name of the keyword argument passed to the function, but not specified
in the decorator (str, read-only).</p>
</dd>
</dl>
</li>
</ul>
</dd></dl>
<dl class="exception">
<dt id="argvalidate.DecoratorStackingException">
<em class="property">exception </em><tt class="descclassname">argvalidate.</tt><tt class="descname">DecoratorStackingException</tt><big>(</big><em>func_name</em>, <em>decorator_name</em><big>)</big><a class="headerlink" href="#argvalidate.DecoratorStackingException" title="Permalink to this definition">¶</a></dt>
<dd><p>Exception for stacking a decorator with itself.</p>
<p>This exception provides the following attributes:</p>
<ul>
<li><dl class="first docutils">
<dt>func_name</dt>
<dd><p class="first last">Name of function that caused the exception to be raised
(str, read-only).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>decorator_name</dt>
<dd><p class="first last">Name of the decorator that was stacked with itself (str, read-only).</p>
</dd>
</dl>
</li>
</ul>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">argvalidate Module</a><ul>
<li><a class="reference internal" href="#decorators">Decorators</a></li>
<li><a class="reference internal" href="#helpers">Helpers</a></li>
<li><a class="reference internal" href="#exceptions">Exceptions</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">argvalidate - Python argument validator library documentation</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="envvars.html"
title="next chapter">argvalidate environment variables</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/argvalidate.txt"
rel="nofollow">Show Source</a></li>
</ul>
<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="envvars.html" title="argvalidate environment variables"
>next</a> |</li>
<li class="right" >
<a href="index.html" title="argvalidate - Python argument validator library documentation"
>previous</a> |</li>
<li><a href="index.html">argvalidate - Python argument validator library 0.9.0 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2009, Stephan Peijnik.
Last updated on Oct 24, 2014.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>
|