/usr/share/doc/python-cement-doc/html/api/utils/misc.html is in python-cement-doc 2.10.0-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 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 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>cement.utils.misc — Cement 2.10.0 documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="Cement 2.10.0 documentation" href="../../index.html"/>
<link rel="up" title="API Reference" href="../index.html"/>
<link rel="next" title="cement.utils.test" href="test.html"/>
<link rel="prev" title="cement.utils.shell" href="shell.html"/>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../../index.html" class="icon icon-home"> Cement
</a>
<div class="version">
2.10
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../changes.html">ChangeLog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contributors.html">Contributors</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../upgrading.html">Upgrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../whats_new.html">What’s New</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../projects_built_on_cement.html">Projects Built on Cement™</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../faq.html">Frequenty Asked Questions</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../index.html#cement-core-modules">Cement Core Modules</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../index.html#cement-utility-modules">Cement Utility Modules</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="fs.html"><code class="docutils literal"><span class="pre">cement.utils.fs</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="shell.html"><code class="docutils literal"><span class="pre">cement.utils.shell</span></code></a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"><code class="docutils literal"><span class="pre">cement.utils.misc</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="test.html"><code class="docutils literal"><span class="pre">cement.utils.test</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#cement-extension-modules">Cement Extension Modules</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Developer Documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../examples/index.html">Examples</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">Cement</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html">Docs</a> »</li>
<li><a href="../index.html">API Reference</a> »</li>
<li><code class="docutils literal"><span class="pre">cement.utils.misc</span></code></li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/api/utils/misc.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="cement-utils-misc">
<span id="id1"></span><h1><a class="reference internal" href="#module-cement.utils.misc" title="cement.utils.misc"><code class="xref py py-mod docutils literal"><span class="pre">cement.utils.misc</span></code></a><a class="headerlink" href="#cement-utils-misc" title="Permalink to this headline">¶</a></h1>
<span class="target" id="module-cement.utils.misc"></span><p>Misc utilities.</p>
<dl class="function">
<dt id="cement.utils.misc.init_defaults">
<code class="descclassname">cement.utils.misc.</code><code class="descname">init_defaults</code><span class="sig-paren">(</span><em>*sections</em><span class="sig-paren">)</span><a class="headerlink" href="#cement.utils.misc.init_defaults" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a standard dictionary object to use for application defaults.
If sections are given, it will create a nested dict for each section name.</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>sections</strong> – Section keys to create nested dictionaries for.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Dictionary of nested dictionaries (sections)</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dict</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">cement.core</span> <span class="kn">import</span> <span class="n">foundation</span>
<span class="kn">from</span> <span class="nn">cement.utils.misc</span> <span class="kn">import</span> <span class="n">init_defaults</span>
<span class="n">defaults</span> <span class="o">=</span> <span class="n">init_defaults</span><span class="p">(</span><span class="s1">'myapp'</span><span class="p">,</span> <span class="s1">'section2'</span><span class="p">,</span> <span class="s1">'section3'</span><span class="p">)</span>
<span class="n">defaults</span><span class="p">[</span><span class="s1">'myapp'</span><span class="p">][</span><span class="s1">'debug'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">defaults</span><span class="p">[</span><span class="s1">'section2'</span><span class="p">][</span><span class="s1">'foo'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'bar</span>
<span class="n">defaults</span><span class="p">[</span><span class="s1">'section3'</span><span class="p">][</span><span class="s1">'foo2'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'bar2'</span>
<span class="n">app</span> <span class="o">=</span> <span class="n">foundation</span><span class="o">.</span><span class="n">CementApp</span><span class="p">(</span><span class="s1">'myapp'</span><span class="p">,</span> <span class="n">config_defaults</span><span class="o">=</span><span class="n">defaults</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="cement.utils.misc.is_true">
<code class="descclassname">cement.utils.misc.</code><code class="descname">is_true</code><span class="sig-paren">(</span><em>item</em><span class="sig-paren">)</span><a class="headerlink" href="#cement.utils.misc.is_true" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a value, determine if it is one of [True, ‘True’, ‘true’, 1, ‘1’].</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>item</strong> – The item to convert to a boolean.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True if <cite>item</cite> is in <code class="docutils literal"><span class="pre">[True,</span> <span class="pre">'True',</span> <span class="pre">'true',</span> <span class="pre">1,</span> <span class="pre">'1']</span></code>, False
otherwise.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">boolean</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="cement.utils.misc.minimal_logger">
<code class="descclassname">cement.utils.misc.</code><code class="descname">minimal_logger</code><span class="sig-paren">(</span><em>namespace</em>, <em>debug=False</em><span class="sig-paren">)</span><a class="headerlink" href="#cement.utils.misc.minimal_logger" title="Permalink to this definition">¶</a></dt>
<dd><p>Setup just enough for cement to be able to do debug logging. This is the
logger used by the Cement framework, which is setup and accessed before
the application is functional (and more importantly before the
applications log handler is usable).</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>namespace</strong> – The logging namespace. This is generally ‘__name__’ or
anything you want.</li>
<li><strong>debug</strong> (<em>boolean</em>) – Toggle debug output. Default: False</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Logger object</p>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">cement.utils.misc</span> <span class="kn">import</span> <span class="n">minimal_logger</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">minimal_logger</span><span class="p">(</span><span class="s1">'cement'</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">'This is a debug message'</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="cement.utils.misc.rando">
<code class="descclassname">cement.utils.misc.</code><code class="descname">rando</code><span class="sig-paren">(</span><em>salt=None</em><span class="sig-paren">)</span><a class="headerlink" href="#cement.utils.misc.rando" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate a random MD5 hash for whatever purpose. Useful for testing
or any other time that something random is required.</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>salt</strong> – Optional ‘salt’, if None then random() is used.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Random MD5 hash (str).</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="cement.utils.misc.random">
<code class="descclassname">cement.utils.misc.</code><code class="descname">random</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → x in the interval [0, 1).<a class="headerlink" href="#cement.utils.misc.random" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="cement.utils.misc.wrap">
<code class="descclassname">cement.utils.misc.</code><code class="descname">wrap</code><span class="sig-paren">(</span><em>text</em>, <em>width=77</em>, <em>indent=''</em>, <em>long_words=False</em>, <em>hyphens=False</em><span class="sig-paren">)</span><a class="headerlink" href="#cement.utils.misc.wrap" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrap text for cleaner output (this is a simple wrapper around
<cite>textwrap.TextWrapper</cite> in the standard library).</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>text</strong> – The text to wrap</li>
<li><strong>width</strong> – The max width of a line before breaking</li>
<li><strong>indent</strong> – String to prefix subsequent lines after breaking</li>
<li><strong>long_words</strong> – Break on long words</li>
<li><strong>hyphens</strong> – Break on hyphens</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">str(text)</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="test.html" class="btn btn-neutral float-right" title="cement.utils.test" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="shell.html" class="btn btn-neutral" title="cement.utils.shell" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2009-2016, Data Folk Labs, LLC.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'2.10.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>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|