<spanid="evennia-utils-ansi"></span><h1>evennia.utils.ansi<aclass="headerlink"href="#module-evennia.utils.ansi"title="Permalink to this headline">¶</a></h1>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="s2">"This is |rRed text|n and this is normal again."</span>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="s2">"This is |500Red text|n and this is normal again."</span>
<spanclass="s2">"This is |[=jText on dark grey background"</span>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">ANSIParser</code><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_fg</code><emclass="property"> = ['\\|([0-5])([0-5])([0-5])']</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_fg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_bg</code><emclass="property"> = ['\\|\\[([0-5])([0-5])([0-5])']</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_bg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_gfg</code><emclass="property"> = ['\\|=([a-z])']</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_gfg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_gbg</code><emclass="property"> = ['\\|\\[=([a-z])']</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_gbg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mxp_re</code><emclass="property"> = '\\|lc(.*?)\\|lt(.*?)\\|le'</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.mxp_re"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mxp_url_re</code><emclass="property"> = '\\|lu(.*?)\\|lt(.*?)\\|le'</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.mxp_url_re"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">brightbg_sub</code><emclass="property"> = re.compile('(?<!\\|)\\|\\[r|(?<!\\|)\\|\\[g|(?<!\\|)\\|\\[y|(?<!\\|)\\|\\[b|(?<!\\|)\\|\\[m|(?<!\\|)\\|\\[c|(?<!\\|)\\|\\[w|(?<!\\|)\\|\\[x', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.brightbg_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_fg_sub</code><emclass="property"> = re.compile('\\|([0-5])([0-5])([0-5])', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_fg_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_bg_sub</code><emclass="property"> = re.compile('\\|\\[([0-5])([0-5])([0-5])', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_bg_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_gfg_sub</code><emclass="property"> = re.compile('\\|=([a-z])', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_gfg_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">xterm256_gbg_sub</code><emclass="property"> = re.compile('\\|\\[=([a-z])', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.xterm256_gbg_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">ansi_sub</code><emclass="property"> = re.compile('\\|n|\\|/|\\|\\-|\\|>|\\|_|\\|\\*|\\|\\^|\\|u|\\|r|\\|g|\\|y|\\|b|\\|m|\\|c|\\|w|\\|x|\\|R|\\|G|\\|Y|\\|B|\\|M|\\|C|\\|W|\\|X|\\|h|\\|H|\\|!R|\\|!G|\\|!Y|\\|!B|\\|!M|\\|!C|\\|!W|\\|!X|\\|\\[R|\\|\\[G, re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.ansi_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mxp_sub</code><emclass="property"> = re.compile('\\|lc(.*?)\\|lt(.*?)\\|le', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.mxp_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mxp_url_sub</code><emclass="property"> = re.compile('\\|lu(.*?)\\|lt(.*?)\\|le', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.mxp_url_sub"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">ansi_re</code><emclass="property"> = '\\033\\[[0-9;]+m'</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.ansi_re"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">ansi_regex</code><emclass="property"> = re.compile('\\033\\[[0-9;]+m')</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.ansi_regex"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">ansi_escapes</code><emclass="property"> = re.compile('({{|\\\\|\\|\\|)', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.ansi_escapes"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">unsafe_tokens</code><emclass="property"> = re.compile('\\|\\/|\\|-', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.unsafe_tokens"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">sub_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">ansimatch</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser.sub_ansi"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.sub_ansi"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">sub_brightbg</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">ansimatch</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser.sub_brightbg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.sub_brightbg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">sub_xterm256</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">rgbmatch</span></em>, <emclass="sig-param"><spanclass="n">use_xterm256</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="n">color_type</span><spanclass="o">=</span><spanclass="default_value">'fg'</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser.sub_xterm256"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.sub_xterm256"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">strip_raw_codes</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">string</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser.strip_raw_codes"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.strip_raw_codes"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">strip_mxp</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">string</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser.strip_mxp"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.strip_mxp"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">strip_unsafe_tokens</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">string</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser.strip_unsafe_tokens"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.strip_unsafe_tokens"title="Permalink to this definition">¶</a></dt>
<dd><p>Strip explicitly ansi line breaks and tabs.</p>
<codeclass="sig-name descname">parse_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">string</span></em>, <emclass="sig-param"><spanclass="n">strip_ansi</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="n">xterm256</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="n">mxp</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIParser.parse_ansi"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIParser.parse_ansi"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">strip_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">parser=<evennia.utils.ansi.ANSIParser object></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#strip_ansi"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.strip_ansi"title="Permalink to this definition">¶</a></dt>
<dd><p>Strip all ansi from the string. This handles the Evennia-specific
markup.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string</strong> (<em>str</em>) – The string to strip.</p></li>
<li><p><strong>parser</strong> (<em>ansi.AnsiParser</em><em>, </em><em>optional</em>) – The parser to use.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>string (str)</em>– The stripped string.</p>
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">strip_raw_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">parser=<evennia.utils.ansi.ANSIParser object></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#strip_raw_ansi"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.strip_raw_ansi"title="Permalink to this definition">¶</a></dt>
<dd><p>Remove raw ansi codes from string. This assumes pure
ANSI-bytecodes in the string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string</strong> (<em>str</em>) – The string to parse.</p></li>
<li><p><strong>parser</strong> (<em>bool</em><em>, </em><em>optional</em>) – The parser to use.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>string (str)</em>– the stripped string.</p>
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">strip_unsafe_tokens</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">parser=<evennia.utils.ansi.ANSIParser object></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#strip_unsafe_tokens"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.strip_unsafe_tokens"title="Permalink to this definition">¶</a></dt>
<dd><p>Strip markup that can be used to create visual exploits
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">strip_mxp</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">parser=<evennia.utils.ansi.ANSIParser object></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#strip_mxp"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.strip_mxp"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">raw</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">string</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#raw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.raw"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">ANSIMeta</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIMeta"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIMeta"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIMeta.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIMeta.__init__"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">ANSIString</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_format</code><emclass="property"> = re.compile('(?i)(?P<just>(?P<fill>.)?(?P<align>\\<|\\>|\\=|\\^))?(?P<sign>\\+|\\-| )?(?P<alt>\\#)?(?P<zero>0)?(?P<width>\\d+)?(?P<grouping>\\_|\\,)?(?:\\.(?P<precision>\\d+))?(?P<type>b|c|d|e|E|f|F|g|G|n|o|s|x|X, re.IGNORECASE)</em><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.re_format"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">_</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.__init__"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">clean</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.clean"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.clean"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a string object <em>without</em> the ANSI escapes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><em>clean_string (str)</em>– A unicode object with no ANSI escapes.</p>
<codeclass="sig-name descname">raw</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.raw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.raw"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a string object with the ANSI escapes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><em>raw (str)</em>– A unicode object <em>with</em> the raw ANSI escape sequences.</p>
<codeclass="sig-name descname">partition</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">sep</span></em>, <emclass="sig-param"><spanclass="n">reverse</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.partition"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.partition"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">split</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">by</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">maxsplit</span><spanclass="o">=</span><spanclass="default_value">- 1</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.split"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.split"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">rsplit</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">by</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">maxsplit</span><spanclass="o">=</span><spanclass="default_value">- 1</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.rsplit"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.rsplit"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">strip</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">chars</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.strip"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.strip"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lstrip</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">chars</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.lstrip"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.lstrip"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">capitalize</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.capitalize"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a capitalized version of the string.</p>
<p>More specifically, make the first character have upper case and the rest lower
<codeclass="sig-name descname">count</code><spanclass="sig-paren">(</span><emclass="sig-param">sub</em><spanclass="optional">[</span>, <emclass="sig-param">start</em><spanclass="optional">[</span>, <emclass="sig-param">end</em><spanclass="optional">]</span><spanclass="optional">]</span><spanclass="sig-paren">)</span>→ int<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.count"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the number of non-overlapping occurrences of substring sub in
string S[start:end]. Optional arguments start and end are
<codeclass="sig-name descname">decode</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.decode"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">encode</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.encode"title="Permalink to this definition">¶</a></dt>
<dd><p>Encode the string using the codec registered for encoding.</p>
<dlclass="simple">
<dt>encoding</dt><dd><p>The encoding in which to encode the string.</p>
</dd>
<dt>errors</dt><dd><p>The error handling scheme to use for encoding errors.
The default is ‘strict’ meaning that encoding errors raise a
UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and
‘xmlcharrefreplace’ as well as any other name registered with
codecs.register_error that can handle UnicodeEncodeErrors.</p>
<codeclass="sig-name descname">endswith</code><spanclass="sig-paren">(</span><emclass="sig-param">suffix</em><spanclass="optional">[</span>, <emclass="sig-param">start</em><spanclass="optional">[</span>, <emclass="sig-param">end</em><spanclass="optional">]</span><spanclass="optional">]</span><spanclass="sig-paren">)</span>→ bool<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.endswith"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
<codeclass="sig-name descname">expandtabs</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.expandtabs"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a copy where all tab characters are expanded using spaces.</p>
<p>If tabsize is not given, a tab size of 8 characters is assumed.</p>
<codeclass="sig-name descname">find</code><spanclass="sig-paren">(</span><emclass="sig-param">sub</em><spanclass="optional">[</span>, <emclass="sig-param">start</em><spanclass="optional">[</span>, <emclass="sig-param">end</em><spanclass="optional">]</span><spanclass="optional">]</span><spanclass="sig-paren">)</span>→ int<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.find"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.</p>
<codeclass="sig-name descname">format</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span>→ str<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.format"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a formatted version of S, using substitutions from args and kwargs.
<codeclass="sig-name descname">index</code><spanclass="sig-paren">(</span><emclass="sig-param">sub</em><spanclass="optional">[</span>, <emclass="sig-param">start</em><spanclass="optional">[</span>, <emclass="sig-param">end</em><spanclass="optional">]</span><spanclass="optional">]</span><spanclass="sig-paren">)</span>→ int<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.index"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.</p>
<p>Raises ValueError when the substring is not found.</p>
<codeclass="sig-name descname">isalnum</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isalnum"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the string is an alpha-numeric string, False otherwise.</p>
<p>A string is alpha-numeric if all characters in the string are alpha-numeric and
there is at least one character in the string.</p>
<codeclass="sig-name descname">isalpha</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isalpha"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the string is an alphabetic string, False otherwise.</p>
<p>A string is alphabetic if all characters in the string are alphabetic and there
<codeclass="sig-name descname">isdigit</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isdigit"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the string is a digit string, False otherwise.</p>
<p>A string is a digit string if all characters in the string are digits and there
<codeclass="sig-name descname">islower</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.islower"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the string is a lowercase string, False otherwise.</p>
<p>A string is lowercase if all cased characters in the string are lowercase and
there is at least one cased character in the string.</p>
<codeclass="sig-name descname">isspace</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isspace"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the string is a whitespace string, False otherwise.</p>
<p>A string is whitespace if all characters in the string are whitespace and there
<codeclass="sig-name descname">istitle</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.istitle"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the string is a title-cased string, False otherwise.</p>
<p>In a title-cased string, upper- and title-case characters may only
follow uncased characters and lowercase characters only cased ones.</p>
<codeclass="sig-name descname">isupper</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isupper"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the string is an uppercase string, False otherwise.</p>
<p>A string is uppercase if all cased characters in the string are uppercase and
there is at least one cased character in the string.</p>
<codeclass="sig-name descname">lower</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.lower"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a copy of the string converted to lowercase.</p>
<codeclass="sig-name descname">replace</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.replace"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a copy with all occurrences of substring old replaced by new.</p>
<blockquote>
<div><dlclass="simple">
<dt>count</dt><dd><p>Maximum number of occurrences to replace.
-1 (the default value) means replace all occurrences.</p>
</dd>
</dl>
</div></blockquote>
<p>If the optional argument count is given, only the first count occurrences are
<codeclass="sig-name descname">rfind</code><spanclass="sig-paren">(</span><emclass="sig-param">sub</em><spanclass="optional">[</span>, <emclass="sig-param">start</em><spanclass="optional">[</span>, <emclass="sig-param">end</em><spanclass="optional">]</span><spanclass="optional">]</span><spanclass="sig-paren">)</span>→ int<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.rfind"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.</p>
<codeclass="sig-name descname">rindex</code><spanclass="sig-paren">(</span><emclass="sig-param">sub</em><spanclass="optional">[</span>, <emclass="sig-param">start</em><spanclass="optional">[</span>, <emclass="sig-param">end</em><spanclass="optional">]</span><spanclass="optional">]</span><spanclass="sig-paren">)</span>→ int<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.rindex"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.</p>
<p>Raises ValueError when the substring is not found.</p>
<codeclass="sig-name descname">rstrip</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">chars</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.rstrip"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.rstrip"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">startswith</code><spanclass="sig-paren">(</span><emclass="sig-param">prefix</em><spanclass="optional">[</span>, <emclass="sig-param">start</em><spanclass="optional">[</span>, <emclass="sig-param">end</em><spanclass="optional">]</span><spanclass="optional">]</span><spanclass="sig-paren">)</span>→ bool<aclass="headerlink"href="#evennia.utils.ansi.ANSIString.startswith"title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
<codeclass="sig-name descname">swapcase</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.swapcase"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert uppercase characters to lowercase and lowercase characters to uppercase.</p>
<codeclass="sig-name descname">translate</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.translate"title="Permalink to this definition">¶</a></dt>
<dd><p>Replace each character in the string using the given translation table.</p>
<blockquote>
<div><dlclass="simple">
<dt>table</dt><dd><p>Translation table, which must be a mapping of Unicode ordinals to
Unicode ordinals, strings, or None.</p>
</dd>
</dl>
</div></blockquote>
<p>The table must implement lookup/indexing via __getitem__, for instance a
dictionary or list. If this operation raises LookupError, the character is
left untouched. Characters mapped to None are deleted.</p>
<codeclass="sig-name descname">upper</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.upper"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a copy of the string converted to uppercase.</p>
<codeclass="sig-name descname">join</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">iterable</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.join"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.join"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">center</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">width</span></em>, <emclass="sig-param"><spanclass="n">fillchar</span></em>, <emclass="sig-param"><spanclass="n">_difference</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.center"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.center"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">ljust</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">width</span></em>, <emclass="sig-param"><spanclass="n">fillchar</span></em>, <emclass="sig-param"><spanclass="n">_difference</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.ljust"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.ljust"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">rjust</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">width</span></em>, <emclass="sig-param"><spanclass="n">fillchar</span></em>, <emclass="sig-param"><spanclass="n">_difference</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString.rjust"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.rjust"title="Permalink to this definition">¶</a></dt>