Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > e4be28b383be195ff28bfce2053e734a > files > 260

python-stem-doc-1.1.0-1.fc18.noarch.rpm



<!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>Enumerations &mdash; Stem 1.1.0 documentation</title>
    
    <link rel="stylesheet" href="../../_static/haiku.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/print.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.1.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/theme_extras.js"></script>
    <link rel="shortcut icon" href="../../_static/favicon.png"/>
    <link rel="top" title="Stem 1.1.0 documentation" href="../../index.html" />
    <link rel="up" title="Contents" href="../../contents.html" />
    <link rel="next" title="Logging" href="log.html" />
    <link rel="prev" title="Connection Utilities" href="connection.html" /> 
  </head>
  <body>
      <div class="header"><img class="rightlogo" src="../../_static/logo.png" alt="Logo"/><h1 class="heading"><a href="../../index.html">
          <span>Stem Docs</span></a></h1>
        <h2 class="heading"><span>Enumerations</span></h2>
      </div>
      <div class="topnav">
      
        <p>

        <ul id="navbar">
          <li><a href="../../index.html">Home</a></li>
          <li><a href="../../tutorials.html">Tutorials</a>
            <ul>
              <li><a href="../../tutorials/the_little_relay_that_could.html">Hello World</a></li>
              <li><a href="../../tutorials/to_russia_with_love.html">Client Usage</a></li>
              <li><a href="../../tutorials/tortoise_and_the_hare.html">Event Listening</a></li>
              <li><a href="../../tutorials/mirror_mirror_on_the_wall.html">Tor Descriptors</a></li>
              <li><a href="../../tutorials/east_of_the_sun.html">Utilities</a></li>
              <li><a href="../../tutorials/double_double_toil_and_trouble.html">Examples</a></li>
            </ul>
          </li>
          <li><a href="../../api.html">API</a>
            <ul>
              <li><a href="../control.html">stem.control</a></li>
              <li><a href="../connection.html">stem.connection</a></li>
              <li><a href="../socket.html">stem.socket</a></li>
              <li><a href="../process.html">stem.process</a></li>
              <li><a href="../response.html">stem.response</a></li>
              <li><a href="../exit_policy.html">stem.exit_policy</a></li>
              <li><a href="../version.html">stem.version</a></li>
              <li><a href="../../api.html#descriptors">Descriptors</a></li>
              <li><a href="../../api.html#utilities">Utilities</a></li>
            </ul>
          </li>
          <li><a href="https://trac.torproject.org/projects/tor/wiki/doc/stem">Development</a>
            <ul>
              <li><a href="../../faq.html">FAQ</a></li>
              <li><a href="../../change_log.html">Change Log</a></li>
              <li><a href="https://trac.torproject.org/projects/tor/wiki/doc/stem/bugs">Bug Tracker</a></li>
              <li><a href="../../download.html">Download</a></li>
            </ul>
          </li>
        </ul>
        </p>

      </div>
      <div class="content">
        
        
  <div class="section" id="module-stem.util.enum">
<span id="enumerations"></span><h1>Enumerations<a class="headerlink" href="#module-stem.util.enum" title="Permalink to this headline">¶</a></h1>
<p>Basic enumeration, providing ordered types for collections. These can be
constructed as simple type listings...</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">stem.util</span> <span class="kn">import</span> <span class="n">enum</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">insects</span> <span class="o">=</span> <span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">(</span><span class="s">&quot;ANT&quot;</span><span class="p">,</span> <span class="s">&quot;WASP&quot;</span><span class="p">,</span> <span class="s">&quot;LADYBUG&quot;</span><span class="p">,</span> <span class="s">&quot;FIREFLY&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">insects</span><span class="o">.</span><span class="n">ANT</span>
<span class="go">&#39;Ant&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">tuple</span><span class="p">(</span><span class="n">insects</span><span class="p">)</span>
<span class="go">(&#39;Ant&#39;, &#39;Wasp&#39;, &#39;Ladybug&#39;, &#39;Firefly&#39;)</span>
</pre></div>
</div>
<p>... or with overwritten string counterparts...</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">stem.util</span> <span class="kn">import</span> <span class="n">enum</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pets</span> <span class="o">=</span> <span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">((</span><span class="s">&quot;DOG&quot;</span><span class="p">,</span> <span class="s">&quot;Skippy&quot;</span><span class="p">),</span> <span class="s">&quot;CAT&quot;</span><span class="p">,</span> <span class="p">(</span><span class="s">&quot;FISH&quot;</span><span class="p">,</span> <span class="s">&quot;Nemo&quot;</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pets</span><span class="o">.</span><span class="n">DOG</span>
<span class="go">&#39;Skippy&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pets</span><span class="o">.</span><span class="n">CAT</span>
<span class="go">&#39;Cat&#39;</span>
</pre></div>
</div>
<p><strong>Module Overview:</strong></p>
<div class="highlight-python"><pre>UppercaseEnum - Provides an enum instance with capitalized values

Enum - Provides a basic, ordered  enumeration
  |- keys - string representation of our enum keys
  |- index_of - index of an enum value
  |- next - provides the enum after a given enum value
  |- previous - provides the enum before a given value
  |- __getitem__ - provides the value for an enum key
  +- __iter__ - iterator over our enum keys</pre>
</div>
<dl class="function">
<dt id="stem.util.enum.UppercaseEnum">
<tt class="descclassname">stem.util.enum.</tt><tt class="descname">UppercaseEnum</tt><big>(</big><em>*args</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/enum.html#UppercaseEnum"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.enum.UppercaseEnum" title="Permalink to this definition">¶</a></dt>
<dd><p>Provides an <a class="reference internal" href="#stem.util.enum.Enum" title="stem.util.enum.Enum"><tt class="xref py py-class docutils literal"><span class="pre">Enum</span></tt></a> instance where the values are
identical to the keys. Since the keys are uppercase by convention this means
the values are too. For instance...</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">stem.util</span> <span class="kn">import</span> <span class="n">enum</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">runlevels</span> <span class="o">=</span> <span class="n">enum</span><span class="o">.</span><span class="n">UppercaseEnum</span><span class="p">(</span><span class="s">&quot;DEBUG&quot;</span><span class="p">,</span> <span class="s">&quot;INFO&quot;</span><span class="p">,</span> <span class="s">&quot;NOTICE&quot;</span><span class="p">,</span> <span class="s">&quot;WARN&quot;</span><span class="p">,</span> <span class="s">&quot;ERROR&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">runlevels</span><span class="o">.</span><span class="n">DEBUG</span>
<span class="go">&#39;DEBUG&#39;</span>
</pre></div>
</div>
<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> (<em>list</em>) &#8211; enum keys to initialize with</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#stem.util.enum.Enum" title="stem.util.enum.Enum"><tt class="xref py py-class docutils literal"><span class="pre">Enum</span></tt></a> instance with the given keys</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="stem.util.enum.Enum">
<em class="property">class </em><tt class="descclassname">stem.util.enum.</tt><tt class="descname">Enum</tt><big>(</big><em>*args</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/enum.html#Enum"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.enum.Enum" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Basic enumeration.</p>
<dl class="method">
<dt id="stem.util.enum.Enum.keys">
<tt class="descname">keys</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/stem/util/enum.html#Enum.keys"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.enum.Enum.keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Provides an ordered listing of the enumeration keys in this set.</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">Returns:</th><td class="field-body"><strong>list</strong> with our enum keys</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="stem.util.enum.Enum.index_of">
<tt class="descname">index_of</tt><big>(</big><em>value</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/enum.html#Enum.index_of"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.enum.Enum.index_of" title="Permalink to this definition">¶</a></dt>
<dd><p>Provides the index of the given value in the collection.</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>value</strong> (<em>str</em>) &#8211; entry to be looked up</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>int</strong> index of the given entry</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><strong>ValueError</strong> if no such element exists</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="stem.util.enum.Enum.next">
<tt class="descname">next</tt><big>(</big><em>value</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/enum.html#Enum.next"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.enum.Enum.next" title="Permalink to this definition">¶</a></dt>
<dd><p>Provides the next enumeration after the given value.</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>value</strong> (<em>str</em>) &#8211; enumeration for which to get the next entry</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">enum value following the given entry</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><strong>ValueError</strong> if no such element exists</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="stem.util.enum.Enum.previous">
<tt class="descname">previous</tt><big>(</big><em>value</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/enum.html#Enum.previous"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.enum.Enum.previous" title="Permalink to this definition">¶</a></dt>
<dd><p>Provides the previous enumeration before the given value.</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>value</strong> (<em>str</em>) &#8211; enumeration for which to get the previous entry</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">enum value proceeding the given entry</td>
</tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><strong>ValueError</strong> if no such element exists</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>


      </div>
      <div class="bottomnav">
      </div>

    <div class="footer">
    </div>
  </body>
</html>