Some helpers without having a specific module
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 78KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <!DOCTYPE html>
  2. <html class="writer-html4" lang="en" >
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Welcome to helpers’s documentation! &mdash; helpers documentation</title>
  7. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <!--[if lt IE 9]>
  10. <script src="_static/js/html5shiv.min.js"></script>
  11. <![endif]-->
  12. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  13. <script type="text/javascript" src="_static/jquery.js"></script>
  14. <script type="text/javascript" src="_static/underscore.js"></script>
  15. <script type="text/javascript" src="_static/doctools.js"></script>
  16. <script type="text/javascript" src="_static/language_data.js"></script>
  17. <script type="text/javascript" src="_static/js/theme.js"></script>
  18. <link rel="index" title="Index" href="genindex.html" />
  19. <link rel="search" title="Search" href="search.html" />
  20. </head>
  21. <body class="wy-body-for-nav">
  22. <div class="wy-grid-for-nav">
  23. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  24. <div class="wy-side-scroll">
  25. <div class="wy-side-nav-search" >
  26. <a href="#" class="icon icon-home" alt="Documentation Home"> helpers
  27. </a>
  28. <div role="search">
  29. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  30. <input type="text" name="q" placeholder="Search docs" />
  31. <input type="hidden" name="check_keywords" value="yes" />
  32. <input type="hidden" name="area" value="default" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <!-- Local TOC -->
  38. <div class="local-toc"><ul>
  39. <li><a class="reference internal" href="#">Welcome to helpers’s documentation!</a><ul>
  40. <li><a class="reference internal" href="#helpers-helpers">helpers (Helpers)</a></li>
  41. </ul>
  42. </li>
  43. <li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
  44. </ul>
  45. </div>
  46. </div>
  47. </div>
  48. </nav>
  49. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  50. <nav class="wy-nav-top" aria-label="top navigation">
  51. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  52. <a href="#">helpers</a>
  53. </nav>
  54. <div class="wy-nav-content">
  55. <div class="rst-content">
  56. <div role="navigation" aria-label="breadcrumbs navigation">
  57. <ul class="wy-breadcrumbs">
  58. <li><a href="#" class="icon icon-home"></a> &raquo;</li>
  59. <li>Welcome to helpers’s documentation!</li>
  60. <li class="wy-breadcrumbs-aside">
  61. <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
  62. </li>
  63. </ul>
  64. <hr/>
  65. </div>
  66. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  67. <div itemprop="articleBody">
  68. <div class="section" id="module-helpers">
  69. <span id="welcome-to-helpers-s-documentation"></span><h1>Welcome to helpers’s documentation!<a class="headerlink" href="#module-helpers" title="Permalink to this headline">¶</a></h1>
  70. <div class="section" id="helpers-helpers">
  71. <h2>helpers (Helpers)<a class="headerlink" href="#helpers-helpers" title="Permalink to this headline">¶</a></h2>
  72. <p><strong>Author:</strong></p>
  73. <ul class="simple">
  74. <li>Dirk Alders &lt;<a class="reference external" href="mailto:sudo-dirk&#37;&#52;&#48;mount-mockery&#46;de">sudo-dirk<span>&#64;</span>mount-mockery<span>&#46;</span>de</a>&gt;</li>
  75. </ul>
  76. <p><strong>Description:</strong></p>
  77. <blockquote>
  78. <div>This module supports functions and classes which don’t have an own Module (yet).</div></blockquote>
  79. <p><strong>Submodules:</strong></p>
  80. <ul class="simple">
  81. <li><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a></li>
  82. <li><a class="reference internal" href="#helpers.continues_statistic_multivalue" title="helpers.continues_statistic_multivalue"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic_multivalue</span></code></a></li>
  83. <li><a class="reference internal" href="#helpers.direct_socket_client" title="helpers.direct_socket_client"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_client</span></code></a></li>
  84. <li><a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a></li>
  85. <li><a class="reference internal" href="#helpers.ringbuffer" title="helpers.ringbuffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.ringbuffer</span></code></a></li>
  86. </ul>
  87. <p><strong>Unittest:</strong></p>
  88. <blockquote>
  89. <div>See also the <a class="reference download internal" download="" href="_downloads/fc87e95cc505cb0c7a476506dac46609/unittest.pdf"><code class="xref download docutils literal notranslate"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
  90. <p><strong>Module Documentation:</strong></p>
  91. <dl class="class">
  92. <dt id="helpers.continues_statistic">
  93. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">continues_statistic</code><span class="sig-paren">(</span><em>mean=None</em>, <em>min_val=None</em>, <em>max_val=None</em>, <em>quantifier=0</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic" title="Permalink to this definition">¶</a></dt>
  94. <dd><p>This class stores a statistic for a stream of values. The statistic includes: mean, min, max, quantifier.</p>
  95. <div class="admonition note">
  96. <p class="first admonition-title">Note</p>
  97. <p class="last">You can use the mathematic operators “+, +=” to add a value to the statistic.</p>
  98. </div>
  99. <table class="docutils field-list" frame="void" rules="none">
  100. <col class="field-name" />
  101. <col class="field-body" />
  102. <tbody valign="top">
  103. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  104. <li><strong>mean</strong> (<em>numeric</em>) – The mean start value, the start value or None.</li>
  105. <li><strong>min_val</strong> (<em>numeric</em>) – The min start value or None</li>
  106. <li><strong>max_val</strong> (<em>numeric</em>) – The max start value or None</li>
  107. <li><strong>quantifier</strong> (<em>int</em>) – The quantifier start value or 0</li>
  108. </ul>
  109. </td>
  110. </tr>
  111. </tbody>
  112. </table>
  113. <div class="admonition note">
  114. <p class="first admonition-title">Note</p>
  115. <p>You are able to initialise this class in the following ways:</p>
  116. <ul class="last simple">
  117. <li>Without arguments to get an empty instance</li>
  118. <li>With one single value to get an starting instance</li>
  119. <li>With mean, min_val, max_val, quantifier to initialise an existing statistic</li>
  120. </ul>
  121. </div>
  122. <p><strong>Example:</strong></p>
  123. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  124. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  125. <span class="kn">import</span> <span class="nn">helpers</span>
  126. <span class="n">cs</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic</span><span class="p">()</span>
  127. <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">4</span><span class="p">):</span>
  128. <span class="n">cs</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
  129. <span class="nb">print</span><span class="p">(</span><span class="n">cs</span><span class="p">)</span>
  130. </pre></div>
  131. </div>
  132. <p>Will result to the following output:</p>
  133. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mean</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">1</span>
  134. <span class="n">mean</span><span class="o">=</span><span class="mf">2.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">2</span>
  135. <span class="n">mean</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">3</span>
  136. <span class="n">mean</span><span class="o">=</span><span class="mf">3.25</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">4</span>
  137. </pre></div>
  138. </div>
  139. <dl class="attribute">
  140. <dt id="helpers.continues_statistic.max">
  141. <code class="descname">max</code><a class="headerlink" href="#helpers.continues_statistic.max" title="Permalink to this definition">¶</a></dt>
  142. <dd><p>The current max value.</p>
  143. </dd></dl>
  144. <dl class="attribute">
  145. <dt id="helpers.continues_statistic.mean">
  146. <code class="descname">mean</code><a class="headerlink" href="#helpers.continues_statistic.mean" title="Permalink to this definition">¶</a></dt>
  147. <dd><p>The current mean value.</p>
  148. </dd></dl>
  149. <dl class="attribute">
  150. <dt id="helpers.continues_statistic.min">
  151. <code class="descname">min</code><a class="headerlink" href="#helpers.continues_statistic.min" title="Permalink to this definition">¶</a></dt>
  152. <dd><p>The current min value.</p>
  153. </dd></dl>
  154. <dl class="method">
  155. <dt id="helpers.continues_statistic.pop">
  156. <code class="descname">pop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic.pop" title="Permalink to this definition">¶</a></dt>
  157. <dd><p>This pops out the current statistic data and returns these as an instance of <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
  158. <table class="docutils field-list" frame="void" rules="none">
  159. <col class="field-name" />
  160. <col class="field-body" />
  161. <tbody valign="top">
  162. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The current statistic or None, if no value is available.</td>
  163. </tr>
  164. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a> or None</td>
  165. </tr>
  166. </tbody>
  167. </table>
  168. </dd></dl>
  169. <dl class="attribute">
  170. <dt id="helpers.continues_statistic.quantifier">
  171. <code class="descname">quantifier</code><a class="headerlink" href="#helpers.continues_statistic.quantifier" title="Permalink to this definition">¶</a></dt>
  172. <dd><p>The current quantifier (number of values for continues statistic).</p>
  173. </dd></dl>
  174. </dd></dl>
  175. <dl class="class">
  176. <dt id="helpers.continues_statistic_multivalue">
  177. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">continues_statistic_multivalue</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic_multivalue" title="Permalink to this definition">¶</a></dt>
  178. <dd><p>This class stores multiple statistics of stream values. The statistic of each value is stored as <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
  179. <div class="admonition note">
  180. <p class="first admonition-title">Note</p>
  181. <p class="last">You can use the mathematic operators “+, +=” to add instances.</p>
  182. </div>
  183. <div class="admonition note">
  184. <p class="first admonition-title">Note</p>
  185. <p>You are able to initialise this class in the following ways:</p>
  186. <ul class="last simple">
  187. <li>Without arguments to get an empty instance</li>
  188. <li>With a keword argument(s) which will be passed to <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">continues_statistic</span></code></a></li>
  189. <li>With a dict equivalent of <a class="reference internal" href="#helpers.continues_statistic_multivalue" title="helpers.continues_statistic_multivalue"><code class="xref py py-class docutils literal notranslate"><span class="pre">continues_statistic_multivalue</span></code></a> to initialise an existing statistic</li>
  190. </ul>
  191. </div>
  192. <p><strong>Example:</strong></p>
  193. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  194. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  195. <span class="kn">import</span> <span class="nn">helpers</span>
  196. <span class="n">csm</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">()</span>
  197. <span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  198. <span class="n">csm</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="mf">3.1</span><span class="p">,</span> <span class="s1">&#39;min_val&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;max_val&#39;</span><span class="p">:</span> <span class="mf">3.5</span><span class="p">,</span> <span class="s1">&#39;quantifier&#39;</span><span class="p">:</span> <span class="mi">305</span><span class="p">})</span>
  199. <span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  200. <span class="n">csm</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="mf">17.1</span><span class="p">,</span> <span class="s1">&#39;min_val&#39;</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">,</span> <span class="s1">&#39;max_val&#39;</span><span class="p">:</span> <span class="mf">19.3</span><span class="p">,</span> <span class="s1">&#39;quantifier&#39;</span><span class="p">:</span> <span class="mi">27</span><span class="p">})</span>
  201. <span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  202. <span class="nb">print</span><span class="p">(</span><span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="n">csm</span><span class="p">)),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  203. <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out b:&#39;</span><span class="p">,</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;b&#39;</span><span class="p">),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  204. <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out b:&#39;</span><span class="p">,</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;b&#39;</span><span class="p">),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  205. <span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  206. <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out all:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  207. <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out all:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  208. <span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  209. </pre></div>
  210. </div>
  211. <p>Will result to the following output:</p>
  212. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span>
  213. <span class="o">--------------------------------------------------------------</span>
  214. <span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">3.5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">305</span>
  215. <span class="o">--------------------------------------------------------------</span>
  216. <span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
  217. <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
  218. <span class="o">--------------------------------------------------------------</span>
  219. <span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
  220. <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
  221. <span class="o">--------------------------------------------------------------</span>
  222. <span class="n">pop</span> <span class="n">out</span> <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
  223. <span class="o">--------------------------------------------------------------</span>
  224. <span class="n">pop</span> <span class="n">out</span> <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">0</span>
  225. <span class="o">--------------------------------------------------------------</span>
  226. <span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
  227. <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">0</span>
  228. <span class="o">--------------------------------------------------------------</span>
  229. <span class="n">pop</span> <span class="n">out</span> <span class="nb">all</span><span class="p">:</span>
  230. <span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
  231. <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">0</span>
  232. <span class="o">--------------------------------------------------------------</span>
  233. <span class="n">pop</span> <span class="n">out</span> <span class="nb">all</span><span class="p">:</span>
  234. <span class="o">-</span>
  235. <span class="o">--------------------------------------------------------------</span>
  236. <span class="o">-</span>
  237. <span class="o">--------------------------------------------------------------</span>
  238. </pre></div>
  239. </div>
  240. <dl class="method">
  241. <dt id="helpers.continues_statistic_multivalue.pop">
  242. <code class="descname">pop</code><span class="sig-paren">(</span><em>key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic_multivalue.pop" title="Permalink to this definition">¶</a></dt>
  243. <dd><p>This pops out the current statistic data for a given key and returns these as an instance of <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
  244. <p>If no key is given it pops out the current statistic data and returns these as an instance of <code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic_multiple</span></code>.</p>
  245. <table class="docutils field-list" frame="void" rules="none">
  246. <col class="field-name" />
  247. <col class="field-body" />
  248. <tbody valign="top">
  249. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>key</strong> (<em>str</em><em> or </em><em>NoneType</em>) – The key to get data for</td>
  250. </tr>
  251. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The current statistic or None, if no value is available.</td>
  252. </tr>
  253. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a> or None</td>
  254. </tr>
  255. </tbody>
  256. </table>
  257. </dd></dl>
  258. </dd></dl>
  259. <dl class="class">
  260. <dt id="helpers.direct_socket_base">
  261. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_base</code><span class="sig-paren">(</span><em>max_len=None</em>, <em>virtual_rate_bps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base" title="Permalink to this definition">¶</a></dt>
  262. <dd><p>This is the base class for other classes in this module.</p>
  263. <dl class="method">
  264. <dt id="helpers.direct_socket_base.disconnect">
  265. <code class="descname">disconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.disconnect" title="Permalink to this definition">¶</a></dt>
  266. <dd><p>Method to disconnect client and server.</p>
  267. </dd></dl>
  268. <dl class="method">
  269. <dt id="helpers.direct_socket_base.init_channel_name">
  270. <code class="descname">init_channel_name</code><span class="sig-paren">(</span><em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.init_channel_name" title="Permalink to this definition">¶</a></dt>
  271. <dd><p>With this Method, the channel name for logging can be changed.</p>
  272. <table class="docutils field-list" frame="void" rules="none">
  273. <col class="field-name" />
  274. <col class="field-body" />
  275. <tbody valign="top">
  276. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</td>
  277. </tr>
  278. </tbody>
  279. </table>
  280. </dd></dl>
  281. <dl class="method">
  282. <dt id="helpers.direct_socket_base.is_connected">
  283. <code class="descname">is_connected</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.is_connected" title="Permalink to this definition">¶</a></dt>
  284. <dd><p>With this Method the connection status can be identified.</p>
  285. <table class="docutils field-list" frame="void" rules="none">
  286. <col class="field-name" />
  287. <col class="field-body" />
  288. <tbody valign="top">
  289. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True, if a connection is established, otherwise False.</td>
  290. </tr>
  291. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  292. </tr>
  293. </tbody>
  294. </table>
  295. </dd></dl>
  296. <dl class="method">
  297. <dt id="helpers.direct_socket_base.receive">
  298. <code class="descname">receive</code><span class="sig-paren">(</span><em>timeout=1.0</em>, <em>num=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.receive" title="Permalink to this definition">¶</a></dt>
  299. <dd><p>This method returns received data.</p>
  300. <table class="docutils field-list" frame="void" rules="none">
  301. <col class="field-name" />
  302. <col class="field-body" />
  303. <tbody valign="top">
  304. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  305. <li><strong>timeout</strong> (<em>float</em>) – The timeout for receiving data (at least after the timeout the method returns data or None).</li>
  306. <li><strong>num</strong> (<em>int</em><em> or </em><em>None</em>) – the number of bytes to receive (use None to get all available data).</li>
  307. </ul>
  308. </td>
  309. </tr>
  310. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The received data.</p>
  311. </td>
  312. </tr>
  313. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bytes</p>
  314. </td>
  315. </tr>
  316. </tbody>
  317. </table>
  318. </dd></dl>
  319. <dl class="method">
  320. <dt id="helpers.direct_socket_base.register_callback">
  321. <code class="descname">register_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_callback" title="Permalink to this definition">¶</a></dt>
  322. <dd><p>This method stores the callback which is executed, if data is available. You need to execute <a class="reference internal" href="#helpers.direct_socket_base.receive" title="helpers.direct_socket_base.receive"><code class="xref py py-func docutils literal notranslate"><span class="pre">receive()</span></code></a> of this instance
  323. given as first argument.</p>
  324. <table class="docutils field-list" frame="void" rules="none">
  325. <col class="field-name" />
  326. <col class="field-body" />
  327. <tbody valign="top">
  328. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when data is available.</td>
  329. </tr>
  330. </tbody>
  331. </table>
  332. </dd></dl>
  333. <dl class="method">
  334. <dt id="helpers.direct_socket_base.register_connect_callback">
  335. <code class="descname">register_connect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_connect_callback" title="Permalink to this definition">¶</a></dt>
  336. <dd><p>This method stores the callback which is executed, if a connection is established.</p>
  337. <table class="docutils field-list" frame="void" rules="none">
  338. <col class="field-name" />
  339. <col class="field-body" />
  340. <tbody valign="top">
  341. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when a connection is established.</td>
  342. </tr>
  343. </tbody>
  344. </table>
  345. </dd></dl>
  346. <dl class="method">
  347. <dt id="helpers.direct_socket_base.register_disconnect_callback">
  348. <code class="descname">register_disconnect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_disconnect_callback" title="Permalink to this definition">¶</a></dt>
  349. <dd><p>This method stores the callback which is executed, after the connection is lost.</p>
  350. <table class="docutils field-list" frame="void" rules="none">
  351. <col class="field-name" />
  352. <col class="field-body" />
  353. <tbody valign="top">
  354. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, after the connection is lost.</td>
  355. </tr>
  356. </tbody>
  357. </table>
  358. </dd></dl>
  359. <dl class="method">
  360. <dt id="helpers.direct_socket_base.send">
  361. <code class="descname">send</code><span class="sig-paren">(</span><em>data</em>, <em>timeout=1.0</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.send" title="Permalink to this definition">¶</a></dt>
  362. <dd><p>This method sends data via the initiated communication channel.</p>
  363. <table class="docutils field-list" frame="void" rules="none">
  364. <col class="field-name" />
  365. <col class="field-body" />
  366. <tbody valign="top">
  367. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  368. <li><strong>data</strong> (<em>bytes</em>) – The data to be send over the communication channel.</li>
  369. <li><strong>timeout</strong> (<em>float</em>) – The timeout for sending data (e.g. time to establish new connection).</li>
  370. </ul>
  371. </td>
  372. </tr>
  373. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if data had been sent, otherwise False.</p>
  374. </td>
  375. </tr>
  376. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
  377. </td>
  378. </tr>
  379. </tbody>
  380. </table>
  381. </dd></dl>
  382. </dd></dl>
  383. <dl class="class">
  384. <dt id="helpers.direct_socket_client">
  385. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_client</code><span class="sig-paren">(</span><em>max_len=None</em>, <em>virtual_rate_bps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client" title="Permalink to this definition">¶</a></dt>
  386. <dd><p>Class to create a direct client socket. See also parent <a class="reference internal" href="#helpers.direct_socket_base" title="helpers.direct_socket_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_base</span></code></a>.</p>
  387. <p><strong>Example:</strong></p>
  388. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  389. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  390. <span class="kn">import</span> <span class="nn">report</span>
  391. <span class="kn">import</span> <span class="nn">helpers</span>
  392. <span class="kn">import</span> <span class="nn">time</span>
  393. <span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
  394. <span class="n">sock</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sock</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
  395. <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  396. <span class="n">s</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_server</span><span class="p">(</span><span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  397. <span class="n">s</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_server&#39;</span><span class="p">)</span>
  398. <span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
  399. <span class="n">c</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_client</span><span class="p">(</span><span class="n">max_len</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  400. <span class="n">c</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_client&#39;</span><span class="p">)</span>
  401. <span class="n">c</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
  402. <span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;abc&#39;</span><span class="p">)</span>
  403. <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The Client received: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
  404. </pre></div>
  405. </div>
  406. <p>Will result to the following output:</p>
  407. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  408. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Waiting</span> <span class="k">for</span> <span class="n">incomming</span> <span class="n">connection</span>
  409. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  410. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
  411. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  412. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
  413. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  414. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  415. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">824</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  416. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">825</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
  417. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">825</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  418. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">08</span><span class="p">,</span><span class="mi">025</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
  419. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">08</span><span class="p">,</span><span class="mi">225</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  420. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">08</span><span class="p">,</span><span class="mi">225</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
  421. <span class="n">The</span> <span class="n">Client</span> <span class="n">received</span><span class="p">:</span> <span class="sa">b</span><span class="s1">&#39;ab&#39;</span>
  422. </pre></div>
  423. </div>
  424. <dl class="method">
  425. <dt id="helpers.direct_socket_client.connect">
  426. <code class="descname">connect</code><span class="sig-paren">(</span><em>remote_socket</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client.connect" title="Permalink to this definition">¶</a></dt>
  427. <dd><p>Method to create a connection between this client and a <a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a> instance.</p>
  428. <table class="docutils field-list" frame="void" rules="none">
  429. <col class="field-name" />
  430. <col class="field-body" />
  431. <tbody valign="top">
  432. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>remote_socket</strong> (<a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a>) – The remote socket to connect to.</td>
  433. </tr>
  434. </tbody>
  435. </table>
  436. </dd></dl>
  437. <dl class="method">
  438. <dt id="helpers.direct_socket_client.reconnect">
  439. <code class="descname">reconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client.reconnect" title="Permalink to this definition">¶</a></dt>
  440. <dd><p>Method to do a reconnect.</p>
  441. <div class="admonition note">
  442. <p class="first admonition-title">Note</p>
  443. <p class="last">The <code class="xref py py-const docutils literal notranslate"><span class="pre">remote_socket</span></code> of the prefious <a class="reference internal" href="#helpers.direct_socket_client.connect" title="helpers.direct_socket_client.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">connect()</span></code></a> call will be used.</p>
  444. </div>
  445. </dd></dl>
  446. </dd></dl>
  447. <dl class="class">
  448. <dt id="helpers.direct_socket_server">
  449. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_server</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_server" title="Permalink to this definition">¶</a></dt>
  450. <dd><p>Class to create a direct server socket. See also parent <a class="reference internal" href="#helpers.direct_socket_base" title="helpers.direct_socket_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_base</span></code></a>.</p>
  451. <p><strong>Example:</strong></p>
  452. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  453. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  454. <span class="kn">import</span> <span class="nn">report</span>
  455. <span class="kn">import</span> <span class="nn">helpers</span>
  456. <span class="kn">import</span> <span class="nn">time</span>
  457. <span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
  458. <span class="n">sock</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sock</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
  459. <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
  460. <span class="n">s</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_server</span><span class="p">(</span><span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  461. <span class="n">s</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_server&#39;</span><span class="p">)</span>
  462. <span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
  463. <span class="n">c</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_client</span><span class="p">(</span><span class="n">max_len</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  464. <span class="n">c</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_client&#39;</span><span class="p">)</span>
  465. <span class="n">c</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
  466. <span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;abc&#39;</span><span class="p">)</span>
  467. <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The Client received: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
  468. </pre></div>
  469. </div>
  470. <p>Will result to the following output:</p>
  471. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  472. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Waiting</span> <span class="k">for</span> <span class="n">incomming</span> <span class="n">connection</span>
  473. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  474. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">423</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
  475. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  476. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
  477. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
  478. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">424</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  479. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">824</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  480. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">825</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
  481. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">07</span><span class="p">,</span><span class="mi">825</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  482. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">08</span><span class="p">,</span><span class="mi">025</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
  483. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">08</span><span class="p">,</span><span class="mi">225</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
  484. <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">03</span><span class="p">:</span><span class="mi">08</span><span class="p">,</span><span class="mi">225</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
  485. <span class="n">The</span> <span class="n">Client</span> <span class="n">received</span><span class="p">:</span> <span class="sa">b</span><span class="s1">&#39;ab&#39;</span>
  486. </pre></div>
  487. </div>
  488. </dd></dl>
  489. <dl class="class">
  490. <dt id="helpers.direct_socket_stp_base">
  491. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_stp_base</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_stp_base" title="Permalink to this definition">¶</a></dt>
  492. <dd><dl class="method">
  493. <dt id="helpers.direct_socket_stp_base.receive">
  494. <code class="descname">receive</code><span class="sig-paren">(</span><em>timeout=1</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_stp_base.receive" title="Permalink to this definition">¶</a></dt>
  495. <dd><p>This method returns one received messages via the initiated communication channel.</p>
  496. <table class="docutils field-list" frame="void" rules="none">
  497. <col class="field-name" />
  498. <col class="field-body" />
  499. <tbody valign="top">
  500. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>timeout</strong> (<em>float</em>) – The timeout for receiving data (at least after the timeout the method returns data or None).</td>
  501. </tr>
  502. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The received data.</td>
  503. </tr>
  504. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bytes</td>
  505. </tr>
  506. </tbody>
  507. </table>
  508. </dd></dl>
  509. </dd></dl>
  510. <dl class="class">
  511. <dt id="helpers.direct_socket_stp_client">
  512. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_stp_client</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_stp_client" title="Permalink to this definition">¶</a></dt>
  513. <dd><dl class="method">
  514. <dt id="helpers.direct_socket_stp_client.connect">
  515. <code class="descname">connect</code><span class="sig-paren">(</span><em>remote_socket</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_stp_client.connect" title="Permalink to this definition">¶</a></dt>
  516. <dd><p>Method to create a connection between this client and a <a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a> instance.</p>
  517. <table class="docutils field-list" frame="void" rules="none">
  518. <col class="field-name" />
  519. <col class="field-body" />
  520. <tbody valign="top">
  521. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>remote_socket</strong> (<a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a>) – The remote socket to connect to.</td>
  522. </tr>
  523. </tbody>
  524. </table>
  525. </dd></dl>
  526. <dl class="method">
  527. <dt id="helpers.direct_socket_stp_client.reconnect">
  528. <code class="descname">reconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_stp_client.reconnect" title="Permalink to this definition">¶</a></dt>
  529. <dd><p>Method to do a reconnect.</p>
  530. <div class="admonition note">
  531. <p class="first admonition-title">Note</p>
  532. <p class="last">The <code class="xref py py-const docutils literal notranslate"><span class="pre">remote_socket</span></code> of the prefious <a class="reference internal" href="#helpers.direct_socket_stp_client.connect" title="helpers.direct_socket_stp_client.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">connect()</span></code></a> call will be used.</p>
  533. </div>
  534. </dd></dl>
  535. </dd></dl>
  536. <dl class="class">
  537. <dt id="helpers.direct_socket_stp_server">
  538. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_stp_server</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_stp_server" title="Permalink to this definition">¶</a></dt>
  539. <dd></dd></dl>
  540. <dl class="class">
  541. <dt id="helpers.ringbuffer">
  542. <em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">ringbuffer</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer" title="Permalink to this definition">¶</a></dt>
  543. <dd><p>Class for a list with a limited number of elements.</p>
  544. <div class="admonition note">
  545. <p class="first admonition-title">Note</p>
  546. <p class="last">On adding Objects, the list will be reduced to the maximum length by deleting entries starting from index 0.</p>
  547. </div>
  548. <p><strong>Example:</strong></p>
  549. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
  550. <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
  551. <span class="kn">import</span> <span class="nn">helpers</span>
  552. <span class="n">rb</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">ringbuffer</span><span class="p">(</span><span class="n">length</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  553. <span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  554. <span class="n">rb</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
  555. <span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  556. <span class="n">rb</span><span class="o">.</span><span class="n">extend</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">))</span>
  557. <span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  558. <span class="n">rb</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">17</span><span class="p">)</span>
  559. <span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
  560. </pre></div>
  561. </div>
  562. <p>Will result to the following output:</p>
  563. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[]</span>
  564. <span class="o">--------------------------------------------------------------</span>
  565. <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
  566. <span class="o">--------------------------------------------------------------</span>
  567. <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">]</span>
  568. <span class="o">--------------------------------------------------------------</span>
  569. <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">17</span><span class="p">]</span>
  570. <span class="o">--------------------------------------------------------------</span>
  571. </pre></div>
  572. </div>
  573. <dl class="method">
  574. <dt id="helpers.ringbuffer.append">
  575. <code class="descname">append</code><span class="sig-paren">(</span><em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer.append" title="Permalink to this definition">¶</a></dt>
  576. <dd><p>Append object to the end of the list.</p>
  577. </dd></dl>
  578. <dl class="method">
  579. <dt id="helpers.ringbuffer.extend">
  580. <code class="descname">extend</code><span class="sig-paren">(</span><em>iterable</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer.extend" title="Permalink to this definition">¶</a></dt>
  581. <dd><p>Extend list by appending elements from the iterable.</p>
  582. </dd></dl>
  583. </dd></dl>
  584. </div>
  585. <div class="toctree-wrapper compound">
  586. </div>
  587. </div>
  588. <div class="section" id="indices-and-tables">
  589. <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
  590. <ul class="simple">
  591. <li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
  592. <li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
  593. <li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
  594. </ul>
  595. </div>
  596. </div>
  597. </div>
  598. <footer>
  599. <hr/>
  600. <div role="contentinfo">
  601. <p>
  602. &copy; Copyright 2021, Dirk Alders
  603. </p>
  604. </div>
  605. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
  606. <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
  607. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  608. </footer>
  609. </div>
  610. </div>
  611. </section>
  612. </div>
  613. <script type="text/javascript">
  614. jQuery(function () {
  615. SphinxRtdTheme.Navigation.enable(true);
  616. });
  617. </script>
  618. </body>
  619. </html>