<!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>Terminal Utilities — 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="Tor Utilities" href="tor_tools.html" /> <link rel="prev" title="System Utilities" href="system.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>Terminal Utilities</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.term"> <span id="terminal-utilities"></span><h1>Terminal Utilities<a class="headerlink" href="#module-stem.util.term" title="Permalink to this headline">¶</a></h1> <p>Utilities for working with the terminal.</p> <p><strong>Module Overview:</strong></p> <div class="highlight-python"><pre>format - wrap text with ANSI for the given colors or attributes</pre> </div> <dl class="data"> <dt id="stem.util.term.Color"> <tt class="descclassname">stem.util.term.</tt><tt class="descname">Color</tt><big>(</big><em>enum</em><big>)</big><a class="headerlink" href="#stem.util.term.Color" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="data"> <dt id="stem.util.term.BgColor"> <tt class="descclassname">stem.util.term.</tt><tt class="descname">BgColor</tt><big>(</big><em>enum</em><big>)</big><a class="headerlink" href="#stem.util.term.BgColor" title="Permalink to this definition">¶</a></dt> <dd><p>Enumerations for foreground or background terminal color.</p> <table border="1" class="docutils"> <colgroup> <col width="46%" /> <col width="54%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Color</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><strong>BLACK</strong></td> <td>black color</td> </tr> <tr class="row-odd"><td><strong>BLUE</strong></td> <td>blue color</td> </tr> <tr class="row-even"><td><strong>CYAN</strong></td> <td>cyan color</td> </tr> <tr class="row-odd"><td><strong>GREEN</strong></td> <td>green color</td> </tr> <tr class="row-even"><td><strong>MAGENTA</strong></td> <td>magenta color</td> </tr> <tr class="row-odd"><td><strong>RED</strong></td> <td>red color</td> </tr> <tr class="row-even"><td><strong>WHITE</strong></td> <td>white color</td> </tr> <tr class="row-odd"><td><strong>YELLOW</strong></td> <td>yellow color</td> </tr> </tbody> </table> </dd></dl> <dl class="data"> <dt id="stem.util.term.Attr"> <tt class="descclassname">stem.util.term.</tt><tt class="descname">Attr</tt><big>(</big><em>enum</em><big>)</big><a class="headerlink" href="#stem.util.term.Attr" title="Permalink to this definition">¶</a></dt> <dd><p>Enumerations of terminal text attributes.</p> <table border="1" class="docutils"> <colgroup> <col width="28%" /> <col width="72%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Attr</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><strong>BOLD</strong></td> <td>heavy typeface</td> </tr> <tr class="row-odd"><td><strong>HILIGHT</strong></td> <td>inverted foreground and background</td> </tr> <tr class="row-even"><td><strong>UNDERLINE</strong></td> <td>underlined text</td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="stem.util.term.format"> <tt class="descclassname">stem.util.term.</tt><tt class="descname">format</tt><big>(</big><em>msg</em>, <em>*attr</em><big>)</big><a class="reference internal" href="../../_modules/stem/util/term.html#format"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.util.term.format" title="Permalink to this definition">¶</a></dt> <dd><p>Simple terminal text formatting using <a class="reference external" href="https://secure.wikimedia.org/wikipedia/en/wiki/ANSI_escape_code#CSI_codes">ANSI escape sequences</a>. The following are some toolkits providing similar capabilities:</p> <ul class="simple"> <li><a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/utils/termcolors.py">django.utils.termcolors</a></li> <li><a class="reference external" href="http://pypi.python.org/pypi/termcolor">termcolor</a></li> <li><a class="reference external" href="http://pypi.python.org/pypi/colorama">colorama</a></li> </ul> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>msg</strong> (<em>str</em>) – string to be formatted</li> <li><strong>attr</strong> (<em>str</em>) – text attributes, this can be <a class="reference internal" href="#stem.util.term.Color" title="stem.util.term.Color"><tt class="xref py py-data docutils literal"><span class="pre">Color</span></tt></a>, <a class="reference internal" href="#stem.util.term.BgColor" title="stem.util.term.BgColor"><tt class="xref py py-data docutils literal"><span class="pre">BgColor</span></tt></a>, or <a class="reference internal" href="#stem.util.term.Attr" title="stem.util.term.Attr"><tt class="xref py py-data docutils literal"><span class="pre">Attr</span></tt></a> enums and are case insensitive (so strings like “red” are fine)</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><strong>str</strong> wrapped with ANSI escape encodings, starting with the given attributes and ending with a reset</p> </td> </tr> </tbody> </table> </dd></dl> </div> </div> <div class="bottomnav"> </div> <div class="footer"> </div> </body> </html>