<spanid="evennia-utils-package"></span><h1>evennia.utils package<aclass="headerlink"href="#module-evennia.utils"title="Permalink to this headline">¶</a></h1>
<p>This sub-package holds the miscelaneous utilities used by other
modules in Evennia. It also holds the idmapper in-memory caching
functionality.</p>
<divclass="section"id="subpackages">
<h2>Subpackages<aclass="headerlink"href="#subpackages"title="Permalink to this headline">¶</a></h2>
<spanid="evennia-utils-ansi-module"></span><h2>evennia.utils.ansi module<aclass="headerlink"href="#module-evennia.utils.ansi"title="Permalink to this headline">¶</a></h2>
<p>ANSI - Gives colour to text.</p>
<p>Use the codes defined in ANSIPARSER in your text
to apply colour to text according to the ANSI standard.</p>
<pclass="rubric">Examples</p>
<p>This is <ahref="#id1"><spanclass="problematic"id="id2">|</span></a>rRed text|n and this is normal again.</p>
<p>Mostly you should not need to call parse_ansi() explicitly;
it is run by Evennia just before returning data to/from the
user. Depreciated example forms are available by extending
the ansi mapping.</p>
<dlclass="class">
<dtid="evennia.utils.ansi.ANSIMeta">
<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">*args</em>, <emclass="sig-param">**kwargs</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>
<p>Many functions on ANSIString are just light wrappers around the string
base class. We apply them here, as part of the classes construction.</p>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIMeta.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</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>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.ansi.ANSIParser">
<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">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">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>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.ansi.ANSIParser.ansi_regex">
<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>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.ansi.ANSIParser.ansi_sub">
<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">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>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.ansi.ANSIParser.mxp_re">
<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>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.ansi.ANSIParser.mxp_sub">
<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>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIParser.parse_ansi">
<codeclass="sig-name descname">parse_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">strip_ansi=False</em>, <emclass="sig-param">xterm256=False</em>, <emclass="sig-param">mxp=False</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>
<dd><p>Parses a string, subbing color codes according to the stored
mapping.</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>strip_ansi</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Strip all found ansi markup.</p></li>
<li><p><strong>xterm256</strong> (<em>boolean</em><em>, </em><em>optional</em>) – If actually using xterm256 or if
these values should be converted to 16-color ANSI.</p></li>
<li><p><strong>mxp</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Parse MXP commands in string.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The parsed string.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>string (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIParser.strip_mxp">
<codeclass="sig-name descname">strip_mxp</code><spanclass="sig-paren">(</span><emclass="sig-param">string</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>
<dd><p>Strips all MXP codes from a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>string</strong> (<em>str</em>) – The string to strip.</p>
<codeclass="sig-name descname">strip_raw_codes</code><spanclass="sig-paren">(</span><emclass="sig-param">string</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>
<dd><p>Strips raw ANSI codes from a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>string</strong> (<em>str</em>) – The string to strip.</p>
<codeclass="sig-name descname">sub_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param">ansimatch</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>
<dd><p>Replacer used by <cite>re.sub</cite> to replace ANSI
markers with correct ANSI sequences</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>ansimatch</strong> (<em>re.matchobject</em>) – The match.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The processed match string.</p>
<codeclass="sig-name descname">sub_brightbg</code><spanclass="sig-paren">(</span><emclass="sig-param">ansimatch</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>
<dd><p>Replacer used by <cite>re.sub</cite> to replace ANSI
bright background markers with Xterm256 replacement</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>ansimatch</strong> (<em>re.matchobject</em>) – The match.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The processed match string.</p>
<codeclass="sig-name descname">sub_xterm256</code><spanclass="sig-paren">(</span><emclass="sig-param">rgbmatch</em>, <emclass="sig-param">use_xterm256=False</em>, <emclass="sig-param">color_type='fg'</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>
<dd><p>This is a replacer method called by <cite>re.sub</cite> with the matched
tag. It must return the correct ansi sequence.</p>
<p>It checks <cite>self.do_xterm256</cite> to determine if conversion
to standard ANSI should be done or not.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>rgbmatch</strong> (<em>re.matchobject</em>) – The match.</p></li>
<li><p><strong>use_xterm256</strong> (<em>bool</em><em>, </em><em>optional</em>) – Don’t convert 256-colors to 16.</p></li>
<li><p><strong>color_type</strong> (<em>str</em>) – One of ‘fg’, ‘bg’, ‘gfg’, ‘gbg’.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The processed match string.</p>
<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_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_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_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_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">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">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_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>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.ansi.ANSIString">
<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">*_</em>, <emclass="sig-param">**kwargs</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>
<p>Unicode-like object that is aware of ANSI codes.</p>
<p>This class can be used nearly identically to strings, in that it will
report string length, handle slices, etc, much like a string object
would. The methods should be used identically as string methods are.</p>
<p>There is at least one exception to this (and there may be more, though
they have not come up yet). When using ‘’.join() or u’’.join() on an
ANSIString, color information will get lost. You must use
ANSIString(‘’).join() to preserve color information.</p>
<p>This implementation isn’t perfectly clean, as it doesn’t really have an
understanding of what the codes mean in order to eliminate
redundant characters– though cleaning up the strings might end up being
inefficient and slow without some C code when dealing with larger values.
Such enhancements could be made as an enhancement to ANSI_PARSER
if needed, however.</p>
<p>If one is going to use ANSIString, one should generally avoid converting
away from it until one is about to send information on the wire. This is
because escape sequences in the string may otherwise already be decoded,
and taken literally the second time around.</p>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*_</em>, <emclass="sig-param">**kwargs</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>
<dd><p>When the ANSIString is first initialized, a few internal variables
have to be set.</p>
<p>The first is the parser. It is possible to replace Evennia’s standard
ANSI parser with one of your own syntax if you wish, so long as it
implements the same interface.</p>
<p>The second is the _raw_string. This is the original “dumb” string
with ansi escapes that ANSIString represents.</p>
<p>The third thing to set is the _clean_string. This is a string that is
devoid of all ANSI Escapes.</p>
<p>Finally, _code_indexes and _char_indexes are defined. These are lookup
tables for which characters in the raw string are related to ANSI
escapes, and which are for the readable text.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString._adder">
<emclass="property">classmethod </em><codeclass="sig-name descname">_adder</code><spanclass="sig-paren">(</span><emclass="sig-param">first</em>, <emclass="sig-param">second</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString._adder"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString._adder"title="Permalink to this definition">¶</a></dt>
<dd><p>Joins two ANSIStrings, preserving calculated info.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString._filler">
<codeclass="sig-name descname">_filler</code><spanclass="sig-paren">(</span><emclass="sig-param">char</em>, <emclass="sig-param">amount</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString._filler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString._filler"title="Permalink to this definition">¶</a></dt>
<dd><p>Generate a line of characters in a more efficient way than just adding
<codeclass="sig-name descname">_get_indexes</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString._get_indexes"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString._get_indexes"title="Permalink to this definition">¶</a></dt>
<dd><p>Two tables need to be made, one which contains the indexes of all
readable characters, and one which contains the indexes of all ANSI
escapes. It’s important to remember that ANSI escapes require more
that one character at a time, though no readable character needs more
than one character, since the string base class abstracts that away
from us. However, several readable characters can be placed in a row.</p>
<p>We must use regexes here to figure out where all the escape sequences
are hiding in the string. Then we use the ranges of their starts and
ends to create a final, comprehensive list of all indexes which are
dedicated to code, and all dedicated to text.</p>
<p>It’s possible that only one of these tables is actually needed, the
<codeclass="sig-name descname">_get_interleving</code><spanclass="sig-paren">(</span><emclass="sig-param">index</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString._get_interleving"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString._get_interleving"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the code characters from the given slice end to the next
character.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString._shifter">
<emclass="property">static </em><codeclass="sig-name descname">_shifter</code><spanclass="sig-paren">(</span><emclass="sig-param">iterable</em>, <emclass="sig-param">offset</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString._shifter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString._shifter"title="Permalink to this definition">¶</a></dt>
<dd><p>Takes a list of integers, and produces a new one incrementing all
by a number.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString._slice">
<codeclass="sig-name descname">_slice</code><spanclass="sig-paren">(</span><emclass="sig-param">slc</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#ANSIString._slice"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.ANSIString._slice"title="Permalink to this definition">¶</a></dt>
<dd><p>This function takes a slice() object.</p>
<p>Slices have to be handled specially. Not only are they able to specify
a start and end with [x:y], but many forget that they can also specify
an interval with [x:y:z]. As a result, not only do we have to track
the ANSI Escapes that have played before the start of the slice, we
must also replay any in these intervals, should they exist.</p>
<p>Thankfully, slicing the _char_indexes table gives us the actual
indexes that need slicing in the raw string. We can check between
those indexes to figure out what escape characters need to be
replayed.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.capitalize">
<codeclass="sig-name descname">capitalize</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.capitalize"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.center">
<codeclass="sig-name descname">center</code><spanclass="sig-paren">(</span><emclass="sig-param">width</em>, <emclass="sig-param">fillchar</em>, <emclass="sig-param">_difference</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>
<dd><p>Center some text with some spaces padding both sides.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>width</strong> (<em>int</em>) – The target width of the output string.</p></li>
<li><p><strong>fillchar</strong> (<em>str</em>) – A single character string to pad the output string
with.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A string padded on both ends with fillchar.</p>
<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>A unicode object with no ANSI escapes.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>clean_string (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.count">
<codeclass="sig-name descname">count</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.count"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.decode">
<codeclass="sig-name descname">decode</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.decode"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.encode">
<codeclass="sig-name descname">encode</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.encode"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.endswith">
<codeclass="sig-name descname">endswith</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.endswith"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.expandtabs">
<codeclass="sig-name descname">expandtabs</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.expandtabs"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.find">
<codeclass="sig-name descname">find</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.find"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.format">
<codeclass="sig-name descname">format</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.format"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.index">
<codeclass="sig-name descname">index</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.index"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.isalnum">
<codeclass="sig-name descname">isalnum</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isalnum"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.isalpha">
<codeclass="sig-name descname">isalpha</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isalpha"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.isdigit">
<codeclass="sig-name descname">isdigit</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isdigit"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.islower">
<codeclass="sig-name descname">islower</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.islower"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.isspace">
<codeclass="sig-name descname">isspace</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isspace"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.istitle">
<codeclass="sig-name descname">istitle</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.istitle"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.isupper">
<codeclass="sig-name descname">isupper</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.isupper"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.join">
<codeclass="sig-name descname">join</code><spanclass="sig-paren">(</span><emclass="sig-param">iterable</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>
<dd><p>Joins together strings in an iterable, using this string between each
one.</p>
<dlclass="simple">
<dt>NOTE: This should always be used for joining strings when ANSIStrings</dt><dd><p>are involved. Otherwise color information will be discarded by
python, due to details in the C implementation of strings.</p>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>iterable</strong> (<em>list of strings</em>) – A list of strings to join together</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dl>
<dt>A single string with all of the iterable’s</dt><dd><p>contents concatenated, with this string between each. For
<codeclass="sig-name descname">ljust</code><spanclass="sig-paren">(</span><emclass="sig-param">width</em>, <emclass="sig-param">fillchar</em>, <emclass="sig-param">_difference</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>
<dd><p>Left justify some text.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>width</strong> (<em>int</em>) – The target width of the output string.</p></li>
<li><p><strong>fillchar</strong> (<em>str</em>) – A single character string to pad the output string
with.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A string padded on the right with fillchar.</p>
<codeclass="sig-name descname">lower</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.lower"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.lstrip">
<codeclass="sig-name descname">lstrip</code><spanclass="sig-paren">(</span><emclass="sig-param">chars=None</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>
<dd><p>Strip from the left, taking ANSI markers into account.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>chars</strong> (<em>str</em><em>, </em><em>optional</em>) – A string containing individual characters
to strip off of the left end of the string. By default, any
blank spaces are trimmed.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A new ANSIString with the left end trimmed of</dt><dd><p>the relevant characters.</p>
<codeclass="sig-name descname">partition</code><spanclass="sig-paren">(</span><emclass="sig-param">sep</em>, <emclass="sig-param">reverse=False</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>
<dd><p>Splits once into three sections (with the separator being the middle section)</p>
<p>We use the same techniques we used in split() to make sure each are
colored.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>sep</strong> (<em>str</em>) – The separator to split the string on.</p></li>
<li><p><strong>reverse</strong> (<em>boolean</em>) – Whether to split the string on the last
occurrence of the separator rather than the first.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>prefix (ANSIString): The part of the string before the</dt><dd><p>separator</p>
</dd>
</dl>
<p>sep (ANSIString): The separator itself
postfix (ANSIString): The part of the string after the</p>
<blockquote>
<div><p>separator.</p>
</div></blockquote>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>result (tuple)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.raw">
<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>A unicode object <em>with</em> the raw ANSI escape sequences.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>raw (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.ansi.ANSIString.re_format">
<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>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.replace">
<codeclass="sig-name descname">replace</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.replace"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.rfind">
<codeclass="sig-name descname">rfind</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.rfind"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.rindex">
<codeclass="sig-name descname">rindex</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.rindex"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.rjust">
<codeclass="sig-name descname">rjust</code><spanclass="sig-paren">(</span><emclass="sig-param">width</em>, <emclass="sig-param">fillchar</em>, <emclass="sig-param">_difference</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>
<dd><p>Right justify some text.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>width</strong> (<em>int</em>) – The target width of the output string.</p></li>
<li><p><strong>fillchar</strong> (<em>str</em>) – A single character string to pad the output string
with.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A string padded on the left with fillchar.</p>
<codeclass="sig-name descname">rsplit</code><spanclass="sig-paren">(</span><emclass="sig-param">by=None</em>, <emclass="sig-param">maxsplit=-1</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>
<dd><p>Like split, but starts from the end of the string rather than the
beginning.</p>
<p>Stolen from PyPy’s pure Python string implementation, tweaked for
<li><p><strong>by</strong> (<em>str</em>) – A string to search for which will be used to split
the string. For instance, ‘,’ for ‘Hello,world’ would
result in [‘Hello’, ‘world’]</p></li>
<li><p><strong>maxsplit</strong> (<em>int</em>) – The maximum number of times to split the string.
For example, a maxsplit of 2 with a by of ‘,’ on the string
‘Hello,world,test,string’ would result in
[‘Hello,world’, ‘test’, ‘string’]</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A list of ANSIStrings derived from</dt><dd><p>this string.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>result (list of ANSIStrings)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.rstrip">
<codeclass="sig-name descname">rstrip</code><spanclass="sig-paren">(</span><emclass="sig-param">chars=None</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>
<dd><p>Strip from the right, taking ANSI markers into account.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>chars</strong> (<em>str</em><em>, </em><em>optional</em>) – A string containing individual characters
to strip off of the right end of the string. By default, any
blank spaces are trimmed.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A new ANSIString with the right end trimmed of</dt><dd><p>the relevant characters.</p>
<codeclass="sig-name descname">split</code><spanclass="sig-paren">(</span><emclass="sig-param">by=None</em>, <emclass="sig-param">maxsplit=-1</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>
<dd><p>Splits a string based on a separator.</p>
<p>Stolen from PyPy’s pure Python string implementation, tweaked for
<li><p><strong>by</strong> (<em>str</em>) – A string to search for which will be used to split
the string. For instance, ‘,’ for ‘Hello,world’ would
result in [‘Hello’, ‘world’]</p></li>
<li><p><strong>maxsplit</strong> (<em>int</em>) – The maximum number of times to split the string.
For example, a maxsplit of 2 with a by of ‘,’ on the string
‘Hello,world,test,string’ would result in
[‘Hello’, ‘world’, ‘test,string’]</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A list of ANSIStrings derived from</dt><dd><p>this string.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>result (list of ANSIStrings)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.startswith">
<codeclass="sig-name descname">startswith</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.startswith"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.strip">
<codeclass="sig-name descname">strip</code><spanclass="sig-paren">(</span><emclass="sig-param">chars=None</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>
<dd><p>Strip from both ends, taking ANSI markers into account.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>chars</strong> (<em>str</em><em>, </em><em>optional</em>) – A string containing individual characters
to strip off of both ends of the string. By default, any blank
spaces are trimmed.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A new ANSIString with the ends trimmed of the</dt><dd><p>relevant characters.</p>
<codeclass="sig-name descname">swapcase</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.swapcase"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.translate">
<codeclass="sig-name descname">translate</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.translate"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.ansi.ANSIString.upper">
<codeclass="sig-name descname">upper</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.ansi.ANSIString.upper"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.ansi._on_raw">
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">_on_raw</code><spanclass="sig-paren">(</span><emclass="sig-param">func_name</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#_on_raw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi._on_raw"title="Permalink to this definition">¶</a></dt>
<dd><p>Like query_super, but makes the operation run on the raw string.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.ansi._query_super">
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">_query_super</code><spanclass="sig-paren">(</span><emclass="sig-param">func_name</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#_query_super"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi._query_super"title="Permalink to this definition">¶</a></dt>
<dd><p>Have the string class handle this with the cleaned string instead
of ANSIString.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.ansi._spacing_preflight">
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">_spacing_preflight</code><spanclass="sig-paren">(</span><emclass="sig-param">func</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#_spacing_preflight"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi._spacing_preflight"title="Permalink to this definition">¶</a></dt>
<dd><p>This wrapper function is used to do some preflight checks on
functions used for padding ANSIStrings.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.ansi._transform">
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">_transform</code><spanclass="sig-paren">(</span><emclass="sig-param">func_name</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#_transform"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi._transform"title="Permalink to this definition">¶</a></dt>
<dd><p>Some string functions, like those manipulating capital letters,
return a string the same length as the original. This function
allows us to do the same, replacing all the non-coded characters
with the resulting string.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.ansi.parse_ansi">
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">parse_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">strip_ansi=False</em>, <emclass="sig-param">parser=<evennia.utils.ansi.ANSIParser object></em>, <emclass="sig-param">xterm256=False</em>, <emclass="sig-param">mxp=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/ansi.html#parse_ansi"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.ansi.parse_ansi"title="Permalink to this definition">¶</a></dt>
<dd><p>Parses a string, subbing color codes as needed.</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>strip_ansi</strong> (<em>bool</em><em>, </em><em>optional</em>) – Strip all ANSI sequences.</p></li>
<li><p><strong>parser</strong> (<em>ansi.AnsiParser</em><em>, </em><em>optional</em>) – A parser instance to use.</p></li>
<li><p><strong>xterm256</strong> (<em>bool</em><em>, </em><em>optional</em>) – Support xterm256 or not.</p></li>
<li><p><strong>mxp</strong> (<em>bool</em><em>, </em><em>optional</em>) – Support MXP markup or not.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The parsed string.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>string (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.ansi.raw">
<codeclass="sig-prename descclassname">evennia.utils.ansi.</code><codeclass="sig-name descname">raw</code><spanclass="sig-paren">(</span><emclass="sig-param">string</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>
<dd><p>Escapes a string into a form which won’t be colorized by the ansi
<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>The stripped string.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>string (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.ansi.strip_raw_ansi">
<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>
<spanid="evennia-utils-batchprocessors-module"></span><h2>evennia.utils.batchprocessors module<aclass="headerlink"href="#module-evennia.utils.batchprocessors"title="Permalink to this headline">¶</a></h2>
<p>This module contains the core methods for the Batch-command- and
Batch-code-processors respectively. In short, these are two different
ways to build a game world using a normal text-editor without having
to do so ‘on the fly’ in-game. They also serve as an automatic backup
so you can quickly recreate a world also after a server reset. The
functions in this module is meant to form the backbone of a system
called and accessed through game commands.</p>
<p>The Batch-command processor is the simplest. It simply runs a list of
in-game commands in sequence by reading them from a text file. The
advantage of this is that the builder only need to remember the normal
in-game commands. They are also executing with full permission checks
etc, making it relatively safe for builders to use. The drawback is
that in-game there is really a builder-character walking around
building things, and it can be important to create rooms and objects
in the right order, so the character can move between them. Also
objects that affects players (such as mobs, dark rooms etc) will
affect the building character too, requiring extra care to turn
off/on.</p>
<p>The Batch-code processor is a more advanced system that accepts full
Python code, executing in chunks. The advantage of this is much more
power; practically anything imaginable can be coded and handled using
the batch-code processor. There is no in-game character that moves and
that can be affected by what is being built - the database is
populated on the fly. The drawback is safety and entry threshold - the
code is executed as would any server code, without mud-specific
permission-checks, and you have full access to modifying objects
etc. You also need to know Python and Evennia’s API. Hence it’s
recommended that the batch-code processor is limited only to
<p>An example batch file is <cite>contrib/examples/batch_example.ev</cite>.</p>
<hrclass="docutils"/>
<p>Batch-code processor file syntax</p>
<p>The Batch-code processor accepts full python modules (e.g. <cite>batch.py</cite>)
that looks identical to normal Python files. The difference from
importing and running any Python module is that the batch-code module
is loaded as a file and executed directly, so changes to the file will
apply immediately without a server @reload.</p>
<p>Optionally, one can add some special commented tokens to split the
execution of the code for the benefit of the batchprocessor’s
interactive- and debug-modes. This allows to conveniently step through
the code and re-run sections of it easily during development.</p>
<p>Code blocks are marked by commented tokens alone on a line:</p>
<dlclass="simple">
<dt>#HEADER - This denotes code that should be pasted at the top of all</dt><dd><p>other code. Multiple HEADER statements - regardless of where
it exists in the file - is the same as one big block.
Observe that changes to variables made in one block is not
preserved between blocks!</p>
</dd>
<dt>#CODE - This designates a code block that will be executed like a</dt><dd><p>stand-alone piece of code together with any HEADER(s)
defined. It is mainly used as a way to mark stop points for
the interactive mode of the batchprocessor. If no CODE block
is defined in the module, the entire module (including HEADERS)
is assumed to be a CODE block.</p>
</dd>
<dt>#INSERT path.filename - This imports another batch_code.py file and</dt><dd><p>runs it in the given position. The inserted file will retain
its own HEADERs which will not be mixed with the headers of
this file.</p>
</dd>
</dl>
<p>Importing works as normal. The following variables are automatically
made available in the script namespace.</p>
<ulclass="simple">
<li><p><cite>caller</cite> - The object executing the batchscript</p></li>
<li><dlclass="simple">
<dt><cite>DEBUG</cite> - This is a boolean marking if the batchprocessor is running</dt><dd><p>in debug mode. It can be checked to e.g. delete created objects
when running a CODE block multiple times during testing.
(avoids creating a slew of same-named db objects)</p>
</dd>
</dl>
</li>
</ul>
</div>
<divclass="section"id="example-batch-py-file">
<h3>Example batch.py file<aclass="headerlink"href="#example-batch-py-file"title="Permalink to this headline">¶</a></h3>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.batchprocessors.</code><codeclass="sig-name descname">BatchCodeProcessor</code><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#BatchCodeProcessor"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.BatchCodeProcessor"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">code_exec</code><spanclass="sig-paren">(</span><emclass="sig-param">code</em>, <emclass="sig-param">extra_environ=None</em>, <emclass="sig-param">debug=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#BatchCodeProcessor.code_exec"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.BatchCodeProcessor.code_exec"title="Permalink to this definition">¶</a></dt>
<dd><p>Execute a single code block, including imports and appending
global vars.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>code</strong> (<em>str</em>) – Code to run.</p></li>
<li><p><strong>extra_environ</strong> (<em>dict</em>) – Environment variables to run with code.</p></li>
<li><p><strong>debug</strong> (<em>bool</em><em>, </em><em>optional</em>) – Set the DEBUG variable in the execution
namespace.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An error code or None (ok).</p>
<codeclass="sig-name descname">parse_file</code><spanclass="sig-paren">(</span><emclass="sig-param">pythonpath</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#BatchCodeProcessor.parse_file"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.BatchCodeProcessor.parse_file"title="Permalink to this definition">¶</a></dt>
<dd><p>This parses the lines of a batchfile according to the following
rules:</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>pythonpath</strong> (<em>str</em>) – The dot-python path to the file.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A list of all #CODE blocks, each with</dt><dd><p>prepended #HEADER data. If no #CODE blocks were found,
this will be a list of one element.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>codeblocks (list)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<olclass="arabic simple">
<li><dlclass="simple">
<dt>Code before a #CODE/HEADER block are considered part of</dt><dd><p>the first code/header block or is the ONLY block if no
#CODE/HEADER blocks are defined.</p>
</dd>
</dl>
</li>
<li><p>Lines starting with #HEADER starts a header block (ends other blocks)</p></li>
<li><p>Lines starting with #CODE begins a code block (ends other blocks)</p></li>
<li><p>Lines starting with #INSERT are on form #INSERT filename. Code from
this file are processed with their headers <em>separately</em> before
being inserted at the point of the #INSERT.</p></li>
<li><p>Code after the last block is considered part of the last header/code
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.batchprocessors.</code><codeclass="sig-name descname">BatchCommandProcessor</code><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#BatchCommandProcessor"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.BatchCommandProcessor"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">parse_file</code><spanclass="sig-paren">(</span><emclass="sig-param">pythonpath</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#BatchCommandProcessor.parse_file"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.BatchCommandProcessor.parse_file"title="Permalink to this definition">¶</a></dt>
<dd><p>This parses the lines of a batchfile according to the following
rules:</p>
<blockquote>
<div><olclass="arabic simple">
<li><dlclass="simple">
<dt># at the beginning of a line marks the end of the command before</dt><dd><p>it. It is also a comment and any number of # can exist on
subsequent lines (but not inside comments).</p>
</dd>
</dl>
</li>
<li><p>#INSERT at the beginning of a line imports another
batch-cmd file file and pastes it into the batch file as if
it was written there.</p></li>
<li><p>Commands are placed alone at the beginning of a line and their
arguments are considered to be everything following (on any
number of lines) until the next comment line beginning with #.</p></li>
<li><p>Newlines are ignored in command definitions</p></li>
<li><p>A completely empty line in a command line definition is condered
a newline (so two empty lines is a paragraph).</p></li>
<li><p>Excess spaces and indents inside arguments are stripped.</p></li>
<codeclass="sig-prename descclassname">evennia.utils.batchprocessors.</code><codeclass="sig-name descname">read_batchfile</code><spanclass="sig-paren">(</span><emclass="sig-param">pythonpath</em>, <emclass="sig-param">file_ending='.py'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#read_batchfile"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.read_batchfile"title="Permalink to this definition">¶</a></dt>
<dd><p>This reads the contents of a batch-file. Filename is considered
to be a python path to a batch file relative the directory
specified in <cite>settings.py</cite>.</p>
<p>file_ending specify which batchfile ending should be assumed (.ev
or .py). The ending should not be included in the python path.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>pythonpath</strong> (<em>str</em>) – A dot-python path to a file.</p></li>
<li><p><strong>file_ending</strong> (<em>str</em>) – The file ending of this file (.ev or .py)</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The text content of the batch file.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>IOError</strong>– If problems reading file.</p>
<codeclass="sig-prename descclassname">evennia.utils.batchprocessors.</code><codeclass="sig-name descname">tb_filename</code><spanclass="sig-paren">(</span><emclass="sig-param">tb</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#tb_filename"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.tb_filename"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper to get filename from traceback</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.batchprocessors.tb_iter">
<codeclass="sig-prename descclassname">evennia.utils.batchprocessors.</code><codeclass="sig-name descname">tb_iter</code><spanclass="sig-paren">(</span><emclass="sig-param">tb</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/batchprocessors.html#tb_iter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.batchprocessors.tb_iter"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-containers-module"></span><h2>evennia.utils.containers module<aclass="headerlink"href="#module-evennia.utils.containers"title="Permalink to this headline">¶</a></h2>
<p>Containers</p>
<p>Containers are storage classes usually initialized from a setting. They
represent Singletons and acts as a convenient place to find resources (
available as properties on the singleton)</p>
<p>evennia.GLOBAL_SCRIPTS
evennia.OPTION_CLASSES</p>
<dlclass="class">
<dtid="evennia.utils.containers.Container">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.containers.</code><codeclass="sig-name descname">Container</code><aclass="reference internal"href="../_modules/evennia/utils/containers.html#Container"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.Container"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#Container.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.Container.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Read data from module.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.containers.Container.all">
<codeclass="sig-name descname">all</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#Container.all"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.Container.all"title="Permalink to this definition">¶</a></dt>
<dd><p>Get all stored data</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>All global script objects stored on the container.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>scripts (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.containers.Container.get">
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">default=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#Container.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.Container.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrive data by key (in case of not knowing it beforehand).</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em>) – The name of the script.</p></li>
<li><p><strong>default</strong> (<em>any</em><em>, </em><em>optional</em>) – Value to return if key is not found.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The data loaded on this container.</p>
<codeclass="sig-name descname">load_data</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#Container.load_data"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.Container.load_data"title="Permalink to this definition">¶</a></dt>
<dd><p>Delayed import to avoid eventual circular imports from inside
<codeclass="sig-name descname">storage_modules</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.utils.containers.Container.storage_modules"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.containers.</code><codeclass="sig-name descname">GlobalScriptContainer</code><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Note: We must delay loading of typeclasses since this module may get
initialized before Scripts are actually initialized.</p>
<codeclass="sig-name descname">_get_scripts</code><spanclass="sig-paren">(</span><emclass="sig-param">key=None</em>, <emclass="sig-param">default=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer._get_scripts"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer._get_scripts"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_load_script</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer._load_script"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer._load_script"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">all</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer.all"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer.all"title="Permalink to this definition">¶</a></dt>
<dd><p>Get all global scripts. Note that this will not auto-start
scripts defined in settings.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>All global script objects stored on the container.</p>
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">default=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrive data by key (in case of not knowing it beforehand). Any
scripts that are in settings.GLOBAL_SCRIPTS that are not found
will be recreated on-demand.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em>) – The name of the script.</p></li>
<li><p><strong>default</strong> (<em>any</em><em>, </em><em>optional</em>) – Value to return if key is not found
at all on this container (i.e it cannot be loaded at all).</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The data loaded on this container.</p>
<codeclass="sig-name descname">load_data</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer.load_data"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer.load_data"title="Permalink to this definition">¶</a></dt>
<dd><p>This delayed import avoids trying to load Scripts before they are
<codeclass="sig-name descname">start</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/containers.html#GlobalScriptContainer.start"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.GlobalScriptContainer.start"title="Permalink to this definition">¶</a></dt>
<dd><p>Called last in evennia.__init__ to initialize the container late
(after script typeclasses have finished loading).</p>
<p>We include all global scripts in the handler and
make sure to auto-load time-based scripts.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.containers.OptionContainer">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.containers.</code><codeclass="sig-name descname">OptionContainer</code><aclass="reference internal"href="../_modules/evennia/utils/containers.html#OptionContainer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.containers.OptionContainer"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">storage_modules</code><emclass="property"> = ['evennia.utils.optionclasses']</em><aclass="headerlink"href="#evennia.utils.containers.OptionContainer.storage_modules"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-create-module"></span><h2>evennia.utils.create module<aclass="headerlink"href="#module-evennia.utils.create"title="Permalink to this headline">¶</a></h2>
<p>This module gathers all the essential database-creation
functions for the game engine’s various object types.</p>
<p>Only objects created ‘stand-alone’ are in here, e.g. object Attributes
are always created directly through their respective objects.</p>
<p>Each creation_* function also has an alias named for the entity being
created, such as create_object() and object(). This is for
consistency with the utils.search module and allows you to do the
shorter “create.object()”.</p>
<p>The respective object managers hold more methods for manipulating and
searching objects already existing in the database.</p>
<dlclass="simple">
<dt>Models covered:</dt><dd><p>Objects
Scripts
Help
Message
Channel
Accounts</p>
</dd>
</dl>
<dlclass="function">
<dtid="evennia.utils.create.create_object">
<codeclass="sig-prename descclassname">evennia.utils.create.</code><codeclass="sig-name descname">create_object</code><spanclass="sig-paren">(</span><emclass="sig-param">typeclass=None</em>, <emclass="sig-param">key=None</em>, <emclass="sig-param">location=None</em>, <emclass="sig-param">home=None</em>, <emclass="sig-param">permissions=None</em>, <emclass="sig-param">locks=None</em>, <emclass="sig-param">aliases=None</em>, <emclass="sig-param">tags=None</em>, <emclass="sig-param">destination=None</em>, <emclass="sig-param">report_to=None</em>, <emclass="sig-param">nohome=False</em>, <emclass="sig-param">attributes=None</em>, <emclass="sig-param">nattributes=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/create.html#create_object"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.create.create_object"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new in-game object.</p>
<dl>
<dt>Kwargs:</dt><dd><p>typeclass (class or str): Class or python path to a typeclass.
key (str): Name of the new object. If not set, a name of</p>
<blockquote>
<div><p>#dbref will be set.</p>
</div></blockquote>
<dlclass="simple">
<dt>home (Object or str): Obj or #dbref to use as the object’s</dt><dd><p>home location.</p>
</dd>
</dl>
<p>permissions (list): A list of permission strings or tuples (permstring, category).
locks (str): one or more lockstrings, separated by semicolons.
aliases (list): A list of alternative keys or tuples (aliasstring, category).
tags (list): List of tag keys or tuples (tagkey, category) or (tagkey, category, data).
destination (Object or str): Obj or #dbref to use as an Exit’s</p>
<blockquote>
<div><p>target.</p>
</div></blockquote>
<p>report_to (Object): The object to return error messages to.
nohome (bool): This allows the creation of objects without a</p>
<blockquote>
<div><p>default home location; only used when creating the default
location itself or during unittests.</p>
</div></blockquote>
<dlclass="simple">
<dt>attributes (list): Tuples on the form (key, value) or (key, value, category),</dt><dd><dlclass="simple">
<dt>(key, value, lockstring) or (key, value, lockstring, default_access).</dt><dd><p>to set as Attributes on the new object.</p>
</dd>
</dl>
</dd>
<dt>nattributes (list): Non-persistent tuples on the form (key, value). Note that</dt><dd><p>adding this rarely makes sense since this data will not survive a reload.</p>
</dd>
</dl>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>A newly created object of the given typeclass.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>object (Object)</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><aclass="reference internal"href="evennia.objects.html#evennia.objects.models.ObjectDB.DoesNotExist"title="evennia.objects.models.ObjectDB.DoesNotExist"><strong>ObjectDB.DoesNotExist</strong></a>– If trying to create an Object with
<cite>location</cite> or <cite>home</cite> that can’t be found.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.create.create_script">
<codeclass="sig-prename descclassname">evennia.utils.create.</code><codeclass="sig-name descname">create_script</code><spanclass="sig-paren">(</span><emclass="sig-param">typeclass=None</em>, <emclass="sig-param">key=None</em>, <emclass="sig-param">obj=None</em>, <emclass="sig-param">account=None</em>, <emclass="sig-param">locks=None</em>, <emclass="sig-param">interval=None</em>, <emclass="sig-param">start_delay=None</em>, <emclass="sig-param">repeats=None</em>, <emclass="sig-param">persistent=None</em>, <emclass="sig-param">autostart=True</em>, <emclass="sig-param">report_to=None</em>, <emclass="sig-param">desc=None</em>, <emclass="sig-param">tags=None</em>, <emclass="sig-param">attributes=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/create.html#create_script"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.create.create_script"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new script. All scripts are a combination of a database
object that communicates with the database, and an typeclass that
‘decorates’ the database object into being different types of
scripts. It’s behaviour is similar to the game objects except
scripts has a time component and are more limited in scope.</p>
<dl>
<dt>Kwargs:</dt><dd><p>typeclass (class or str): Class or python path to a typeclass.
key (str): Name of the new object. If not set, a name of</p>
<blockquote>
<div><p>#dbref will be set.</p>
</div></blockquote>
<dlclass="simple">
<dt>obj (Object): The entity on which this Script sits. If this</dt><dd><p>is <cite>None</cite>, we are creating a “global” script.</p>
</dd>
<dt>account (Account): The account on which this Script sits. It is</dt><dd><p>exclusiv to <cite>obj</cite>.</p>
</dd>
</dl>
<p>locks (str): one or more lockstrings, separated by semicolons.
interval (int): The triggering interval for this Script, in</p>
<blockquote>
<div><p>seconds. If unset, the Script will not have a timing
component.</p>
</div></blockquote>
<dlclass="simple">
<dt>start_delay (bool): If <cite>True</cite>, will wait <cite>interval</cite> seconds</dt><dd><p>before triggering the first time.</p>
</dd>
<dt>repeats (int): The number of times to trigger before stopping.</dt><dd><p>If unset, will repeat indefinitely.</p>
</dd>
<dt>persistent (bool): If this Script survives a server shutdown</dt><dd><p>or not (all Scripts will survive a reload).</p>
</dd>
<dt>autostart (bool): If this Script will start immediately when</dt><dd><p>created or if the <cite>start</cite> method must be called explicitly.</p>
</dd>
</dl>
<p>report_to (Object): The object to return error messages to.
desc (str): Optional description of script
tags (list): List of tags or tuples (tag, category).
attributes (list): List if tuples (key, value) or (key, value, category)</p>
<blockquote>
<div><p>(key, value, lockstring) or (key, value, lockstring, default_access).</p>
</div></blockquote>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>An instance of the script created</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>script (obj)</p>
</dd>
</dl>
<p>See evennia.scripts.manager for methods to manipulate existing
scripts in the database.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.create.create_help_entry">
<codeclass="sig-prename descclassname">evennia.utils.create.</code><codeclass="sig-name descname">create_help_entry</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">entrytext</em>, <emclass="sig-param">category='General'</em>, <emclass="sig-param">locks=None</em>, <emclass="sig-param">aliases=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/create.html#create_help_entry"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.create.create_help_entry"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a static help entry in the help database. Note that Command
help entries are dynamic and directly taken from the __doc__
entries of the command. The database-stored help entries are
intended for more general help on the game, more extensive info,
in-game setting information and so on.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em>) – The name of the help entry.</p></li>
<li><p><strong>entrytext</strong> (<em>str</em>) – The body of te help entry</p></li>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The help category of the entry.</p></li>
<li><p><strong>locks</strong> (<em>str</em><em>, </em><em>optional</em>) – A lockstring to restrict access.</p></li>
<li><p><strong>aliases</strong> (<em>list of str</em>) – List of alternative (likely shorter) keynames.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A newly created help entry.</p>
<codeclass="sig-prename descclassname">evennia.utils.create.</code><codeclass="sig-name descname">create_message</code><spanclass="sig-paren">(</span><emclass="sig-param">senderobj</em>, <emclass="sig-param">message</em>, <emclass="sig-param">channels=None</em>, <emclass="sig-param">receivers=None</em>, <emclass="sig-param">locks=None</em>, <emclass="sig-param">header=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/create.html#create_message"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.create.create_message"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new communication Msg. Msgs represent a unit of
database-persistent communication between entites.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>senderobj</strong> (<em>Object</em><em> or </em><em>Account</em>) – The entity sending the Msg.</p></li>
<li><p><strong>message</strong> (<em>str</em>) – Text with the message. Eventual headers, titles
etc should all be included in this text string. Formatting
will be retained.</p></li>
<li><p><strong>channels</strong> (<em>Channel</em><em>, </em><em>key</em><em> or </em><em>list</em>) – A channel or a list of channels to
send to. The channels may be actual channel objects or their
unique key strings.</p></li>
<li><p><strong>receivers</strong> (<em>Object</em><em>, </em><em>Account</em><em>, </em><em>str</em><em> or </em><em>list</em>) – An Account/Object to send
to, or a list of them. May be Account objects or accountnames.</p></li>
<li><p><strong>header</strong> (<em>str</em>) – Mime-type or other optional information for the message</p></li>
</ul>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>The Comm system is created very open-ended, so it’s fully possible
to let a message both go to several channels and to several
receivers at the same time, it’s up to the command definitions to
limit this as desired.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.create.create_channel">
<codeclass="sig-prename descclassname">evennia.utils.create.</code><codeclass="sig-name descname">create_channel</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">aliases=None</em>, <emclass="sig-param">desc=None</em>, <emclass="sig-param">locks=None</em>, <emclass="sig-param">keep_log=True</em>, <emclass="sig-param">typeclass=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/create.html#create_channel"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.create.create_channel"title="Permalink to this definition">¶</a></dt>
<dd><p>Create A communication Channel. A Channel serves as a central hub
for distributing Msgs to groups of people without specifying the
receivers explicitly. Instead accounts may ‘connect’ to the channel
and follow the flow of messages. By default the channel allows
access to all old messages, but this can be turned off with the
keep_log switch.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>key</strong> (<em>str</em>) – This must be unique.</p>
</dd>
</dl>
<dl>
<dt>Kwargs:</dt><dd><p>aliases (list of str): List of alternative (likely shorter) keynames.
desc (str): A description of the channel, for use in listings.
locks (str): Lockstring.
keep_log (bool): Log channel throughput.
typeclass (str or class): The typeclass of the Channel (not</p>
<blockquote>
<div><p>often used).</p>
</div></blockquote>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>A newly created channel.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>channel (Channel)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.create.create_account">
<codeclass="sig-prename descclassname">evennia.utils.create.</code><codeclass="sig-name descname">create_account</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">email</em>, <emclass="sig-param">password</em>, <emclass="sig-param">typeclass=None</em>, <emclass="sig-param">is_superuser=False</em>, <emclass="sig-param">locks=None</em>, <emclass="sig-param">permissions=None</em>, <emclass="sig-param">tags=None</em>, <emclass="sig-param">attributes=None</em>, <emclass="sig-param">report_to=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/create.html#create_account"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.create.create_account"title="Permalink to this definition">¶</a></dt>
<dd><p>This creates a new account.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em>) – The account’s name. This should be unique.</p></li>
<li><p><strong>email</strong> (<em>str</em><em> or </em><em>None</em>) – Email on valid <aclass="reference external"href="mailto:addr%40addr.domain">addr<span>@</span>addr<span>.</span>domain</a> form. If
the empty string, will be set to None.</p></li>
<li><p><strong>password</strong> (<em>str</em>) – Password in cleartext.</p></li>
</ul>
</dd>
</dl>
<dl>
<dt>Kwargs:</dt><dd><p>typeclass (str): The typeclass to use for the account.
is_superuser (bool): Wether or not this account is to be a superuser
locks (str): Lockstring.
permission (list): List of permission strings.
tags (list): List of Tags on form <cite>(key, category[, data])</cite>
attributes (list): List of Attributes on form</p>
<blockquote>
<div><p><cite>(key, value [, category, [,lockstring [, default_pass]]])</cite></p>
</div></blockquote>
<dlclass="simple">
<dt>report_to (Object): An object with a msg() method to report</dt><dd><p>errors to. If not given, errors will be logged.</p>
</dd>
</dl>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>The newly created Account.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>Account</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>ValueError</strong>– If <cite>key</cite> already exists in database.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Usually only the server admin should need to be superuser, all
other access levels can be handled with more fine-grained
permissions or groups. A superuser bypasses all lock checking
operations and is thus not suitable for play-testing the game.</p>
<spanid="evennia-utils-dbserialize-module"></span><h2>evennia.utils.dbserialize module<aclass="headerlink"href="#module-evennia.utils.dbserialize"title="Permalink to this headline">¶</a></h2>
<p>This module handles serialization of arbitrary python structural data,
intended primarily to be stored in the database. It also supports
storing Django model instances (which plain pickle cannot do).</p>
<p>This serialization is used internally by the server, notably for
storing data in Attributes and for piping data to process pools.</p>
<p>The purpose of dbserialize is to handle all forms of data. For
well-structured non-arbitrary exchange, such as communicating with a
rich web client, a simpler JSON serialization makes more sense.</p>
<p>This module also implements the <cite>SaverList</cite>, <cite>SaverDict</cite> and <cite>SaverSet</cite>
classes. These are iterables that track their position in a nested
structure and makes sure to send updates up to their root. This is
used by Attributes - without it, one would not be able to update mutables
in-situ, e.g <cite>obj.db.mynestedlist[3][5] = 3</cite> would never be saved and
be out of sync with the database.</p>
<dlclass="function">
<dtid="evennia.utils.dbserialize.to_pickle">
<codeclass="sig-prename descclassname">evennia.utils.dbserialize.</code><codeclass="sig-name descname">to_pickle</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/dbserialize.html#to_pickle"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.dbserialize.to_pickle"title="Permalink to this definition">¶</a></dt>
<dd><p>This prepares data on arbitrary form to be pickled. It handles any
nested structure and returns data on a form that is safe to pickle
(including having converted any database models to their internal
representation). We also convert any Saver*-type objects back to
their normal representations, they are not pickle-safe.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong> (<em>any</em>) – Data to pickle.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Pickled data.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>data (any)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.dbserialize.from_pickle">
<codeclass="sig-prename descclassname">evennia.utils.dbserialize.</code><codeclass="sig-name descname">from_pickle</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em>, <emclass="sig-param">db_obj=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/dbserialize.html#from_pickle"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.dbserialize.from_pickle"title="Permalink to this definition">¶</a></dt>
<dd><p>This should be fed a just de-pickled data object. It will be converted back
to a form that may contain database objects again. Note that if a database
object was removed (or changed in-place) in the database, None will be
returned.</p>
<dl>
<dt><ahref="#id219"><spanclass="problematic"id="id220">Args_</span></a></dt><dd><p>data (any): Pickled data to unpickle.
db_obj (Atribute, any): This is the model instance (normally</p>
<blockquote>
<div><p>an Attribute) that _Saver*-type iterables (_SaverList etc)
will save to when they update. It must have a ‘value’ property
that saves assigned data to the database. Skip if not
serializing onto a given object. If db_obj is given, this
function will convert lists, dicts and sets to their
_SaverList, _SaverDict and _SaverSet counterparts.</p>
</div></blockquote>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Unpickled data.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>data (any)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.dbserialize.do_pickle">
<codeclass="sig-prename descclassname">evennia.utils.dbserialize.</code><codeclass="sig-name descname">do_pickle</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/dbserialize.html#do_pickle"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.dbserialize.do_pickle"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform pickle to string</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.dbserialize.do_unpickle">
<codeclass="sig-prename descclassname">evennia.utils.dbserialize.</code><codeclass="sig-name descname">do_unpickle</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/dbserialize.html#do_unpickle"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.dbserialize.do_unpickle"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve pickle from pickled string</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.dbserialize.dbserialize">
<codeclass="sig-prename descclassname">evennia.utils.dbserialize.</code><codeclass="sig-name descname">dbserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/dbserialize.html#dbserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.dbserialize.dbserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Serialize to pickled form in one step</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.dbserialize.dbunserialize">
<codeclass="sig-prename descclassname">evennia.utils.dbserialize.</code><codeclass="sig-name descname">dbunserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em>, <emclass="sig-param">db_obj=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/dbserialize.html#dbunserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.dbserialize.dbunserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Un-serialize in one step. See from_pickle for help db_obj.</p>
<spanid="evennia-utils-eveditor-module"></span><h2>evennia.utils.eveditor module<aclass="headerlink"href="#module-evennia.utils.eveditor"title="Permalink to this headline">¶</a></h2>
<p>EvEditor (Evennia Line Editor)</p>
<p>This implements an advanced line editor for editing longer texts
in-game. The editor mimics the command mechanisms of the “VI” editor
(a famous line-by-line editor) as far as reasonable.</p>
<p>Features of the editor:</p>
<blockquote>
<div><ulclass="simple">
<li><p>undo/redo.</p></li>
<li><p>edit/replace on any line of the buffer.</p></li>
<li><p>search&replace text anywhere in buffer.</p></li>
<li><p>formatting of buffer, or selection, to certain width + indentations.</p></li>
<li><p>allow to echo the input or not, depending on your client.</p></li>
</ul>
</div></blockquote>
<p>To use the editor, just import EvEditor from this module
<li><p>caller is the user of the editor, the one to see all feedback.</p></li>
<li><p>loadfunc(caller) is called when the editor is first launched; the
return from this function is loaded as the starting buffer in the
editor.</p></li>
<li><p>safefunc(caller, buffer) is called with the current buffer when
saving in the editor. The function should return True/False depending
on if the saving was successful or not.</p></li>
<li><p>quitfunc(caller) is called when the editor exits. If this is given,
no automatic quit messages will be given.</p></li>
<li><p>key is an optional identifier for the editing session, to be
displayed in the editor.</p></li>
<li><p>persistent means the editor state will be saved to the database making it
survive a server reload. Note that using this mode, the load- save-
and quit-funcs must all be possible to pickle - notable unusable
callables are class methods and functions defined inside other
functions. With persistent=False, no such restriction exists.</p></li>
<li><p>code set to True activates features on the EvEditor to enter Python code.</p></li>
</ul>
</div></blockquote>
<p>In addition, the EvEditor can be used to enter Python source code,
and offers basic handling of indentation.</p>
<dlclass="class">
<dtid="evennia.utils.eveditor.CmdEditorBase">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">CmdEditorBase</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdEditorBase"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_keyaliases</code><emclass="property"> = ('command',)</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase._keyaliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_matchset</code><emclass="property"> = {'command'}</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase._matchset"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">editor</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.editor"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_entry</code><emclass="property"> = 'LineEditor'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.help_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.eveditor.CmdEditorBase.key">
<codeclass="sig-name descname">key</code><emclass="property"> = 'command'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">locks</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.locks"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">parse</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdEditorBase.parse"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.parse"title="Permalink to this definition">¶</a></dt>
<dd><p>Handles pre-parsing</p>
<dl>
<dt>Editor commands are on the form</dt><dd><p>:cmd [li] [w] [txt]</p>
</dd>
<dt>Where all arguments are optional.</dt><dd><dlclass="simple">
<dt>li - line number (int), starting from 1. This could also</dt><dd><p>be a range given as <l>:<l>.</p>
</dd>
</dl>
<p>w - word(s) (string), could be encased in quotes.
txt - extra text (string), could be encased in quotes.</p>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '', 'category': 'general', 'key': 'command', 'tags': '', 'text': '\n Base parent for editor commands\n '}</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorBase.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.eveditor.CmdEditorGroup">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">CmdEditorGroup</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdEditorGroup"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorGroup"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">arg_regex</code><emclass="property"> = re.compile('\\s.*?|$', re.IGNORECASE)</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorGroup.arg_regex"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdEditorGroup.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorGroup.func"title="Permalink to this definition">¶</a></dt>
<dd><p>This command handles all the in-editor :-style commands. Since
each command is small and very limited, this makes for a more
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorGroup.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = ':editor_command_group'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorGroup.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdEditorGroup.lock_storage"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">CmdLineInput</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdLineInput"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_keyaliases</code><emclass="property"> = ('__nomatch_command', '__noinput_command')</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput._keyaliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_matchset</code><emclass="property"> = {'__noinput_command', '__nomatch_command'}</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput._matchset"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['__noinput_command']</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput.aliases"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.eveditor.CmdLineInput.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdLineInput.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput.func"title="Permalink to this definition">¶</a></dt>
<dd><p>Adds the line without any formatting changes.</p>
<p>If the editor handles code, it might add automatic
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput.help_category"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.eveditor.CmdLineInput.key">
<codeclass="sig-name descname">key</code><emclass="property"> = '__nomatch_command'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '__noinput_command', 'category': 'general', 'key': '__nomatch_command', 'tags': '', 'text': '\n No command match - Inputs line of text into buffer.\n '}</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdLineInput.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.eveditor.CmdSaveYesNo">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">CmdSaveYesNo</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdSaveYesNo"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_keyaliases</code><emclass="property"> = ('__nomatch_command', '__noinput_command')</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo._keyaliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_matchset</code><emclass="property"> = {'__noinput_command', '__nomatch_command'}</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo._matchset"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['__noinput_command']</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.aliases"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.eveditor.CmdSaveYesNo.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#CmdSaveYesNo.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.func"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_cateogory</code><emclass="property"> = 'LineEditor'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.help_cateogory"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.eveditor.CmdSaveYesNo.key">
<codeclass="sig-name descname">key</code><emclass="property"> = '__nomatch_command'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">locks</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.locks"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '__noinput_command', 'category': 'general', 'key': '__nomatch_command', 'tags': '', 'text': '\n Save the editor state on quit. This catches\n nomatches (defaults to Yes), and avoid saves only if\n command was given specifically as "no" or "n".\n '}</em><aclass="headerlink"href="#evennia.utils.eveditor.CmdSaveYesNo.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.eveditor.EvEditor">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">EvEditor</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">loadfunc=None</em>, <emclass="sig-param">savefunc=None</em>, <emclass="sig-param">quitfunc=None</em>, <emclass="sig-param">key=''</em>, <emclass="sig-param">persistent=False</em>, <emclass="sig-param">codefunc=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">decrease_indent</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.decrease_indent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.decrease_indent"title="Permalink to this definition">¶</a></dt>
<dd><p>Decrease automatic indentation by 1 level.</p>
<codeclass="sig-name descname">deduce_indent</code><spanclass="sig-paren">(</span><emclass="sig-param">line</em>, <emclass="sig-param">buffer</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.deduce_indent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.deduce_indent"title="Permalink to this definition">¶</a></dt>
<dd><p>Try to deduce the level of indentation of the given line.</p>
<codeclass="sig-name descname">display_buffer</code><spanclass="sig-paren">(</span><emclass="sig-param">buf=None</em>, <emclass="sig-param">offset=0</em>, <emclass="sig-param">linenums=True</em>, <emclass="sig-param">options={'raw': False}</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.display_buffer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.display_buffer"title="Permalink to this definition">¶</a></dt>
<dd><p>This displays the line editor buffer, or selected parts of it.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>buf</strong> (<em>str</em><em>, </em><em>optional</em>) – The buffer or part of buffer to display.</p></li>
<li><p><strong>offset</strong> (<em>int</em><em>, </em><em>optional</em>) – If <cite>buf</cite> is set and is not the full buffer,
<cite>offset</cite> should define the actual starting line number, to
get the linenum display right.</p></li>
<li><p><strong>linenums</strong> (<em>bool</em><em>, </em><em>optional</em>) – Show line numbers in buffer.</p></li>
<li><p><strong>options</strong>– raw (bool, optional): Tell protocol to not parse
<codeclass="sig-name descname">display_help</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.display_help"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.display_help"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">get_buffer</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.get_buffer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.get_buffer"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">increase_indent</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.increase_indent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.increase_indent"title="Permalink to this definition">¶</a></dt>
<dd><p>Increase automatic indentation by 1 level.</p>
<codeclass="sig-name descname">load_buffer</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.load_buffer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.load_buffer"title="Permalink to this definition">¶</a></dt>
<dd><p>Load the buffer using the load function hook.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.eveditor.EvEditor.quit">
<codeclass="sig-name descname">quit</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.quit"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.quit"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">save_buffer</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.save_buffer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.save_buffer"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">swap_autoindent</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.swap_autoindent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.swap_autoindent"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">update_buffer</code><spanclass="sig-paren">(</span><emclass="sig-param">buf</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.update_buffer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.update_buffer"title="Permalink to this definition">¶</a></dt>
<dd><p>This should be called when the buffer has been changed
somehow. It will handle unsaved flag and undo updating.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>buf</strong> (<em>str</em>) – The text to update the buffer with.</p>
<codeclass="sig-name descname">update_undo</code><spanclass="sig-paren">(</span><emclass="sig-param">step=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditor.update_undo"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditor.update_undo"title="Permalink to this definition">¶</a></dt>
<dd><p>This updates the undo position.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>step</strong> (<em>int</em><em>, </em><em>optional</em>) – The amount of steps
to progress the undo position to. This
may be a negative value for undo and
a positive value for redo.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.eveditor.EvEditorCmdSet">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">EvEditorCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param">cmdsetobj=None</em>, <emclass="sig-param">key=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditorCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditorCmdSet"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#EvEditorCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.EvEditorCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook method - this should be overloaded in the inheriting
class, and should take care of populating the cmdset by use of
<codeclass="sig-name descname">key</code><emclass="property"> = 'editorcmdset'</em><aclass="headerlink"href="#evennia.utils.eveditor.EvEditorCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mergetype</code><emclass="property"> = 'Replace'</em><aclass="headerlink"href="#evennia.utils.eveditor.EvEditorCmdSet.mergetype"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.eveditor.EvEditorCmdSet'</em><aclass="headerlink"href="#evennia.utils.eveditor.EvEditorCmdSet.path"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.eveditor.SaveYesNoCmdSet">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">SaveYesNoCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param">cmdsetobj=None</em>, <emclass="sig-param">key=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#SaveYesNoCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.SaveYesNoCmdSet"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#SaveYesNoCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor.SaveYesNoCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'quitsave_yesno'</em><aclass="headerlink"href="#evennia.utils.eveditor.SaveYesNoCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mergetype</code><emclass="property"> = 'Replace'</em><aclass="headerlink"href="#evennia.utils.eveditor.SaveYesNoCmdSet.mergetype"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.eveditor.SaveYesNoCmdSet'</em><aclass="headerlink"href="#evennia.utils.eveditor.SaveYesNoCmdSet.path"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">priority</code><emclass="property"> = 1</em><aclass="headerlink"href="#evennia.utils.eveditor.SaveYesNoCmdSet.priority"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.eveditor._load_editor">
<codeclass="sig-prename descclassname">evennia.utils.eveditor.</code><codeclass="sig-name descname">_load_editor</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/eveditor.html#_load_editor"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.eveditor._load_editor"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-evform-module"></span><h2>evennia.utils.evform module<aclass="headerlink"href="#module-evennia.utils.evform"title="Permalink to this headline">¶</a></h2>
<p>EvForm - a way to create advanced ASCII forms</p>
<p>This is intended for creating advanced ASCII game forms, such as a
large pretty character sheet or info document.</p>
<p>The system works on the basis of a readin template that is given in a
separate Python file imported into the handler. This file contains
some optional settings and a string mapping out the form. The template
has markers in it to denounce fields to fill. The markers map the
absolute size of the field and will be filled with an <cite>evtable.EvCell</cite>
object when displaying the form.</p>
<p>Example of input file <cite>testform.py</cite>:</p>
<p>This object is instantiated with a text file and parses
it for rectangular form fields. It can then be fed a
mapping so as to populate the fields with fixed-width
EvCell or Tables.</p>
<dlclass="method">
<dtid="evennia.utils.evform.EvForm.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">filename=None</em>, <emclass="sig-param">cells=None</em>, <emclass="sig-param">tables=None</em>, <emclass="sig-param">form=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#EvForm.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform.EvForm.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initiate the form</p>
<dl>
<dt>Kwargs:</dt><dd><p>filename (str): Path to template file.
cells (dict): A dictionary mapping of {id:text}
tables (dict): A dictionary mapping of {id:EvTable}.
form (dict): A dictionary of {“FORMCHAR”:char,</p>
<blockquote>
<div><blockquote>
<div><p>“TABLECHAR”:char,
“FORM”:templatestring}</p>
</div></blockquote>
<p>if this is given, filename is not read.</p>
</div></blockquote>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Other kwargs are fed as options to the EvCells and EvTables
(see <cite>evtable.EvCell</cite> and <cite>evtable.EvTable</cite> for more info).</p>
<codeclass="sig-name descname">_parse_rectangles</code><spanclass="sig-paren">(</span><emclass="sig-param">cellchar</em>, <emclass="sig-param">tablechar</em>, <emclass="sig-param">form</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#EvForm._parse_rectangles"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform.EvForm._parse_rectangles"title="Permalink to this definition">¶</a></dt>
<dd><p>Parse a form for rectangular formfields identified by formchar
<codeclass="sig-name descname">_populate_form</code><spanclass="sig-paren">(</span><emclass="sig-param">raw_form</em>, <emclass="sig-param">mapping</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#EvForm._populate_form"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform.EvForm._populate_form"title="Permalink to this definition">¶</a></dt>
<dd><p>Insert cell contents into form at given locations</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evform.EvForm.map">
<codeclass="sig-name descname">map</code><spanclass="sig-paren">(</span><emclass="sig-param">cells=None</em>, <emclass="sig-param">tables=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#EvForm.map"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform.EvForm.map"title="Permalink to this definition">¶</a></dt>
<dd><p>Add mapping for form.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>cells</strong> (<em>dict</em>) – A dictionary of {identifier:celltext}</p></li>
<li><p><strong>tables</strong> (<em>dict</em>) – A dictionary of {identifier:table}</p></li>
</ul>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>kwargs will be forwarded to tables/cells. See
<cite>evtable.EvCell</cite> and <cite>evtable.EvTable</cite> for info.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evform.EvForm.reload">
<codeclass="sig-name descname">reload</code><spanclass="sig-paren">(</span><emclass="sig-param">filename=None</em>, <emclass="sig-param">form=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#EvForm.reload"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform.EvForm.reload"title="Permalink to this definition">¶</a></dt>
<dd><p>Creates the form from a stored file name.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>filename</strong> (<em>str</em>) – The file to read from.</p></li>
<li><p><strong>form</strong> (<em>dict</em>) – A mapping for the form.</p></li>
</ul>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Kwargs are passed through to Cel creation.</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evform._test">
<codeclass="sig-prename descclassname">evennia.utils.evform.</code><codeclass="sig-name descname">_test</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#_test"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform._test"title="Permalink to this definition">¶</a></dt>
<dd><p>test evform. This is used by the unittest system.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evform._to_ansi">
<codeclass="sig-prename descclassname">evennia.utils.evform.</code><codeclass="sig-name descname">_to_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em>, <emclass="sig-param">regexable=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#_to_ansi"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform._to_ansi"title="Permalink to this definition">¶</a></dt>
<dd><p>convert to ANSIString</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evform._to_rect">
<codeclass="sig-prename descclassname">evennia.utils.evform.</code><codeclass="sig-name descname">_to_rect</code><spanclass="sig-paren">(</span><emclass="sig-param">lines</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evform.html#_to_rect"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evform._to_rect"title="Permalink to this definition">¶</a></dt>
<dd><p>Forces all lines to be as long as the longest</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>lines</strong> (<em>list</em>) – list of <ahref="#id75"><spanclass="problematic"id="id76">`</span></a>ANSIString`s</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>list of <ahref="#id77"><spanclass="problematic"id="id78">`</span></a>ANSIString`s of
<spanid="evennia-utils-evmenu-module"></span><h2>evennia.utils.evmenu module<aclass="headerlink"href="#module-evennia.utils.evmenu"title="Permalink to this headline">¶</a></h2>
<p>EvMenu</p>
<p>This implements a full menu system for Evennia.</p>
<p>To start the menu, just import the EvMenu class from this module.
<p>Where caller is the object using the menu and input_string is the
command entered by the user on the <em>previous</em> node (the command
entered to get to this node). The node function code will only be
executed once per node-visit and the system will accept nodes with
both one or two arguments interchangeably. It also accepts nodes
that takes <ahref="#id97"><spanclass="problematic"id="id98">**</span></a>kwargs.</p>
<p>The menu tree itself is available on the caller as
<cite>caller.ndb._menutree</cite>. This makes it a convenient place to store
temporary state variables between nodes, since this NAttribute is
deleted when the menu is exited.</p>
<p>The return values must be given in the above order, but each can be
returned as None as well. If the options are returned as None, the
menu is immediately exited and the default “look” command is called.</p>
<blockquote>
<div><dl>
<dt>text (str, tuple or None): Text shown at this node. If a tuple, the</dt><dd><p>second element in the tuple is a help text to display at this
node when the user enters the menu help command there.</p>
</dd>
<dt>options (tuple, dict or None): If <cite>None</cite>, this exits the menu.</dt><dd><p>If a single dict, this is a single-option node. If a tuple,
it should be a tuple of option dictionaries. Option dicts have
the following keys:</p>
<blockquote>
<div><ulclass="simple">
<li><dlclass="simple">
<dt><cite>key</cite> (str or tuple, optional): What to enter to choose this option.</dt><dd><p>If a tuple, it must be a tuple of strings, where the first string is the
key which will be shown to the user and the others are aliases.
If unset, the options’ number will be used. The special key <cite>_default</cite>
marks this option as the default fallback when no other option matches
the user input. There can only be one <cite>_default</cite> option per node. It
will not be displayed in the list.</p>
</dd>
</dl>
</li>
<li><p><cite>desc</cite> (str, optional): This describes what choosing the option will do.</p></li>
<li><dlclass="simple">
<dt><cite>goto</cite> (str, tuple or callable): If string, should be the name of node to go to</dt><dd><p>when this option is selected. If a callable, it has the signature
<ahref="#id99"><spanclass="problematic"id="id100">`</span></a>callable(caller[,raw_input][,**kwargs]). If a tuple, the first element
is the callable and the second is a dict with the <ahref="#id101"><spanclass="problematic"id="id102">**</span></a>kwargs to pass to
the callable. Those kwargs will also be passed into the next node if possible.
Such a callable should return either a str or a (str, dict), where the
string is the name of the next node to go to and the dict is the new,
(possibly modified) kwarg to pass into the next node. If the callable returns
None or the empty string, the current node will be revisited.</p>
</dd>
</dl>
</li>
<li><dlclass="simple">
<dt><cite>exec</cite> (str, callable or tuple, optional): This takes the same input as <cite>goto</cite> above</dt><dd><p>and runs before it. If given a node name, the node will be executed but will not
be considered the next node. If node/callback returns str or (str, dict), these will
replace the <cite>goto</cite> step (<cite>goto</cite> callbacks will not fire), with the string being the
next node name and the optional dict acting as the kwargs-input for the next node.
If an exec callable returns the empty string (only), the current node is re-run.</p>
</dd>
</dl>
</li>
</ul>
</div></blockquote>
</dd>
</dl>
</div></blockquote>
<p>If key is not given, the option will automatically be identified by
<p>When starting this menu with <cite>Menu(caller, “path.to.menu_module”)</cite>,
the first node will look something like this:</p>
<blockquote>
<div><p>testing: Select this to go to node 2
2: Go to node 3</p>
</div></blockquote>
<p>Where you can both enter “testing” and “1” to select the first option.
If the client supports MXP, they may also mouse-click on “testing” to
do the same. When making this selection, a function “callback1” in the
same Using <cite>help</cite> will show the help text, otherwise a list of
available commands while in menu mode.</p>
<p>The menu tree is exited either by using the in-menu quit command or by
reaching a node without any options.</p>
<p>For a menu demo, import CmdTestMenu from this module and add it to
your default cmdset. Run it with this module, like <cite>testmenu
evennia.utils.evmenu</cite>.</p>
<dlclass="class">
<dtid="evennia.utils.evmenu.CmdEvMenuNode">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">CmdEvMenuNode</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdEvMenuNode"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_keyaliases</code><emclass="property"> = ('__nomatch_command', '__noinput_command')</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode._keyaliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_matchset</code><emclass="property"> = {'__noinput_command', '__nomatch_command'}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode._matchset"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['__nomatch_command']</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.aliases"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmenu.CmdEvMenuNode.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdEvMenuNode.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.func"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'menu'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.help_category"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.CmdEvMenuNode.key">
<codeclass="sig-name descname">key</code><emclass="property"> = '__noinput_command'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.lock_storage"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.CmdEvMenuNode.locks">
<codeclass="sig-name descname">locks</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.locks"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '__nomatch_command', 'category': 'menu', 'key': '__noinput_command', 'tags': '', 'text': '\n Menu options.\n '}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evmenu.CmdGetInput">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">CmdGetInput</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdGetInput"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_keyaliases</code><emclass="property"> = ('__nomatch_command', '__noinput_command')</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput._keyaliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_matchset</code><emclass="property"> = {'__noinput_command', '__nomatch_command'}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput._matchset"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.CmdGetInput.aliases">
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['__noinput_command']</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.aliases"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmenu.CmdGetInput.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdGetInput.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.func"title="Permalink to this definition">¶</a></dt>
<dd><p>This is called when user enters anything.</p>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.help_category"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.CmdGetInput.key">
<codeclass="sig-name descname">key</code><emclass="property"> = '__nomatch_command'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '__noinput_command', 'category': 'general', 'key': '__nomatch_command', 'tags': '', 'text': '\n Enter your data and press return.\n '}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evmenu.CmdTestMenu">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">CmdTestMenu</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdTestMenu"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_keyaliases</code><emclass="property"> = ('testmenu',)</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu._keyaliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_matchset</code><emclass="property"> = {'testmenu'}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu._matchset"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.CmdTestMenu.aliases">
<codeclass="sig-name descname">aliases</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu.aliases"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmenu.CmdTestMenu.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdTestMenu.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu.func"title="Permalink to this definition">¶</a></dt>
<dd><p>This is the actual executing part of the command. It is
called directly after self.parse(). See the docstring of this
module for which object properties are available (beyond those
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu.help_category"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.CmdTestMenu.key">
<codeclass="sig-name descname">key</code><emclass="property"> = 'testmenu'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '', 'category': 'general', 'key': 'testmenu', 'tags': '', 'text': '\n Test menu\n\n Usage:\n testmenu <menumodule>\n\n Starts a demo menu from a menu node definition module.\n\n '}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdTestMenu.search_index_entry"title="Permalink to this definition">¶</a></dt>
<p>This object represents an operational menu. It is initialized from
a menufile.py instruction.</p>
<dlclass="method">
<dtid="evennia.utils.evmenu.EvMenu.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">menudata</em>, <emclass="sig-param">startnode='start'</em>, <emclass="sig-param">cmdset_mergetype='Replace'</em>, <emclass="sig-param">cmdset_priority=1</em>, <emclass="sig-param">auto_quit=True</em>, <emclass="sig-param">auto_look=True</em>, <emclass="sig-param">auto_help=True</em>, <emclass="sig-param">cmd_on_exit='look'</em>, <emclass="sig-param">persistent=False</em>, <emclass="sig-param">startnode_input=''</em>, <emclass="sig-param">session=None</em>, <emclass="sig-param">debug=False</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the menu tree and start the caller onto the first node.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Object</em><em>, </em><em>Account</em><em> or </em><aclass="reference internal"href="evennia.server.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a>) – The user of the menu.</p></li>
<li><p><strong>menudata</strong> (<em>str</em><em>, </em><em>module</em><em> or </em><em>dict</em>) – The full or relative path to the module
holding the menu tree data. All global functions in this module
whose name doesn’t start with ‘_ ‘ will be parsed as menu nodes.
Also the module itself is accepted as input. Finally, a dictionary
menu tree can be given directly. This must then be a mapping
<cite>{“nodekey”:callable,…}</cite> where <cite>callable</cite> must be called as
and return the data expected of a menu node. This allows for
dynamic menu creation.</p></li>
<li><p><strong>startnode</strong> (<em>str</em><em>, </em><em>optional</em>) – The starting node name in the menufile.</p></li>
<li><p><strong>cmdset_mergetype</strong> (<em>str</em><em>, </em><em>optional</em>) –‘Replace’ (default) means the menu
commands will be exclusive - no other normal commands will
be usable while the user is in the menu. ‘Union’ means the
menu commands will be integrated with the existing commands
(it will merge with <cite>merge_priority</cite>), if so, make sure that
the menu’s command names don’t collide with existing commands
in an unexpected way. Also the CMD_NOMATCH and CMD_NOINPUT will
be overloaded by the menu cmdset. Other cmdser mergetypes
has little purpose for the menu.</p></li>
<li><p><strong>cmdset_priority</strong> (<em>int</em><em>, </em><em>optional</em>) – The merge priority for the
menu command set. The default (1) is usually enough for most
types of menus.</p></li>
<li><p><strong>auto_quit</strong> (<em>bool</em><em>, </em><em>optional</em>) – Allow user to use “q”, “quit” or
“exit” to leave the menu at any point. Recommended during
development!</p></li>
<li><p><strong>auto_look</strong> (<em>bool</em><em>, </em><em>optional</em>) – Automatically make “looK” or “l” to
re-show the last node. Turning this off means you have to handle
re-showing nodes yourself, but may be useful if you need to
use “l” for some other purpose.</p></li>
<li><p><strong>auto_help</strong> (<em>bool</em><em>, </em><em>optional</em>) – Automatically make “help” or “h” show
the current help entry for the node. If turned off, eventual
help must be handled manually, but it may be useful if you
need ‘h’ for some other purpose, for example.</p></li>
<li><p><strong>cmd_on_exit</strong> (<em>callable</em><em>, </em><em>str</em><em> or </em><em>None</em><em>, </em><em>optional</em>) – When exiting the menu
(either by reaching a node with no options or by using the
in-built quit command (activated with <cite>allow_quit</cite>), this
callback function or command string will be executed.
The callback function takes two parameters, the caller then the
EvMenu object. This is called after cleanup is complete.
Set to None to not call any command.</p></li>
<li><p><strong>persistent</strong> (<em>bool</em><em>, </em><em>optional</em>) – Make the Menu persistent (i.e. it will
survive a reload. This will make the Menu cmdset persistent. Use
with caution - if your menu is buggy you may end up in a state
you can’t get out of! Also note that persistent mode requires
that all formatters, menu nodes and callables are possible to
<em>pickle</em>. When the server is reloaded, the latest node shown will be completely
re-run with the same input arguments - so be careful if you are counting
up some persistent counter or similar - the counter may be run twice if
reload happens on the node that does that. Note that if <cite>debug</cite> is True,
this setting is ignored and assumed to be False.</p></li>
<li><p><strong>startnode_input</strong> (<em>str</em><em> or </em><em>(</em><em>str</em><em>, </em><em>dict</em><em>)</em><em>, </em><em>optional</em>) – Send an input text to <cite>startnode</cite> as if
a user input text from a fictional previous node. If including the dict, this will
be passed as <ahref="#id113"><spanclass="problematic"id="id114">**</span></a>kwargs to that node. When the server reloads,
the latest visited node will be re-run as <cite>node(caller, raw_string, **kwargs)</cite>.</p></li>
<li><p><strong>session</strong> (<aclass="reference internal"href="evennia.server.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – This is useful when calling EvMenu from an account
in multisession mode > 2. Note that this session only really relevant
for the very first display of the first node - after that, EvMenu itself
will keep the session updated from the command input. So a persistent
menu will <em>not</em> be using this same session anymore after a reload.</p></li>
<li><p><strong>debug</strong> (<em>bool</em><em>, </em><em>optional</em>) – If set, the ‘menudebug’ command will be made available
by default in all nodes of the menu. This will print out the current state of
the menu. Deactivate for production use! When the debug flag is active, the
<cite>persistent</cite> flag is deactivated.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>any (any): All kwargs will become initialization variables on <cite>caller.ndb._menutree</cite>,</dt><dd><p>to be available at run.</p>
</dd>
</dl>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><aclass="reference internal"href="#evennia.utils.evmenu.EvMenuError"title="evennia.utils.evmenu.EvMenuError"><strong>EvMenuError</strong></a>– If the start/end node is not found in menu tree.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>While running, the menu is stored on the caller as <cite>caller.ndb._menutree</cite>. Also
the current Session (from the Command, so this is still valid in multisession
environments) is available through <cite>caller.ndb._menutree._session</cite>. The <cite>_menutree</cite>
property is a good one for storing intermediary data on between nodes since it
will be automatically deleted when the menu closes.</p>
<p>In persistent mode, all nodes, formatters and callbacks in the menu must be
possible to be <em>pickled</em>, this excludes e.g. callables that are class methods
or functions defined dynamically or as part of another function. In
non-persistent mode no such restrictions exist.</p>
<codeclass="sig-name descname">_execute_node</code><spanclass="sig-paren">(</span><emclass="sig-param">nodename</em>, <emclass="sig-param">raw_string</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu._execute_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu._execute_node"title="Permalink to this definition">¶</a></dt>
<dd><p>Execute a node.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodename</strong> (<em>str</em>) – Name of node.</p></li>
<li><p><strong>raw_string</strong> (<em>str</em>) – The raw default string entered on the
previous node (only used if the node accepts it as an
argument)</p></li>
<li><p><strong>kwargs</strong> (<em>any</em><em>, </em><em>optional</em>) – Optional kwargs for the node.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The node text (a string or a</dt><dd><p>tuple and the options tuple, if any.</p>
<codeclass="sig-name descname">_format_node</code><spanclass="sig-paren">(</span><emclass="sig-param">nodetext</em>, <emclass="sig-param">optionlist</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu._format_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu._format_node"title="Permalink to this definition">¶</a></dt>
<dd><p>Format the node text + option section</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodetext</strong> (<em>str</em>) – The node text</p></li>
<li><p><strong>optionlist</strong> (<em>list</em>) – List of (key, desc) pairs.</p></li>
<codeclass="sig-name descname">_parse_menudata</code><spanclass="sig-paren">(</span><emclass="sig-param">menudata</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu._parse_menudata"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu._parse_menudata"title="Permalink to this definition">¶</a></dt>
<dd><p>Parse a menufile for node functions and store in dictionary
map. Alternatively, accept a pre-made mapping dictionary of
node functions.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>menudata</strong> (<em>str</em><em>, </em><em>module</em><em> or </em><em>dict</em>) – The python.path to the menufile,
or the python module itself. If a dict, this should be a
mapping nodename:callable, where the callable must match
the criteria for a menu node.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A {nodekey: func}</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>menutree (dict)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmenu.EvMenu._safe_call">
<codeclass="sig-name descname">_safe_call</code><spanclass="sig-paren">(</span><emclass="sig-param">callback</em>, <emclass="sig-param">raw_string</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu._safe_call"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu._safe_call"title="Permalink to this definition">¶</a></dt>
<dd><p>Call a node-like callable, with a variable number of raw_string, <ahref="#id115"><spanclass="problematic"id="id116">*</span></a>args, <ahref="#id117"><spanclass="problematic"id="id118">**</span></a>kwargs, all of
which should work also if not present (only <cite>caller</cite> is always required). Return its result.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmenu.EvMenu.close_menu">
<codeclass="sig-name descname">close_menu</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.close_menu"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.close_menu"title="Permalink to this definition">¶</a></dt>
<dd><p>Shutdown menu; occurs when reaching the end node or using the quit command.</p>
<codeclass="sig-name descname">display_helptext</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.display_helptext"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.display_helptext"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">display_nodetext</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.display_nodetext"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.display_nodetext"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">extract_goto_exec</code><spanclass="sig-paren">(</span><emclass="sig-param">nodename</em>, <emclass="sig-param">option_dict</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.extract_goto_exec"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.extract_goto_exec"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper: Get callables and their eventual kwargs.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodename</strong> (<em>str</em>) – The current node name (used for error reporting).</p></li>
<li><p><strong>option_dict</strong> (<em>dict</em>) – The seleted option’s dict.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The goto directive in the option.
goto_kwargs (dict): Kwargs for <cite>goto</cite> if the former is callable, otherwise empty.
execute (callable or None): Executable given by the <cite>exec</cite> directive.
exec_kwargs (dict): Kwargs for <cite>execute</cite> if it’s callable, otherwise empty.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>goto (str, callable or None)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmenu.EvMenu.goto">
<codeclass="sig-name descname">goto</code><spanclass="sig-paren">(</span><emclass="sig-param">nodename</em>, <emclass="sig-param">raw_string</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.goto"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.goto"title="Permalink to this definition">¶</a></dt>
<dd><p>Run a node by name, optionally dynamically generating that name first.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodename</strong> (<em>str</em><em> or </em><em>callable</em>) – Name of node or a callable
to be called as <cite>function(caller, raw_string, **kwargs)</cite> or
<cite>function(caller, **kwargs)</cite> to return the actual goto string or
a (“nodename”, kwargs) tuple.</p></li>
<li><p><strong>raw_string</strong> (<em>str</em>) – The raw default string entered on the
previous node (only used if the node accepts it as an
argument)</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>any: Extra arguments to goto callables.</p>
<codeclass="sig-name descname">helptext_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param">helptext</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.helptext_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.helptext_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Format the node’s help text</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>helptext</strong> (<em>str</em>) – The unformatted help text for the node.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The formatted help text.</p>
<codeclass="sig-name descname">node_border_char</code><emclass="property"> = '_'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.node_border_char"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">node_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param">nodetext</em>, <emclass="sig-param">optionstext</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.node_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.node_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the entirety of the node.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodetext</strong> (<em>str</em>) – The node text as returned by <cite>self.nodetext_formatter</cite>.</p></li>
<li><p><strong>optionstext</strong> (<em>str</em>) – The options display as returned by <cite>self.options_formatter</cite>.</p></li>
<li><p><strong>caller</strong> (<em>Object</em><em>, </em><em>Account</em><em> or </em><em>None</em><em>, </em><em>optional</em>) – The caller of the node.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The formatted node to display.</p>
<codeclass="sig-name descname">nodetext_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param">nodetext</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.nodetext_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.nodetext_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Format the node text itself.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>nodetext</strong> (<em>str</em>) – The full node text (the text describing the node).</p>
<codeclass="sig-name descname">options_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param">optionlist</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.options_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.options_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the option block.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>optionlist</strong> (<em>list</em>) – List of (key, description) tuples for every
option related to this node.</p></li>
<li><p><strong>caller</strong> (<em>Object</em><em>, </em><em>Account</em><em> or </em><em>None</em><em>, </em><em>optional</em>) – The caller of the node.</p></li>
<codeclass="sig-name descname">parse_input</code><spanclass="sig-paren">(</span><emclass="sig-param">raw_string</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.parse_input"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.parse_input"title="Permalink to this definition">¶</a></dt>
<dd><p>Parses the incoming string from the menu user.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>raw_string</strong> (<em>str</em>) – The incoming, unmodified string
from the user.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This method is expected to parse input and use the result
to relay execution to the relevant methods of the menu. It
should also report errors directly to the user.</p>
<codeclass="sig-name descname">print_debug_info</code><spanclass="sig-paren">(</span><emclass="sig-param">arg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.print_debug_info"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.print_debug_info"title="Permalink to this definition">¶</a></dt>
<dd><p>Messages the caller with the current menu state, for debug purposes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>arg</strong> (<em>str</em>) – Arg to debug instruction, either nothing, ‘full’ or the name
of a property to inspect.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmenu.EvMenu.run_exec">
<codeclass="sig-name descname">run_exec</code><spanclass="sig-paren">(</span><emclass="sig-param">nodename</em>, <emclass="sig-param">raw_string</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.run_exec"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.run_exec"title="Permalink to this definition">¶</a></dt>
<dd><p>Run a function or node as a callback (with the ‘exec’ option key).</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodename</strong> (<em>callable</em><em> or </em><em>str</em>) – A callable to run as
<cite>callable(caller, raw_string)</cite>, or the Name of an existing
node to run as a callable. This may or may not return
a string.</p></li>
<li><p><strong>raw_string</strong> (<em>str</em>) – The raw default string entered on the
previous node (only used if the node accepts it as an
argument)</p></li>
<li><p><strong>kwargs</strong> (<em>any</em>) – These are optional kwargs passed into goto</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A replacement goto location string or</dt><dd><p>None (no replacement).</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>new_goto (str or None)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Relying on exec callbacks to set the goto location is
very powerful but will easily lead to spaghetti structure and
hard-to-trace paths through the menu logic. So be careful with
<codeclass="sig-name descname">run_exec_then_goto</code><spanclass="sig-paren">(</span><emclass="sig-param">runexec</em>, <emclass="sig-param">goto</em>, <emclass="sig-param">raw_string</em>, <emclass="sig-param">runexec_kwargs=None</em>, <emclass="sig-param">goto_kwargs=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.run_exec_then_goto"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.run_exec_then_goto"title="Permalink to this definition">¶</a></dt>
<dd><p>Call ‘exec’ callback and goto (which may also be a callable) in sequence.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>runexec</strong> (<em>callable</em><em> or </em><em>str</em>) – Callback to run before goto. If
the callback returns a string, this is used to replace
the <cite>goto</cite> string/callable before being passed into the goto handler.</p></li>
<li><p><strong>goto</strong> (<em>str</em>) – The target node to go to next (may be replaced
by <cite>runexec</cite>)..</p></li>
<li><p><strong>raw_string</strong> (<em>str</em>) – The original user input.</p></li>
<li><p><strong>runexec_kwargs</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional kwargs for runexec.</p></li>
<li><p><strong>goto_kwargs</strong> (<em>dict</em><em>, </em><em>optional</em>) – Optional kwargs for goto.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evmenu.EvMenuCmdSet">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">EvMenuCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param">cmdsetobj=None</em>, <emclass="sig-param">key=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenuCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenuCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>Called when creating the set.</p>
</dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.EvMenuCmdSet.key">
<codeclass="sig-name descname">key</code><emclass="property"> = 'menu_cmdset'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mergetype</code><emclass="property"> = 'Replace'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.mergetype"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_channels</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.no_channels"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_exits</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.no_exits"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_objs</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.no_objs"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.EvMenuCmdSet.path">
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.evmenu.EvMenuCmdSet'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.path"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">priority</code><emclass="property"> = 1</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.priority"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="exception">
<dtid="evennia.utils.evmenu.EvMenuError">
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">EvMenuError</code><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenuError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuError"title="Permalink to this definition">¶</a></dt>
<p>Error raised by menu when facing internal errors.</p>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evmenu.InputCmdSet">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">InputCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param">cmdsetobj=None</em>, <emclass="sig-param">key=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#InputCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#InputCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>called once at creation</p>
</dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.InputCmdSet.key">
<codeclass="sig-name descname">key</code><emclass="property"> = 'input_cmdset'</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mergetype</code><emclass="property"> = 'Replace'</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.mergetype"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_channels</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.no_channels"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_exits</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.no_exits"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.InputCmdSet.no_objs">
<codeclass="sig-name descname">no_objs</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.no_objs"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmenu.InputCmdSet.path">
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.evmenu.InputCmdSet'</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.path"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">priority</code><emclass="property"> = 1</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.priority"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evmenu._Prompt">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">_Prompt</code><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#_Prompt"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu._Prompt"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">_generate_goto</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#_generate_goto"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu._generate_goto"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu._test_call">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">_test_call</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">raw_input</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#_test_call"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu._test_call"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.get_input">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">get_input</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">prompt</em>, <emclass="sig-param">callback</em>, <emclass="sig-param">session=None</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#get_input"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.get_input"title="Permalink to this definition">¶</a></dt>
<dd><p>This is a helper function for easily request input from
the caller.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Account</em><em> or </em><em>Object</em>) – The entity being asked
the question. This should usually be an object
controlled by a user.</p></li>
<li><p><strong>prompt</strong> (<em>str</em>) – This text will be shown to the user,
in order to let them know their input is needed.</p></li>
<li><p><strong>callback</strong> (<em>callable</em>) – A function that will be called
when the user enters a reply. It must take three
arguments: the <cite>caller</cite>, the <cite>prompt</cite> text and the
<cite>result</cite> of the input given by the user. If the
callback doesn’t return anything or return False,
the input prompt will be cleaned up and exited. If
returning True, the prompt will remain and continue to
accept input.</p></li>
<li><p><strong>session</strong> (<aclass="reference internal"href="evennia.server.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – This allows to specify the
session to send the prompt to. It’s usually only
needed if <cite>caller</cite> is an Account in multisession modes
greater than 2. The session is then updated by the
command and is available (for example in callbacks)
through <cite>caller.ndb.getinput._session</cite>.</p></li>
<li><p><strong>**kwargs</strong> (<em>*args</em><em>,</em>) –<p>Extra arguments will be
passed to the fall back function as a list ‘args’
and all keyword arguments as a dictionary ‘kwargs’.
To utilise <ahref="#id121"><spanclass="problematic"id="id122">*</span></a>args and <ahref="#id123"><spanclass="problematic"id="id124">**</span></a>kwargs, a value for the
session argument must be provided (None by default)
and the callback function must take <ahref="#id125"><spanclass="problematic"id="id126">*</span></a>args and
<ahref="#id127"><spanclass="problematic"id="id128">**</span></a>kwargs as arguments.</p>
</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>RuntimeError</strong>– If the given callback is not callable.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>The result value sent to the callback is raw and not
processed in any way. This means that you will get
the ending line return character from most types of
client inputs. So make sure to strip that before
doing a comparison.</p>
<p>When the prompt is running, a temporary object
<cite>caller.ndb._getinput</cite> is stored; this will be removed
when the prompt finishes.
If you need the specific Session of the caller (which
may not be easy to get if caller is an account in higher
multisession modes), then it is available in the
callback through <cite>caller.ndb._getinput._session</cite>.</p>
<p>Chaining get_input functions will result in the caller
stacking ever more instances of InputCmdSets. Whilst
they will all be cleared on concluding the get_input
chain, EvMenu should be considered for anything beyond
a single question.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.list_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">list_node</code><spanclass="sig-paren">(</span><emclass="sig-param">option_generator</em>, <emclass="sig-param">select=None</em>, <emclass="sig-param">pagesize=10</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#list_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.list_node"title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator for making an EvMenu node into a multi-page list node. Will add new options,
prepending those options added in the node.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>option_generator</strong> (<em>callable</em><em> or </em><em>list</em>) – A list of strings indicating the options, or a callable
that is called as option_generator(caller) to produce such a list.</p></li>
<li><p><strong>select</strong> (<em>callable</em><em> or </em><em>str</em><em>, </em><em>optional</em>) –<p>Node to redirect a selection to. Its <cite>**kwargs</cite> will
contain the <cite>available_choices</cite> list and <cite>selection</cite> will hold one of the elements in
that list. If a callable, it will be called as</p>
<blockquote>
<div><p>select(caller, menuchoice, <ahref="#id131"><spanclass="problematic"id="id132">**</span></a>kwargs) where menuchoice is the chosen option as a</p>
</div></blockquote>
<p>string and <cite>available_choices</cite> is a kwarg mapping the option keys to the choices
offered by the option_generator. The callable whould return the name of the target node
to goto after this selection (or None to repeat the list-node). Note that if this is not
given, the decorated node must itself provide a way to continue from the node!</p>
</p></li>
<li><p><strong>pagesize</strong> (<em>int</em>) – How many options to show per page.</p></li>
</ul>
</dd>
</dl>
<pclass="rubric">Example</p>
<p>@list_node([‘foo’, ‘bar’], select)
def node_index(caller):</p>
<blockquote>
<div><p>text = “describing the list”
return text, []</p>
</div></blockquote>
<pclass="rubric">Notes</p>
<p>All normal <cite>goto</cite> or <cite>exec</cite> callables returned from the decorated nodes will, if they accept
<ahref="#id133"><spanclass="problematic"id="id134">**</span></a>kwargs, get a new kwarg ‘available_choices’ injected. These are the ordered list of named
options (descs) visible on the current node page.</p>
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">test_displayinput_node</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">raw_string</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#test_displayinput_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.test_displayinput_node"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.test_dynamic_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">test_dynamic_node</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#test_dynamic_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.test_dynamic_node"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.test_end_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">test_end_node</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#test_end_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.test_end_node"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.test_look_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">test_look_node</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#test_look_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.test_look_node"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.test_set_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">test_set_node</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#test_set_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.test_set_node"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.test_start_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">test_start_node</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#test_start_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.test_start_node"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmenu.test_view_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">test_view_node</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#test_view_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.test_view_node"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-evmore-module"></span><h2>evennia.utils.evmore module<aclass="headerlink"href="#module-evennia.utils.evmore"title="Permalink to this headline">¶</a></h2>
<p>EvMore - pager mechanism</p>
<p>This is a pager for displaying long texts and allows stepping up and
down in the text (the name comes from the traditional ‘more’ unix
command).</p>
<p>To use, simply pass the text through the EvMore object:</p>
<p>Where always_page decides if the pager is used also if the text is not
long enough to need to scroll, session is used to determine which session to relay to
and justify_kwargs are kwargs to pass to utils.utils.justify in order to change the formatting
of the text. The remaining <ahref="#id139"><spanclass="problematic"id="id140">**</span></a>kwargs will be passed on to the
caller.msg() construct every time the page is updated.</p>
<dlclass="class">
<dtid="evennia.utils.evmore.CmdMore">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmore.</code><codeclass="sig-name descname">CmdMore</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#CmdMore"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.CmdMore"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">auto_help</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMore.auto_help"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.CmdMore.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#CmdMore.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.CmdMore.func"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMore.help_category"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmore.CmdMore.key">
<codeclass="sig-name descname">key</code><emclass="property"> = '__noinput_command'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMore.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMore.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': 't b n top back abort q end a quit e next', 'category': 'general', 'key': '__noinput_command', 'tags': '', 'text': '\n Manipulate the text paging\n '}</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMore.search_index_entry"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmore.</code><codeclass="sig-name descname">CmdMoreLook</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#CmdMoreLook"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_keyaliases</code><emclass="property"> = ('l', 'look')</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook._keyaliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_matchset</code><emclass="property"> = {'l', 'look'}</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook._matchset"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmore.CmdMoreLook.aliases">
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['l']</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook.aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">auto_help</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook.auto_help"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.CmdMoreLook.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#CmdMoreLook.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook.func"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook.help_category"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmore.CmdMoreLook.key">
<codeclass="sig-name descname">key</code><emclass="property"> = 'look'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': 'l', 'category': 'general', 'key': 'look', 'tags': '', 'text': '\n Override look to display window and prevent OOCLook from firing\n '}</em><aclass="headerlink"href="#evennia.utils.evmore.CmdMoreLook.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evmore.CmdSetMore">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmore.</code><codeclass="sig-name descname">CmdSetMore</code><spanclass="sig-paren">(</span><emclass="sig-param">cmdsetobj=None</em>, <emclass="sig-param">key=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#CmdSetMore"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.CmdSetMore"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#CmdSetMore.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.CmdSetMore.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook method - this should be overloaded in the inheriting
class, and should take care of populating the cmdset by use of
self.add().</p>
</dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmore.CmdSetMore.key">
<codeclass="sig-name descname">key</code><emclass="property"> = 'more_commands'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdSetMore.key"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmore.CmdSetMore.path">
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.evmore.CmdSetMore'</em><aclass="headerlink"href="#evennia.utils.evmore.CmdSetMore.path"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.evmore.CmdSetMore.priority">
<codeclass="sig-name descname">priority</code><emclass="property"> = 110</em><aclass="headerlink"href="#evennia.utils.evmore.CmdSetMore.priority"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evmore.EvMore">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmore.</code><codeclass="sig-name descname">EvMore</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">text</em>, <emclass="sig-param">always_page=False</em>, <emclass="sig-param">session=None</em>, <emclass="sig-param">justify=False</em>, <emclass="sig-param">justify_kwargs=None</em>, <emclass="sig-param">exit_on_lastpage=False</em>, <emclass="sig-param">exit_cmd=None</em>, <emclass="sig-param">page_formatter=<class 'str'></em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore"title="Permalink to this definition">¶</a></dt>
<dt>If <cite>EvTable</cite>, the EvTable will be paginated with the same</dt><dd><p>setting on each page if it is too long. The table
decorations will be considered in the size of the page.</p>
</dd>
</dl>
</li>
<li><dlclass="simple">
<dt>Otherwise <cite>text</cite> is converted to an iterator, where each step is</dt><dd><p>expected to be a line in the final display. Each line
will be run through <cite>iter_callable</cite>.</p>
</dd>
</dl>
</li>
</ul>
</div></blockquote>
<dlclass="simple">
<dt>always_page (bool, optional): If <cite>False</cite>, the</dt><dd><p>pager will only kick in if <cite>text</cite> is too big
to fit the screen.</p>
</dd>
<dt>session (Session, optional): If given, this session will be used</dt><dd><p>to determine the screen width and will receive all output.</p>
</dd>
<dt>justify (bool, optional): If set, auto-justify long lines. This must be turned</dt><dd><p>off for fixed-width or formatted output, like tables. It’s force-disabled
if <cite>text</cite> is an EvTable.</p>
</dd>
<dt>justify_kwargs (dict, optional): Keywords for the justifiy function. Used only</dt><dd><p>if <cite>justify</cite> is True. If this is not set, default arguments will be used.</p>
</dd>
<dt>exit_on_lastpage (bool, optional): If reaching the last page without the</dt><dd><p>page being completely filled, exit pager immediately. If unset,
another move forward is required to exit. If set, the pager
exit message will not be shown.</p>
</dd>
<dt>exit_cmd (str, optional): If given, this command-string will be executed on</dt><dd><p>the caller when the more page exits. Note that this will be using whatever
cmdset the user had <em>before</em> the evmore pager was activated (so none of
the evmore commands will be available when this is run).</p>
</dd>
<dt>page_formatter (callable, optional): If given, this function will be passed the</dt><dd><p>contents of each extracted page. This is useful when paginating
data consisting something other than a string or a list of strings. Especially
queryset data is likely to always need this argument specified. Note however,
that all size calculations assume this function to return one single line
per element on the page!</p>
</dd>
</dl>
<p>kwargs (any, optional): These will be passed on to the <cite>caller.msg</cite> method.</p>
</div></blockquote>
<dl>
<dt>Examples:</dt><dd><p>super_long_text = ” … ”
EvMore(caller, super_long_text)</p>
<p>from django.core.paginator import Paginator
query = ObjectDB.objects.all()
pages = Paginator(query, 10) # 10 objs per page
EvMore(caller, pages) # will repr() each object per line, 10 to a page</p>
<codeclass="sig-name descname">display</code><spanclass="sig-paren">(</span><emclass="sig-param">show_footer=True</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.display"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.display"title="Permalink to this definition">¶</a></dt>
<dd><p>Pretty-print the page.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.format_page">
<codeclass="sig-name descname">format_page</code><spanclass="sig-paren">(</span><emclass="sig-param">page</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.format_page"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.format_page"title="Permalink to this definition">¶</a></dt>
<dd><p>Page formatter. Uses the page_formatter callable by default.
This allows to easier override the class if needed.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.init_evtable">
<codeclass="sig-name descname">init_evtable</code><spanclass="sig-paren">(</span><emclass="sig-param">table</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.init_evtable"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.init_evtable"title="Permalink to this definition">¶</a></dt>
<dd><p>The input is an EvTable.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.init_f_str">
<codeclass="sig-name descname">init_f_str</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.init_f_str"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.init_f_str"title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The input contains</p>
</div></blockquote>
<p>markers. We use
to indicate the user wants to</p>
<blockquote>
<div><p>enforce their line breaks on their own. If so, we do no automatic
<codeclass="sig-name descname">init_iterable</code><spanclass="sig-paren">(</span><emclass="sig-param">inp</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.init_iterable"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.init_iterable"title="Permalink to this definition">¶</a></dt>
<dd><p>The input is something other than a string - convert to iterable of strings</p>
<codeclass="sig-name descname">init_queryset</code><spanclass="sig-paren">(</span><emclass="sig-param">qs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.init_queryset"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.init_queryset"title="Permalink to this definition">¶</a></dt>
<dd><p>The input is a queryset</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.init_str">
<codeclass="sig-name descname">init_str</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.init_str"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.init_str"title="Permalink to this definition">¶</a></dt>
<dd><p>The input is a string</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.page_back">
<codeclass="sig-name descname">page_back</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.page_back"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.page_back"title="Permalink to this definition">¶</a></dt>
<dd><p>Scroll the text back up, at the most to the top.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.page_end">
<codeclass="sig-name descname">page_end</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.page_end"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.page_end"title="Permalink to this definition">¶</a></dt>
<dd><p>Display the bottom page.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.page_next">
<codeclass="sig-name descname">page_next</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.page_next"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.page_next"title="Permalink to this definition">¶</a></dt>
<dd><p>Scroll the text to the next page. Quit if already at the end
of the page.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.page_quit">
<codeclass="sig-name descname">page_quit</code><spanclass="sig-paren">(</span><emclass="sig-param">quiet=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.page_quit"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.page_quit"title="Permalink to this definition">¶</a></dt>
<dd><p>Quit the pager</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.page_top">
<codeclass="sig-name descname">page_top</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.page_top"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.page_top"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">paginator_index</code><spanclass="sig-paren">(</span><emclass="sig-param">pageno</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.paginator_index"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.paginator_index"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">paginator_slice</code><spanclass="sig-paren">(</span><emclass="sig-param">pageno</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.paginator_slice"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.paginator_slice"title="Permalink to this definition">¶</a></dt>
<dd><p>Paginate by slice. This is done with an eye on memory efficiency (usually for
querysets); to avoid fetching all objects at the same time.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evmore.EvMore.start">
<codeclass="sig-name descname">start</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#EvMore.start"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.EvMore.start"title="Permalink to this definition">¶</a></dt>
<dd><p>Starts the pagination</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmore.msg">
<codeclass="sig-prename descclassname">evennia.utils.evmore.</code><codeclass="sig-name descname">msg</code><spanclass="sig-paren">(</span><emclass="sig-param">caller</em>, <emclass="sig-param">text=''</em>, <emclass="sig-param">always_page=False</em>, <emclass="sig-param">session=None</em>, <emclass="sig-param">justify=False</em>, <emclass="sig-param">justify_kwargs=None</em>, <emclass="sig-param">exit_on_lastpage=True</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#msg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.msg"title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>EvMore-supported version of msg, mimicking the normal msg method.</p>
<dl>
<dt>Args:</dt><dd><p>caller (Object or Account): Entity reading the text.
text (str, EvTable or iterator): The text or data to put under paging.</p>
<blockquote>
<div><ulclass="simple">
<li><p>If a string, paginage normally. If this text contains
one or more `</p></li>
</ul>
</div></blockquote>
</dd>
</dl>
</div></blockquote>
<dl>
<dt>` format symbol, automatic pagination is disabled</dt><dd><p>and page-breaks will only happen after each `</p>
<dt>If <cite>EvTable</cite>, the EvTable will be paginated with the same</dt><dd><p>setting on each page if it is too long. The table
decorations will be considered in the size of the page.</p>
</dd>
</dl>
</li>
<li><p>Otherwise <cite>text</cite> is converted to an iterator, where each step is
is expected to be a line in the final display, and each line
will be run through repr().</p></li>
</ul>
</div></blockquote>
<dlclass="simple">
<dt>always_page (bool, optional): If <cite>False</cite>, the</dt><dd><p>pager will only kick in if <cite>text</cite> is too big
to fit the screen.</p>
</dd>
<dt>session (Session, optional): If given, this session will be used</dt><dd><p>to determine the screen width and will receive all output.</p>
</dd>
<dt>justify (bool, optional): If set, justify long lines in output. Disable for</dt><dd><p>fixed-format output, like tables.</p>
</dd>
<dt>justify_kwargs (dict, bool or None, optional): If given, this should</dt><dd><p>be valid keyword arguments to the utils.justify() function. If False,
no justification will be done.</p>
</dd>
</dl>
<p>exit_on_lastpage (bool, optional): Immediately exit pager when reaching the last page.
use_evtable (bool, optional): If True, each page will be rendered as an</p>
<blockquote>
<div><p>EvTable. For this to work, <cite>text</cite> must be an iterable, where each element
is the table (list of list) to render on that page.</p>
</div></blockquote>
<p>evtable_args (tuple, optional): The args to use for EvTable on each page.
evtable_kwargs (dict, optional): The kwargs to use for EvTable on each</p>
<blockquote>
<div><p>page (except <cite>table</cite>, which is supplied by EvMore per-page).</p>
</div></blockquote>
<dlclass="simple">
<dt>kwargs (any, optional): These will be passed on</dt><dd><p>to the <cite>caller.msg</cite> method.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evmore.queryset_maxsize">
<codeclass="sig-prename descclassname">evennia.utils.evmore.</code><codeclass="sig-name descname">queryset_maxsize</code><spanclass="sig-paren">(</span><emclass="sig-param">qs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmore.html#queryset_maxsize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmore.queryset_maxsize"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-evtable-module"></span><h2>evennia.utils.evtable module<aclass="headerlink"href="#module-evennia.utils.evtable"title="Permalink to this headline">¶</a></h2>
<p>This is an advanced ASCII table creator. It was inspired by
[prettytable](<aclass="reference external"href="https://code.google.com/p/prettytable/">https://code.google.com/p/prettytable/</a>) but shares no
<codeclass="sig-name descname">_munge_whitespace</code><spanclass="sig-paren">(</span><emclass="sig-param">text : string</em><spanclass="sig-paren">)</span>→ string<aclass="reference internal"href="../_modules/evennia/utils/evtable.html#ANSITextWrapper._munge_whitespace"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.ANSITextWrapper._munge_whitespace"title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Munge whitespace in text: expand tabs and convert all other
whitespace characters to spaces. Eg. ” foo bar</p>
<codeclass="sig-name descname">_split</code><spanclass="sig-paren">(</span><emclass="sig-param">text : string</em><spanclass="sig-paren">)</span>→ [string]<aclass="reference internal"href="../_modules/evennia/utils/evtable.html#ANSITextWrapper._split"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.ANSITextWrapper._split"title="Permalink to this definition">¶</a></dt>
<dd><p>Split the text to wrap into indivisible chunks. Chunks are
not quite the same as words; see _wrap_chunks() for full
details. As an example, the text</p>
<blockquote>
<div><p>Look, goof-ball – use the -b option!</p>
</div></blockquote>
<dlclass="simple">
<dt>breaks into the following chunks:</dt><dd><p>‘Look,’, ‘‘, ‘goof-‘, ‘ball’, ‘‘, ‘–’, ‘‘,
‘use’, ‘‘, ‘the’, ‘‘, ‘-b’, ‘‘, ‘option!’</p>
</dd>
<dt>if break_on_hyphens is True, or in:</dt><dd><p>‘Look,’, ‘‘, ‘goof-ball’, ‘‘, ‘–’, ‘‘,
<codeclass="sig-name descname">_wrap_chunks</code><spanclass="sig-paren">(</span><emclass="sig-param">chunks : [string]</em><spanclass="sig-paren">)</span>→ [string]<aclass="reference internal"href="../_modules/evennia/utils/evtable.html#ANSITextWrapper._wrap_chunks"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.ANSITextWrapper._wrap_chunks"title="Permalink to this definition">¶</a></dt>
<dd><p>Wrap a sequence of text chunks and return a list of lines of
length ‘self.width’ or less. (If ‘break_long_words’ is false,
some lines may be longer than this.) Chunks correspond roughly
to words and the whitespace between them: each chunk is
indivisible (modulo ‘break_long_words’), but a line break can
come between any two chunks. Chunks should not have internal
whitespace; ie. a chunk is either all whitespace or a “word”.
Whitespace chunks will be removed from the beginning and end of
lines, but apart from that whitespace is preserved.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evtable.EvCell">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">EvCell</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell"title="Permalink to this definition">¶</a></dt>
<p>Holds a single data cell for the table. A cell has a certain width
and height and contains one or more lines of data. It can shrink
and resize as needed.</p>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.__init__"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong> (<em>str</em>) – The un-padded data of the entry.</p>
</dd>
</dl>
<dl>
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>width (int): Desired width of cell. It will pad</dt><dd><p>to this size.</p>
</dd>
<dt>height (int): Desired height of cell. it will pad</dt><dd><p>to this size.</p>
</dd>
<dt>pad_width (int): General padding width. This can be overruled</dt><dd><p>by individual settings below.</p>
</dd>
</dl>
<p>pad_left (int): Number of extra pad characters on the left.
pad_right (int): Number of extra pad characters on the right.
pad_top (int): Number of extra pad lines top (will pad with <cite>vpad_char</cite>).
pad_bottom (int): Number of extra pad lines bottom (will pad with <cite>vpad_char</cite>).
pad_char (str)- pad character to use for padding. This is overruled</p>
<dt>hpad_char (str): Pad character to use both for extra horizontal</dt><dd><p>padding (default <cite>” “</cite>).</p>
</dd>
<dt>vpad_char (str): Pad character to use for extra vertical padding</dt><dd><p>and for vertical fill (default <cite>” “</cite>).</p>
</dd>
<dt>fill_char (str): Character used to filling (expanding cells to</dt><dd><p>desired size). This can be overruled by individual settings below.</p>
</dd>
</dl>
<p>hfill_char (str): Character used for horizontal fill (default <cite>” “</cite>).
vfill_char (str): Character used for vertical fill (default <cite>” “</cite>).
align (str): Should be one of “l”, “r” or “c” for left-, right- or center</p>
<blockquote>
<div><p>horizontal alignment respectively. Default is left-aligned.</p>
</div></blockquote>
<dlclass="simple">
<dt>valign (str): Should be one of “t”, “b” or “c” for top-, bottom and center</dt><dd><p>vertical alignment respectively. Default is centered.</p>
</dd>
<dt>border_width (int): General border width. This is overruled</dt><dd><p>by individual settings below.</p>
</dd>
</dl>
<p>border_left (int): Left border width.
border_right (int): Right border width.
border_top (int): Top border width.
border_bottom (int): Bottom border width.
border_char (str): This will use a single border char for all borders.</p>
<blockquote>
<div><p>overruled by individual settings below.</p>
</div></blockquote>
<p>border_left_char (str): Char used for left border.
border_right_char (str): Char used for right border.
border_top_char (str): Char used for top border.
border_bottom_char (str): Char user for bottom border.
corner_char (str): Character used when two borders cross. (default is “”).</p>
<blockquote>
<div><p>This is overruled by individual settings below.</p>
</div></blockquote>
<p>corner_top_left_char (str): Char used for “nw” corner.
corner_top_right_char (str): Char used for “ne” corner.
corner_bottom_left_char (str): Char used for “sw” corner.
corner_bottom_right_char (str): Char used for “se” corner.
crop_string (str): String to use when cropping sideways, default is <cite>‘[…]’</cite>.
crop (bool): Crop contentof cell rather than expand vertically, default=`False`.
enforce_size (bool): If true, the width/height of the cell is</p>
<blockquote>
<div><p>strictly enforced and extra text will be cropped rather than the
cell growing vertically.</p>
</div></blockquote>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>Exception</strong>– for impossible cell size requirements where the
border width or height cannot fit, or the content is too
small.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._align">
<codeclass="sig-name descname">_align</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._align"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._align"title="Permalink to this definition">¶</a></dt>
<dd><p>Align list of rows of cell. Whitespace characters will be stripped
if there is only one whitespace character - otherwise, it’s assumed
the caller may be trying some manual formatting in the text.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong> (<em>str</em>) – Text to align.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Aligned result.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._border">
<codeclass="sig-name descname">_border</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._border"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._border"title="Permalink to this definition">¶</a></dt>
<dd><p>Add borders to the cell.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong> (<em>str</em>) – Text to surround with borders.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Text with borders.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._center">
<codeclass="sig-name descname">_center</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width</em>, <emclass="sig-param">pad_char</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._center"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._center"title="Permalink to this definition">¶</a></dt>
<dd><p>Horizontally center text on line of certain width, using padding.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – The text to center.</p></li>
<li><p><strong>width</strong> (<em>int</em>) – How wide the area is (in characters) where <cite>text</cite>
should be centered.</p></li>
<li><p><strong>pad_char</strong> (<em>str</em>) – Which padding character to use.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Centered text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._crop">
<codeclass="sig-name descname">_crop</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._crop"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._crop"title="Permalink to this definition">¶</a></dt>
<dd><p>Apply cropping of text.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – The text to crop.</p></li>
<li><p><strong>width</strong> (<em>int</em>) – The width to crop <cite>text</cite> to.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._fit_width">
<codeclass="sig-name descname">_fit_width</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._fit_width"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._fit_width"title="Permalink to this definition">¶</a></dt>
<dd><p>Split too-long lines to fit the desired width of the Cell.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong> (<em>str</em>) – Text to adjust to the cell’s width.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The adjusted text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>adjusted data (str)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This also updates <cite>raw_width</cite>.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._pad">
<codeclass="sig-name descname">_pad</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._pad"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._pad"title="Permalink to this definition">¶</a></dt>
<dd><p>Pad data with extra characters on all sides.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong> (<em>str</em>) – Text to pad.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Padded text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._reformat">
<codeclass="sig-name descname">_reformat</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._reformat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._reformat"title="Permalink to this definition">¶</a></dt>
<dd><p>Apply all EvCells’ formatting operations.</p>
<codeclass="sig-name descname">_split_lines</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._split_lines"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._split_lines"title="Permalink to this definition">¶</a></dt>
<dd><p>Simply split by linebreaks</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – text to split.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>split text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>split (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell._valign">
<codeclass="sig-name descname">_valign</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell._valign"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell._valign"title="Permalink to this definition">¶</a></dt>
<dd><p>Align cell vertically</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>data</strong> (<em>str</em>) – Text to align.</p>
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Get data, padded and aligned in the form of a list of lines.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell.get_height">
<codeclass="sig-name descname">get_height</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.get_height"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.get_height"title="Permalink to this definition">¶</a></dt>
<dd><p>Get natural height of cell, including padding.</p>
<codeclass="sig-name descname">get_min_height</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.get_min_height"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.get_min_height"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the minimum possible height of cell, including at least
one line for data.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>The mininum height of cell.</p>
<codeclass="sig-name descname">get_min_width</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.get_min_width"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.get_min_width"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the minimum possible width of cell, including at least one
character-width for data.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>The minimum width of cell.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>min_width (int)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell.get_width">
<codeclass="sig-name descname">get_width</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.get_width"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.get_width"title="Permalink to this definition">¶</a></dt>
<dd><p>Get natural width of cell, including padding.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Width of cell.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>natural_width (int)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvCell.reformat">
<codeclass="sig-name descname">reformat</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.reformat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.reformat"title="Permalink to this definition">¶</a></dt>
<dd><p>Reformat the EvCell with new options</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>The available keyword arguments are the same as for <cite>EvCell.__init__</cite>.</p>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>Exception</strong>– If the cells cannot shrink enough to accomodate
<codeclass="sig-name descname">replace_data</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvCell.replace_data"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvCell.replace_data"title="Permalink to this definition">¶</a></dt>
<dd><p>Replace cell data. This causes a full reformat of the cell.</p>
<p>The available keyword arguments are the same as for
<cite>EvCell.__init__</cite>.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evtable.EvColumn">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">EvColumn</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvColumn"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvColumn"title="Permalink to this definition">¶</a></dt>
<p>This class holds a list of Cells to represent a column of a table.
It holds operations and settings that affect <em>all</em> cells in the
column.</p>
<p>Columns are not intended to be used stand-alone; they should be
incorporated into an EvTable (like EvCells)</p>
<dlclass="method">
<dtid="evennia.utils.evtable.EvColumn.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvColumn.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvColumn.__init__"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>for each row in the column</strong> (<aclass="reference internal"href="#evennia.utils.optionclasses.Text"title="evennia.utils.optionclasses.Text"><em>Text</em></a>) –</p>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>All <cite>EvCell.__init_</cite> keywords are available, these
settings will be persistently applied to every Cell in the
column.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvColumn._balance">
<codeclass="sig-name descname">_balance</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvColumn._balance"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvColumn._balance"title="Permalink to this definition">¶</a></dt>
<dd><p>Make sure to adjust the width of all cells so we form a
coherent and lined-up column. Will enforce column-specific
options to cells.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Extra keywords to modify the column setting. Same keywords
as in <cite>EvCell.__init__</cite>.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvColumn.add_rows">
<codeclass="sig-name descname">add_rows</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvColumn.add_rows"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvColumn.add_rows"title="Permalink to this definition">¶</a></dt>
<dd><p>Add new cells to column. They will be inserted as
a series of rows. It will inherit the options
of the rest of the column’s cells (use update to change
options).</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>for the new cells</strong> (<em>Texts</em>) –</p></li>
<li><p><strong>ypos</strong> (<em>int</em><em>, </em><em>optional</em>) – Index position in table before which to insert the
new column. Uses Python indexing, so to insert at the top,
use <cite>ypos=0</cite>. If not given, data will be inserted at the end
of the column.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Available keywods as per <cite>EvCell.__init__</cite>.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvColumn.reformat">
<codeclass="sig-name descname">reformat</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvColumn.reformat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvColumn.reformat"title="Permalink to this definition">¶</a></dt>
<dd><p>Change the options for the column.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Keywords as per <cite>EvCell.__init__</cite>.</p>
<codeclass="sig-name descname">reformat_cell</code><spanclass="sig-paren">(</span><emclass="sig-param">index</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvColumn.reformat_cell"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvColumn.reformat_cell"title="Permalink to this definition">¶</a></dt>
<dd><p>reformat cell at given index, keeping column options if
necessary.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>index</strong> (<em>int</em>) – Index location of the cell in the column,
starting from 0 for the first row to Nrows-1.</p>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Keywords as per <cite>EvCell.__init__</cite>.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.evtable.EvTable">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">EvTable</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable"title="Permalink to this definition">¶</a></dt>
<p>The table class holds a list of EvColumns, each consisting of EvCells so
that the result is a 2D matrix.</p>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable.__init__"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>texts for the table.</strong> (<em>Header</em>) –</p>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>table (list of lists or list of <cite>EvColumns</cite>, optional):</dt><dd><p>This is used to build the table in a quick way. If not
given, the table will start out empty and <cite>add_</cite> methods
need to be used to add rows/columns.</p>
</dd>
<dt>header (bool, optional): <cite>True</cite>/<cite>False</cite> - turn off the</dt><dd><p>header texts (<cite>*args</cite>) being treated as a header (such as
not adding extra underlining)</p>
</dd>
<dt>pad_width (int, optional): How much empty space to pad your cells with</dt><dd><p>(default is 1)</p>
</dd>
<dt>border (str, optional)): The border style to use. This is one of</dt><dd><ulclass="simple">
<li><p><cite>None</cite> - No border drawing at all.</p></li>
<li><p>“table” - only a border around the whole table.</p></li>
<li><p>“tablecols” - table and column borders. (default)</p></li>
<li><p>“header” - only border under header.</p></li>
<li><p>“cols” - only vertical borders.</p></li>
<li><p>“incols” - vertical borders, no outer edges.</p></li>
<li><p>“rows” - only borders between rows.</p></li>
<li><p>“cells” - border around all cells.</p></li>
</ul>
</dd>
<dt>border_width (int, optional): Width of table borders, if border is active.</dt><dd><p>Note that widths wider than 1 may give artifacts in the corners. Default is 1.</p>
</dd>
<dt>corner_char (str, optional): Character to use in corners when border is active.</dt><dd><p>Default is <cite>+</cite>.</p>
</dd>
<dt>corner_top_left_char (str, optional): Character used for “nw” corner of table.</dt><dd><p>Defaults to <cite>corner_char</cite>.</p>
</dd>
<dt>corner_top_right_char (str, optional): Character used for “ne” corner of table.</dt><dd><p>Defaults to <cite>corner_char</cite>.</p>
</dd>
<dt>corner_bottom_left_char (str, optional): Character used for “sw” corner of table.</dt><dd><p>Defaults to <cite>corner_char</cite>.</p>
</dd>
<dt>corner_bottom_right_char (str, optional): Character used for “se” corner of table.</dt><dd><p>Defaults to <cite>corner_char</cite>.</p>
</dd>
<dt>pretty_corners (bool, optional): Use custom characters to</dt><dd><p>make the table corners look “rounded”. Uses UTF-8
characters. Defaults to <cite>False</cite> for maximum compatibility with various displays
that may occationally have issues with UTF-8 characters.</p>
</dd>
<dt>header_line_char (str, optional): Character to use for underlining</dt><dd><p>the header row (default is ‘~’). Requires <cite>border</cite> to not be <cite>None</cite>.</p>
</dd>
<dt>width (int, optional): Fixed width of table. If not set,</dt><dd><p>width is set by the total width of each column. This will
resize individual columns in the vertical direction to fit.</p>
</dd>
<dt>height (int, optional): Fixed height of table. Defaults to being unset. Width is</dt><dd><p>still given precedence. If given, table cells will crop text rather
than expand vertically.</p>
</dd>
<dt>evenwidth (bool, optional): Used with the <cite>width</cite> keyword. Adjusts columns to have as even width as</dt><dd><p>possible. This often looks best also for mixed-length tables. Default is <cite>False</cite>.</p>
</dd>
<dt>maxwidth (int, optional): This will set a maximum width</dt><dd><p>of the table while allowing it to be smaller. Only if it grows wider than this
size will it be resized by expanding horizontally (or crop <cite>height</cite> is given).
This keyword has no meaning if <cite>width</cite> is set.</p>
</dd>
</dl>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>Exception</strong>– If given erroneous input or width settings for the data.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Beyond those table-specific keywords, the non-overlapping keywords
of <cite>EcCell.__init__</cite> are also available. These will be passed down
to every cell in the table.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable._balance">
<codeclass="sig-name descname">_balance</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable._balance"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable._balance"title="Permalink to this definition">¶</a></dt>
<dd><p>Balance the table. This means to make sure
all cells on the same row have the same height,
that all columns have the same number of rows
and that the table fits within the given width.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable._borders">
<codeclass="sig-name descname">_borders</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable._borders"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable._borders"title="Permalink to this definition">¶</a></dt>
<dd><p>Add borders to table. This is called from self._balance.</p>
<codeclass="sig-name descname">_cellborders</code><spanclass="sig-paren">(</span><emclass="sig-param">ix</em>, <emclass="sig-param">iy</em>, <emclass="sig-param">nx</em>, <emclass="sig-param">ny</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable._cellborders"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable._cellborders"title="Permalink to this definition">¶</a></dt>
<dd><p>Adds borders to the table by adjusting the input kwarg to
instruct cells to build a border in the right positions.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>ix</strong> (<em>int</em>) – x index positions in table.</p></li>
<li><p><strong>iy</strong> (<em>int</em>) – y index positions in table.</p></li>
<li><p><strong>nx</strong> (<em>int</em>) – x size of table.</p></li>
<li><p><strong>ny</strong> (<em>int</em>) – y size of table.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Keywords as per <cite>EvTable.__init__</cite>.</p>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>string with the correct borders.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>table (str)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>A copy of the kwarg is returned to the cell. This is method
<codeclass="sig-name descname">_generate_lines</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable._generate_lines"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable._generate_lines"title="Permalink to this definition">¶</a></dt>
<dd><p>Generates lines across all columns
(each cell may contain multiple lines)
This will also balance the table.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable.add_column">
<codeclass="sig-name descname">add_column</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable.add_column"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable.add_column"title="Permalink to this definition">¶</a></dt>
<dd><p>Add a column to table. If there are more rows in new column
than there are rows in the current table, the table will
expand with empty rows in the other columns. If too few, the
new column with get new empty rows. All filling rows are added
to the end.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>args</strong> (<cite>EvColum</cite> or multiple strings) – Either a single EvColumn instance or
a number of data string arguments to be used to create a new column.</p></li>
<li><p><strong>header</strong> (<em>str</em><em>, </em><em>optional</em>) – The header text for the column</p></li>
<li><p><strong>xpos</strong> (<em>int</em><em>, </em><em>optional</em>) – Index position in table <em>before</em> which
to input new column. If not given, column will be added to the end
of the table. Uses Python indexing (so first column is <cite>xpos=0</cite>)</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Other keywords as per <cite>Cell.__init__</cite>.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable.add_header">
<codeclass="sig-name descname">add_header</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable.add_header"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable.add_header"title="Permalink to this definition">¶</a></dt>
<dd><p>Add header to table. This is a number of texts to be put at
the top of the table. They will replace an existing header.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>args</strong> (<em>str</em>) – These strings will be used as the header texts.</p>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Same keywords as per <cite>EvTable.__init__</cite>. Will be applied
to the new header’s cells.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable.add_row">
<codeclass="sig-name descname">add_row</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable.add_row"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable.add_row"title="Permalink to this definition">¶</a></dt>
<dd><p>Add a row to table (not a header). If there are more cells in
the given row than there are cells in the current table the
table will be expanded with empty columns to match. These will
be added to the end of the table. In the same way, adding a
line with too few cells will lead to the last ones getting
padded.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>args</strong> (<em>str</em>) – Any number of string argumnets to use as the
data in the row (one cell per argument).</p></li>
<li><p><strong>ypos</strong> (<em>int</em><em>, </em><em>optional</em>) – Index position in table before which to
input new row. If not given, will be added to the end of the table.
Uses Python indexing (so first row is <cite>ypos=0</cite>)</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Other keywords are as per <cite>EvCell.__init__</cite>.</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable.get">
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Return lines of table as a list.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>The lines of the table, in order.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>table_lines (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.evtable.EvTable.reformat">
<codeclass="sig-name descname">reformat</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable.reformat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable.reformat"title="Permalink to this definition">¶</a></dt>
<dd><p>Force a re-shape of the entire table.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Table options as per <cite>EvTable.__init__</cite>.</p>
<codeclass="sig-name descname">reformat_column</code><spanclass="sig-paren">(</span><emclass="sig-param">index</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#EvTable.reformat_column"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.EvTable.reformat_column"title="Permalink to this definition">¶</a></dt>
<dd><p>Sends custom options to a specific column in the table.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>index</strong> (<em>int</em>) – Which column to reformat. The column index is
given from 0 to Ncolumns-1.</p>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>Column options as per <cite>EvCell.__init__</cite>.</p>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>Exception</strong>– if an invalid index is found.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evtable._test">
<codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">_test</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#_test"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable._test"title="Permalink to this definition">¶</a></dt>
<dd><p>Test</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evtable._test2">
<codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">_test2</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#_test2"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable._test2"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.evtable._to_ansi">
<codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">_to_ansi</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#_to_ansi"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable._to_ansi"title="Permalink to this definition">¶</a></dt>
<dd><p>convert to ANSIString.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>obj</strong> (<em>str</em>) – Convert incoming text to
be ANSI aware ANSIStrings.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evtable.fill">
<codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">fill</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width=78</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#fill"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.fill"title="Permalink to this definition">¶</a></dt>
<dd><p>Fill a single paragraph of text, returning a new string.</p>
<p>Reformat the single paragraph in ‘text’ to fit in lines of no more
than ‘width’ columns, and return a new string containing the entire
wrapped paragraph. As with wrap(), tabs are expanded and other
whitespace characters converted to space.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – Text to fill.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – Width of fill area.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>See TextWrapper class for available keyword args to customize
filling behaviour.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.evtable.wrap">
<codeclass="sig-prename descclassname">evennia.utils.evtable.</code><codeclass="sig-name descname">wrap</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width=78</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evtable.html#wrap"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evtable.wrap"title="Permalink to this definition">¶</a></dt>
<dd><p>Wrap a single paragraph of text, returning a list of wrapped lines.</p>
<p>Reformat the single paragraph in ‘text’ so it fits in lines of no
more than ‘width’ columns, and return a list of wrapped lines. By
default, tabs in ‘text’ are expanded with string.expandtabs(), and
all other whitespace characters (including newline) are converted to</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – Text to wrap.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – Width to wrap <cite>text</cite> to.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>See TextWrapper class for available keyword args to customize
<spanid="evennia-utils-gametime-module"></span><h2>evennia.utils.gametime module<aclass="headerlink"href="#module-evennia.utils.gametime"title="Permalink to this headline">¶</a></h2>
<p>The gametime module handles the global passage of time in the mud.</p>
<p>It also supplies some useful methods to convert between
in-mud time and real-world time as well allows to get the
total runtime of the server and the current uptime.</p>
<dlclass="class">
<dtid="evennia.utils.gametime.TimeScript">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">TimeScript</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#TimeScript"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.TimeScript"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-name descname">DoesNotExist</code><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.DoesNotExist"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-name descname">MultipleObjectsReturned</code><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.MultipleObjectsReturned"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_meta</code><emclass="property"> = <Options for TimeScript></em><aclass="headerlink"href="#evennia.utils.gametime.TimeScript._meta"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_repeat</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#TimeScript.at_repeat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.at_repeat"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_script_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#TimeScript.at_script_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.at_script_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>The script is created.</p>
</dd></dl>
<dlclass="attribute">
<dtid="evennia.utils.gametime.TimeScript.path">
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.gametime.TimeScript'</em><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.path"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">typename</code><emclass="property"> = 'TimeScript'</em><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.typename"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.gametime.game_epoch">
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">game_epoch</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#game_epoch"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.game_epoch"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the game epoch.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.gametime.gametime">
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">gametime</code><spanclass="sig-paren">(</span><emclass="sig-param">absolute=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#gametime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.gametime"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the total gametime of the server since first start (minus downtimes)</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>absolute</strong> (<em>bool</em><em>, </em><em>optional</em>) – Get the absolute game time, including
the epoch. This could be converted to an absolute in-game
date.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The gametime as a virtual timestamp.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>time (float)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>If one is using a standard calendar, one could convert the unformatted
return to a date using Python’s standard <cite>datetime</cite> module like this:
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">portal_uptime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#portal_uptime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.portal_uptime"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the current uptime of the portal.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>The uptime of the portal.</p>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">real_seconds_until</code><spanclass="sig-paren">(</span><emclass="sig-param">sec=None</em>, <emclass="sig-param">min=None</em>, <emclass="sig-param">hour=None</em>, <emclass="sig-param">day=None</em>, <emclass="sig-param">month=None</em>, <emclass="sig-param">year=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#real_seconds_until"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.real_seconds_until"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the real seconds until game time.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>sec</strong> (<em>int</em><em> or </em><em>None</em>) – number of absolute seconds.</p></li>
<li><p><strong>min</strong> (<em>int</em><em> or </em><em>None</em>) – number of absolute minutes.</p></li>
<li><p><strong>hour</strong> (<em>int</em><em> or </em><em>None</em>) – number of absolute hours.</p></li>
<li><p><strong>day</strong> (<em>int</em><em> or </em><em>None</em>) – number of absolute days.</p></li>
<li><p><strong>month</strong> (<em>int</em><em> or </em><em>None</em>) – number of absolute months.</p></li>
<li><p><strong>year</strong> (<em>int</em><em> or </em><em>None</em>) – number of absolute years.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The number of real seconds before the given game time is up.</p>
</dd>
</dl>
<pclass="rubric">Example</p>
<p>real_seconds_until(hour=5, min=10, sec=0)</p>
<p>If the game time is 5:00, TIME_FACTOR is set to 2 and you ask
the number of seconds until it’s 5:10, then this function should
return 300 (5 minutes).</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.gametime.reset_gametime">
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">reset_gametime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#reset_gametime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.reset_gametime"title="Permalink to this definition">¶</a></dt>
<dd><p>Resets the game time to make it start from the current time. Note that
the epoch set by <cite>settings.TIME_GAME_EPOCH</cite> will still apply.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.gametime.runtime">
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">runtime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#runtime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.runtime"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the total runtime of the server since first start (minus
downtimes)</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>format</strong> (<em>bool</em><em>, </em><em>optional</em>) – Format into a time representation.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The runtime or the same time split up</dt><dd><p>into time units.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>time (float or tuple)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.gametime.schedule">
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">schedule</code><spanclass="sig-paren">(</span><emclass="sig-param">callback</em>, <emclass="sig-param">repeat=False</em>, <emclass="sig-param">sec=None</em>, <emclass="sig-param">min=None</em>, <emclass="sig-param">hour=None</em>, <emclass="sig-param">day=None</em>, <emclass="sig-param">month=None</em>, <emclass="sig-param">year=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#schedule"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.schedule"title="Permalink to this definition">¶</a></dt>
<dd><p>Call a callback at a given in-game time.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>callback</strong> (<em>function</em>) – The callback function that will be called. Note
that the callback must be a module-level function, since the script will
be persistent.</p></li>
<li><p><strong>repeat</strong> (<em>bool</em><em>, </em><em>optional</em>) – Defines if the callback should be called regularly
at the specified time.</p></li>
<li><p><strong>sec</strong> (<em>int</em><em> or </em><em>None</em>) – Number of absolute game seconds at which to run repeat.</p></li>
<li><p><strong>min</strong> (<em>int</em><em> or </em><em>None</em>) – Number of absolute minutes.</p></li>
<li><p><strong>hour</strong> (<em>int</em><em> or </em><em>None</em>) – Number of absolute hours.</p></li>
<li><p><strong>day</strong> (<em>int</em><em> or </em><em>None</em>) – Number of absolute days.</p></li>
<li><p><strong>month</strong> (<em>int</em><em> or </em><em>None</em>) – Number of absolute months.</p></li>
<li><p><strong>year</strong> (<em>int</em><em> or </em><em>None</em>) – Number of absolute years.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The created Script handling the sceduling.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>script (Script)</p>
</dd>
</dl>
<pclass="rubric">Examples</p>
<p>schedule(func, min=5, sec=0) # Will call 5 minutes past the next (in-game) hour.
schedule(func, hour=2, min=30, sec=0) # Will call the next (in-game) day at 02:30.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.gametime.server_epoch">
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">server_epoch</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#server_epoch"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.server_epoch"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the server epoch. We may need to calculate this on the fly.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.gametime.uptime">
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">uptime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#uptime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.uptime"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the current uptime of the server since last reload</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>format</strong> (<em>bool</em><em>, </em><em>optional</em>) – Format into time representation.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The uptime or the same time split up</dt><dd><p>into time units.</p>
<spanid="evennia-utils-inlinefuncs-module"></span><h2>evennia.utils.inlinefuncs module<aclass="headerlink"href="#module-evennia.utils.inlinefuncs"title="Permalink to this headline">¶</a></h2>
<p>Inline functions (nested form).</p>
<p>This parser accepts nested inlinefunctions on the form</p>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">InlinefuncError</code><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#InlinefuncError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.InlinefuncError"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">NickTemplateInvalid</code><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#NickTemplateInvalid"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.NickTemplateInvalid"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">ParseStack</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#ParseStack"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.ParseStack"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#ParseStack.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.ParseStack.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-name descname">append</code><spanclass="sig-paren">(</span><emclass="sig-param">item</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#ParseStack.append"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.ParseStack.append"title="Permalink to this definition">¶</a></dt>
<dd><p>The stack will merge strings, add other things as normal</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.inlinefuncs.clr">
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">clr</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#clr"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.clr"title="Permalink to this definition">¶</a></dt>
<dd><p>Inlinefunc. Colorizes nested text.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>startclr</strong> (<em>str</em><em>, </em><em>optional</em>) – An ANSI color abbreviation without the
prefix <cite>|</cite>, such as <cite>r</cite> (red foreground) or <cite>[r</cite> (red background).</p></li>
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">crop</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#crop"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.crop"title="Permalink to this definition">¶</a></dt>
<dd><p>Inlinefunc. Crops ingoing text to given widths.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em><em>, </em><em>optional</em>) – Text to crop.</p></li>
<li><p><strong>width</strong> (<em>str</em><em>, </em><em>optional</em>) – Will be converted to an integer. Width of
crop in characters.</p></li>
<li><p><strong>suffix</strong> (<em>str</em><em>, </em><em>optional</em>) – End string to mark the fact that a part
of the string was cropped. Defaults to <cite>[…]</cite>.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>session (Session): Session performing the crop.</p>
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">initialize_nick_templates</code><spanclass="sig-paren">(</span><emclass="sig-param">in_template</em>, <emclass="sig-param">out_template</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#initialize_nick_templates"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.initialize_nick_templates"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the nick templates for matching and remapping a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>in_template</strong> (<em>str</em>) – The template to be used for nick recognition.</p></li>
<li><p><strong>out_template</strong> (<em>str</em>) – The template to be used to replace the string
matched by the in_template.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p>Regex to match against strings
template (str): Template with markers {arg1}, {arg2}, etc for</p>
<blockquote>
<div><p>replacement using the standard .format method.</p>
</div></blockquote>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>regex (regex)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.typeclasses.html#evennia.typeclasses.attributes.NickTemplateInvalid"title="evennia.typeclasses.attributes.NickTemplateInvalid"><strong>NickTemplateInvalid</strong></a>– If the in/out template does not have a matching
number of $args.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.inlinefuncs.nomatch">
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">nomatch</code><spanclass="sig-paren">(</span><emclass="sig-param">name</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#nomatch"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.nomatch"title="Permalink to this definition">¶</a></dt>
<dd><p>Default implementation of nomatch returns the function as-is as a string.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.inlinefuncs.null">
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">null</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#null"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.null"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.inlinefuncs.pad">
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">pad</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#pad"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.pad"title="Permalink to this definition">¶</a></dt>
<dd><p>Inlinefunc. Pads text to given width.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em><em>, </em><em>optional</em>) – Text to pad.</p></li>
<li><p><strong>width</strong> (<em>str</em><em>, </em><em>optional</em>) – Will be converted to integer. Width
of padding.</p></li>
<li><p><strong>align</strong> (<em>str</em><em>, </em><em>optional</em>) – Alignment of padding; one of ‘c’, ‘l’ or ‘r’.</p></li>
<li><p><strong>fillchar</strong> (<em>str</em><em>, </em><em>optional</em>) – Character used for padding. Defaults to a space.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>session (Session): Session performing the pad.</p>
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">parse_nick_template</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">template_regex</em>, <emclass="sig-param">outtemplate</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#parse_nick_template"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.parse_nick_template"title="Permalink to this definition">¶</a></dt>
<dd><p>Parse a text using a template and map it to another template</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string</strong> (<em>str</em>) – The input string to processj</p></li>
<li><p><strong>template_regex</strong> (<em>regex</em>) – A template regex created with
initialize_nick_template.</p></li>
<li><p><strong>outtemplate</strong> (<em>str</em>) – The template to which to map the matches
produced by the template_regex. This should have $1, $2,
etc to match the regex.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.inlinefuncs.space">
<codeclass="sig-prename descclassname">evennia.utils.inlinefuncs.</code><codeclass="sig-name descname">space</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/inlinefuncs.html#space"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.inlinefuncs.space"title="Permalink to this definition">¶</a></dt>
<dd><p>Inlinefunc. Inserts an arbitrary number of spaces. Defaults to 4 spaces.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>spaces</strong> (<em>int</em><em>, </em><em>optional</em>) – The number of spaces to insert.</p>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><p>session (Session): Session performing the crop.</p>
<spanid="evennia-utils-logger-module"></span><h2>evennia.utils.logger module<aclass="headerlink"href="#module-evennia.utils.logger"title="Permalink to this headline">¶</a></h2>
<p>Logging facilities</p>
<p>These are thin wrappers on top of Twisted’s logging facilities; logs
are all directed either to stdout (if Evennia is running in
interactive mode) or to $GAME_DIR/server/logs.</p>
<p>The log_file() function uses its own threading system to log to
arbitrary files in $GAME_DIR/server/logs.</p>
<p>Note: All logging functions have two aliases, log_type() and
log_typemsg(). This is for historical, back-compatible reasons.</p>
<dlclass="class">
<dtid="evennia.utils.logger.EvenniaLogFile">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">EvenniaLogFile</code><spanclass="sig-paren">(</span><emclass="sig-param">name</em>, <emclass="sig-param">directory</em>, <emclass="sig-param">rotateLength=1000000</em>, <emclass="sig-param">defaultMode=None</em>, <emclass="sig-param">maxRotatedFiles=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#EvenniaLogFile"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.EvenniaLogFile"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">num_lines_to_append</code><emclass="property"> = 20</em><aclass="headerlink"href="#evennia.utils.logger.EvenniaLogFile.num_lines_to_append"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">readlines</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#EvenniaLogFile.readlines"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.EvenniaLogFile.readlines"title="Permalink to this definition">¶</a></dt>
<dd><p>Convenience method for accessing our _file attribute’s readlines method,
which is used in tail_log_function.
:param *args: same args as file.readlines
:param **kwargs: same kwargs as file.readlines</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>lines from our _file attribute.</p>
<codeclass="sig-name descname">rotate</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#EvenniaLogFile.rotate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.EvenniaLogFile.rotate"title="Permalink to this definition">¶</a></dt>
<dd><p>Rotates our log file and appends some number of lines from
the previous log to the start of the new one.</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.logger.EvenniaLogFile.seek">
<codeclass="sig-name descname">seek</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#EvenniaLogFile.seek"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.EvenniaLogFile.seek"title="Permalink to this definition">¶</a></dt>
<dd><p>Convenience method for accessing our _file attribute’s seek method,
<codeclass="sig-name descname">settings</code><emclass="property"> = <LazySettings "server.conf.settings"></em><aclass="headerlink"href="#evennia.utils.logger.EvenniaLogFile.settings"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.logger.PortalLogObserver">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">PortalLogObserver</code><spanclass="sig-paren">(</span><emclass="sig-param">f</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#PortalLogObserver"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.PortalLogObserver"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">emit</code><spanclass="sig-paren">(</span><emclass="sig-param">eventDict</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#PortalLogObserver.emit"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.PortalLogObserver.emit"title="Permalink to this definition">¶</a></dt>
<dd><p>Copied from Twisted parent, to change logging output</p>
<codeclass="sig-name descname">prefix</code><emclass="property"> = ' |Portal| '</em><aclass="headerlink"href="#evennia.utils.logger.PortalLogObserver.prefix"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">timeFormat</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.utils.logger.PortalLogObserver.timeFormat"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.logger.ServerLogObserver">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">ServerLogObserver</code><spanclass="sig-paren">(</span><emclass="sig-param">f</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#ServerLogObserver"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.ServerLogObserver"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">prefix</code><emclass="property"> = ' '</em><aclass="headerlink"href="#evennia.utils.logger.ServerLogObserver.prefix"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.logger.WeeklyLogFile">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">WeeklyLogFile</code><spanclass="sig-paren">(</span><emclass="sig-param">name</em>, <emclass="sig-param">directory</em>, <emclass="sig-param">defaultMode=None</em>, <emclass="sig-param">day_rotation=7</em>, <emclass="sig-param">max_size=1000000</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#WeeklyLogFile"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.WeeklyLogFile"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">name</em>, <emclass="sig-param">directory</em>, <emclass="sig-param">defaultMode=None</em>, <emclass="sig-param">day_rotation=7</em>, <emclass="sig-param">max_size=1000000</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#WeeklyLogFile.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.WeeklyLogFile.__init__"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>name</strong> (<em>str</em>) – Name of log file.</p></li>
<li><p><strong>directory</strong> (<em>str</em>) – Directory holding the file.</p></li>
<li><p><strong>defaultMode</strong> (<em>str</em>) – Permissions used to create file. Defaults to
current permissions of this file if it exists.</p></li>
<li><p><strong>day_rotation</strong> (<em>int</em>) – How often to rotate the file.</p></li>
<li><p><strong>max_size</strong> (<em>int</em>) – Max size of log file before rotation (regardless of
<codeclass="sig-name descname">_openFile</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#WeeklyLogFile._openFile"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.WeeklyLogFile._openFile"title="Permalink to this definition">¶</a></dt>
<dd><p>Open the log file.</p>
<p>The log file is always opened in binary mode.</p>
<codeclass="sig-name descname">shouldRotate</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#WeeklyLogFile.shouldRotate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.WeeklyLogFile.shouldRotate"title="Permalink to this definition">¶</a></dt>
<dd><p>Rotate when the date has changed since last write</p>
<codeclass="sig-name descname">suffix</code><spanclass="sig-paren">(</span><emclass="sig-param">tupledate</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#WeeklyLogFile.suffix"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.WeeklyLogFile.suffix"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the suffix given a (year, month, day) tuple or unixtime.
Format changed to have 03 for march instead of 3 etc (retaining unix
file order)</p>
<p>If we get duplicate suffixes in location (due to hitting size limit),
we append __1, __2 etc.</p>
<pclass="rubric">Examples</p>
<p>server.log.2020_01_29
server.log.2020_01_29__1
server.log.2020_01_29__2</p>
</dd></dl>
<dlclass="method">
<dtid="evennia.utils.logger.WeeklyLogFile.write">
<codeclass="sig-name descname">write</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#WeeklyLogFile.write"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.WeeklyLogFile.write"title="Permalink to this definition">¶</a></dt>
<dd><p>Write data to log file</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger._open_log_file">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">_open_log_file</code><spanclass="sig-paren">(</span><emclass="sig-param">filename</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#_open_log_file"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger._open_log_file"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper to open the log file (always in the log dir) and cache its
handle. Will create a new file in the log dir if one didn’t
exist.</p>
<p>To avoid keeping the filehandle open indefinitely we reset it every
_LOG_FILE_HANDLE_RESET accesses. This may help resolve issues for very
long uptimes and heavy log use.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_dep">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_dep</code><spanclass="sig-paren">(</span><emclass="sig-param">depmsg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_dep"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_dep"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints a deprecation message.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>depmsg</strong> (<em>str</em>) – The deprecation message to log.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_depmsg">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_depmsg</code><spanclass="sig-paren">(</span><emclass="sig-param">depmsg</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.logger.log_depmsg"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints a deprecation message.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>depmsg</strong> (<em>str</em>) – The deprecation message to log.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_err">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_err</code><spanclass="sig-paren">(</span><emclass="sig-param">errmsg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_err"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_err"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints/logs an error message to the server log.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>errmsg</strong> (<em>str</em>) – The message to be logged.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_errmsg">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_errmsg</code><spanclass="sig-paren">(</span><emclass="sig-param">errmsg</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.logger.log_errmsg"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints/logs an error message to the server log.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>errmsg</strong> (<em>str</em>) – The message to be logged.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_file">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_file</code><spanclass="sig-paren">(</span><emclass="sig-param">msg</em>, <emclass="sig-param">filename='game.log'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_file"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_file"title="Permalink to this definition">¶</a></dt>
<dd><p>Arbitrary file logger using threads.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>msg</strong> (<em>str</em>) – String to append to logfile.</p></li>
<li><p><strong>filename</strong> (<em>str</em><em>, </em><em>optional</em>) – Defaults to ‘game.log’. All logs
will appear in the logs directory and log entries will start
on new lines following datetime info.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_info">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_info</code><spanclass="sig-paren">(</span><emclass="sig-param">infomsg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_info"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_info"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints any generic debugging/informative info that should appear in the log.</p>
<p>infomsg: (string) The message to be logged.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_infomsg">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_infomsg</code><spanclass="sig-paren">(</span><emclass="sig-param">infomsg</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.logger.log_infomsg"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints any generic debugging/informative info that should appear in the log.</p>
<p>infomsg: (string) The message to be logged.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_msg">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_msg</code><spanclass="sig-paren">(</span><emclass="sig-param">msg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_msg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_msg"title="Permalink to this definition">¶</a></dt>
<dd><p>Wrapper around log.msg call to catch any exceptions that might
occur in logging. If an exception is raised, we’ll print to
stdout instead.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>msg</strong>– The message that was passed to log.msg</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_sec">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_sec</code><spanclass="sig-paren">(</span><emclass="sig-param">secmsg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_sec"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_sec"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints a security-related message.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>secmsg</strong> (<em>str</em>) – The security message to log.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_secmsg">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_secmsg</code><spanclass="sig-paren">(</span><emclass="sig-param">secmsg</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.logger.log_secmsg"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints a security-related message.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>secmsg</strong> (<em>str</em>) – The security message to log.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_server">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_server</code><spanclass="sig-paren">(</span><emclass="sig-param">servermsg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_server"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_server"title="Permalink to this definition">¶</a></dt>
<dd><p>This is for the Portal to log captured Server stdout messages (it’s
usually only used during startup, before Server log is open)</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_trace">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_trace</code><spanclass="sig-paren">(</span><emclass="sig-param">errmsg=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_trace"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_trace"title="Permalink to this definition">¶</a></dt>
<dd><p>Log a traceback to the log. This should be called from within an
exception.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>errmsg</strong> (<em>str</em><em>, </em><em>optional</em>) – Adds an extra line with added info
at the end of the traceback in the log.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_tracemsg">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_tracemsg</code><spanclass="sig-paren">(</span><emclass="sig-param">errmsg=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.logger.log_tracemsg"title="Permalink to this definition">¶</a></dt>
<dd><p>Log a traceback to the log. This should be called from within an
exception.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>errmsg</strong> (<em>str</em><em>, </em><em>optional</em>) – Adds an extra line with added info
at the end of the traceback in the log.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_warn">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_warn</code><spanclass="sig-paren">(</span><emclass="sig-param">warnmsg</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#log_warn"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.log_warn"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints/logs any warnings that aren’t critical but should be noted.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>warnmsg</strong> (<em>str</em>) – The message to be logged.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.log_warnmsg">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">log_warnmsg</code><spanclass="sig-paren">(</span><emclass="sig-param">warnmsg</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.logger.log_warnmsg"title="Permalink to this definition">¶</a></dt>
<dd><p>Prints/logs any warnings that aren’t critical but should be noted.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>warnmsg</strong> (<em>str</em>) – The message to be logged.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.tail_log_file">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">tail_log_file</code><spanclass="sig-paren">(</span><emclass="sig-param">filename</em>, <emclass="sig-param">offset</em>, <emclass="sig-param">nlines</em>, <emclass="sig-param">callback=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#tail_log_file"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.tail_log_file"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the tail of the log file.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>filename</strong> (<em>str</em>) – The name of the log file, presumed to be in
the Evennia log dir.</p></li>
<li><p><strong>offset</strong> (<em>int</em>) – The line offset <em>from the end of the file</em> to start
reading from. 0 means to start at the latest entry.</p></li>
<li><p><strong>nlines</strong> (<em>int</em>) – How many lines to return, counting backwards
from the offset. If file is shorter, will get all lines.</p></li>
<li><p><strong>callback</strong> (<em>callable</em><em>, </em><em>optional</em>) – A function to manage the result of the
asynchronous file access. This will get a list of lines. If unset,
the tail will happen synchronously.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>This will be a deferred if <cite>callable</cite> is given,</dt><dd><p>otherwise it will be a list with The nline entries from the end of the file, or
all if the file is shorter than nlines.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>lines (deferred or list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.logger.timeformat">
<codeclass="sig-prename descclassname">evennia.utils.logger.</code><codeclass="sig-name descname">timeformat</code><spanclass="sig-paren">(</span><emclass="sig-param">when=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/logger.html#timeformat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.logger.timeformat"title="Permalink to this definition">¶</a></dt>
<dd><p>This helper function will format the current time in the same
way as the twisted logger does, including time zone info. Only
difference from official logger is that we only use two digits
for the year and don’t show timezone for CET times.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>when</strong> (<em>int</em><em>, </em><em>optional</em>) – This is a time in POSIX seconds on the form
given by time.time(). If not given, this function will
use the current time.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A formatted string of the given time.</p>
<spanid="evennia-utils-optionclasses-module"></span><h2>evennia.utils.optionclasses module<aclass="headerlink"href="#module-evennia.utils.optionclasses"title="Permalink to this headline">¶</a></h2>
<dlclass="class">
<dtid="evennia.utils.optionclasses.BaseOption">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">BaseOption</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.__init__"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>handler</strong> (<aclass="reference internal"href="#evennia.utils.optionhandler.OptionHandler"title="evennia.utils.optionhandler.OptionHandler"><em>OptionHandler</em></a>) – The OptionHandler that ‘owns’ this Option.</p></li>
<li><p><strong>key</strong> (<em>str</em>) – The name this will be used for storage in a dictionary.
Must be unique per OptionHandler.</p></li>
<li><p><strong>description</strong> (<em>str</em>) – What this Option’s text will show in commands and menus.</p></li>
<li><p><strong>default</strong>– A default value for this Option.</p></li>
<emclass="property">property </em><codeclass="sig-name descname">changed</code><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.changed"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">default</code><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.default"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">display</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.display"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.display"title="Permalink to this definition">¶</a></dt>
<dd><p>Renders the Option’s value as something pretty to look at.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>any (any): These are options passed by the caller to potentially</dt><dd><p>customize display dynamically.</p>
</dd>
</dl>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><dlclass="simple">
<dt>How the stored value should be projected to users (e.g. a raw</dt><dd><p>timedelta is pretty ugly).</p>
<codeclass="sig-name descname">load</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.load"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.load"title="Permalink to this definition">¶</a></dt>
<dd><p>Takes the provided save data, validates it, and gets this Option ready to use.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Whether loading was successful.</p>
<codeclass="sig-name descname">save</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.save"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.save"title="Permalink to this definition">¶</a></dt>
<dd><p>Stores the current value using .handler.save_handler(self.key, value, <ahref="#id181"><spanclass="problematic"id="id182">**</span></a>kwargs)
where kwargs are a combination of those passed into this function and the
ones specified by the OptionHandler.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>any (any): Not used by default. These are passed in from self.set</dt><dd><p>and allows the option to let the caller customize saving by
<codeclass="sig-name descname">serialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.serialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.serialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Serializes the save data for Attribute storage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Whatever is best for storage.</p>
<codeclass="sig-name descname">set</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.set"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.set"title="Permalink to this definition">¶</a></dt>
<dd><p>Takes user input and stores appropriately. This method allows for
passing extra instructions into the validator.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – The new value of this Option.</p></li>
<li><p><strong>kwargs</strong> (<em>any</em>) – Any kwargs will be passed into
<cite>self.validate(value, **kwargs)</cite> and <cite>self.save(**kwargs)</cite>.</p></li>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#BaseOption.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
<emclass="property">property </em><codeclass="sig-name descname">value</code><aclass="headerlink"href="#evennia.utils.optionclasses.BaseOption.value"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Boolean">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Boolean</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Boolean"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Boolean"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Boolean.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Boolean.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">display</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Boolean.display"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Boolean.display"title="Permalink to this definition">¶</a></dt>
<dd><p>Renders the Option’s value as something pretty to look at.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>any (any): These are options passed by the caller to potentially</dt><dd><p>customize display dynamically.</p>
</dd>
</dl>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><dlclass="simple">
<dt>How the stored value should be projected to users (e.g. a raw</dt><dd><p>timedelta is pretty ugly).</p>
<codeclass="sig-name descname">serialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Boolean.serialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Boolean.serialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Serializes the save data for Attribute storage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Whatever is best for storage.</p>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Boolean.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Boolean.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Color">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Color</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Color"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Color"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Color.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Color.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">display</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Color.display"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Color.display"title="Permalink to this definition">¶</a></dt>
<dd><p>Renders the Option’s value as something pretty to look at.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>any (any): These are options passed by the caller to potentially</dt><dd><p>customize display dynamically.</p>
</dd>
</dl>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><dlclass="simple">
<dt>How the stored value should be projected to users (e.g. a raw</dt><dd><p>timedelta is pretty ugly).</p>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Color.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Color.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Datetime">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Datetime</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Datetime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Datetime"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Datetime.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Datetime.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">serialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Datetime.serialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Datetime.serialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Serializes the save data for Attribute storage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Whatever is best for storage.</p>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Datetime.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Datetime.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Duration">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Duration</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Duration"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Duration"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Duration.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Duration.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">serialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Duration.serialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Duration.serialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Serializes the save data for Attribute storage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Whatever is best for storage.</p>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Duration.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Duration.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Email">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Email</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Email"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Email"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Email.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Email.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Email.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Email.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Future">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Future</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Future"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Future"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Future.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Future.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Lock">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Lock</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Lock"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Lock"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Lock.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Lock.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#PositiveInteger.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.PositiveInteger.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#PositiveInteger.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.PositiveInteger.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#SignedInteger.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.SignedInteger.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#SignedInteger.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.SignedInteger.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Text">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Text</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Text"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Text"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Text.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Text.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
displayed to user.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.optionclasses.Timezone">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionclasses.</code><codeclass="sig-name descname">Timezone</code><spanclass="sig-paren">(</span><emclass="sig-param">handler</em>, <emclass="sig-param">key</em>, <emclass="sig-param">description</em>, <emclass="sig-param">default</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Timezone"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Timezone"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">default</code><aclass="headerlink"href="#evennia.utils.optionclasses.Timezone.default"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Timezone.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Timezone.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">serialize</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Timezone.serialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Timezone.serialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Serializes the save data for Attribute storage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Whatever is best for storage.</p>
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#Timezone.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.Timezone.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
<codeclass="sig-name descname">deserialize</code><spanclass="sig-paren">(</span><emclass="sig-param">save_data</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#UnsignedInteger.deserialize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.UnsignedInteger.deserialize"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform sanity-checking on the save data as it is loaded from storage.
This isn’t the same as what validator-functions provide (those work on
user input). For example, save data might be a timedelta or a list or
some other object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>save_data</strong>– The data to check.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Whatever the Option needs to track, like a string or a</dt><dd><p>datetime. The display hook is responsible for what is actually
<codeclass="sig-name descname">validate</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionclasses.html#UnsignedInteger.validate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionclasses.UnsignedInteger.validate"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate user input, which is presumed to be a string.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>str</em>) – User input.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account that is performing the validation.
This is necessary because of other settings which may affect the
check, such as an Account’s timezone affecting how their datetime
entries are processed.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The results of the validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>any (any)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="evennia.prototypes.html#evennia.prototypes.prototypes.ValidationError"title="evennia.prototypes.prototypes.ValidationError"><strong>ValidationError</strong></a>– If input value failed validation.</p>
<codeclass="sig-name descname">validator_key</code><emclass="property"> = 'unsigned_integer'</em><aclass="headerlink"href="#evennia.utils.optionclasses.UnsignedInteger.validator_key"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-optionhandler-module"></span><h2>evennia.utils.optionhandler module<aclass="headerlink"href="#module-evennia.utils.optionhandler"title="Permalink to this headline">¶</a></h2>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.optionhandler.</code><codeclass="sig-name descname">InMemorySaveHandler</code><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#InMemorySaveHandler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.InMemorySaveHandler"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#InMemorySaveHandler.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.InMemorySaveHandler.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-name descname">add</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">value=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#InMemorySaveHandler.add"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.InMemorySaveHandler.add"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">default=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#InMemorySaveHandler.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.InMemorySaveHandler.get"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_load_option</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#OptionHandler._load_option"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.OptionHandler._load_option"title="Permalink to this definition">¶</a></dt>
<dd><p>Loads option on-demand if it has not been loaded yet.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>key</strong> (<em>str</em>) – The option being loaded.</p>
<codeclass="sig-name descname">all</code><spanclass="sig-paren">(</span><emclass="sig-param">return_objs=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#OptionHandler.all"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.OptionHandler.all"title="Permalink to this definition">¶</a></dt>
<dd><p>Get all options defined on this handler.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>return_objs</strong> (<em>bool</em><em>, </em><em>optional</em>) – Return the actual Option objects rather
than their values.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>All options on this handler, either <cite>{key: value}</cite></dt><dd><p>or <cite>{key: <Option>}</cite> if <cite>return_objs</cite> is <cite>True</cite>.</p>
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">default=None</em>, <emclass="sig-param">return_obj=False</em>, <emclass="sig-param">raise_error=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#OptionHandler.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.OptionHandler.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieves an Option stored in the handler. Will load it if it doesn’t exist.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em>) – The option key to retrieve.</p></li>
<li><p><strong>default</strong> (<em>any</em>) – What to return if the option is defined.</p></li>
<li><p><strong>return_obj</strong> (<em>bool</em><em>, </em><em>optional</em>) – If True, returns the actual option
object instead of its value.</p></li>
<li><p><strong>raise_error</strong> (<em>bool</em><em>, </em><em>optional</em>) – Raise Exception if key is not found in options.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An option value the Option itself.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>option_value (any or Option)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>KeyError</strong>– If option is not defined.</p>
<codeclass="sig-name descname">set</code><spanclass="sig-paren">(</span><emclass="sig-param">key</em>, <emclass="sig-param">value</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/optionhandler.html#OptionHandler.set"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.optionhandler.OptionHandler.set"title="Permalink to this definition">¶</a></dt>
<dd><p>Change an individual option.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em>) – The key of an option that can be changed. Allows partial matching.</p></li>
<li><p><strong>value</strong> (<em>str</em>) – The value that should be checked, coerced, and stored.:</p></li>
<li><p><strong>kwargs</strong> (<em>any</em><em>, </em><em>optional</em>) – These are passed into the Option’s validation function,
save function and display function and allows to customize either.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Value stored in option, after validation.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>value (any)</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.optionhandler._GA">
<codeclass="sig-prename descclassname">evennia.utils.optionhandler.</code><codeclass="sig-name descname">_GA</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.optionhandler._GA"title="Permalink to this definition">¶</a></dt>
<dd><p>Return getattr(self, name).</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.optionhandler._SA">
<codeclass="sig-prename descclassname">evennia.utils.optionhandler.</code><codeclass="sig-name descname">_SA</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.optionhandler._SA"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-picklefield-module"></span><h2>evennia.utils.picklefield module<aclass="headerlink"href="#module-evennia.utils.picklefield"title="Permalink to this headline">¶</a></h2>
<p>Pickle field implementation for Django.</p>
<p>Modified for Evennia by Griatch and the Evennia community.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">PickledFormField</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledFormField"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledFormField"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledFormField.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledFormField.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-name descname">clean</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledFormField.clean"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledFormField.clean"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate the given value and return its “cleaned” value as an
appropriate Python object. Raise ValidationError for any errors.</p>
<codeclass="sig-name descname">default_error_messages</code><emclass="property"> = {'invalid': 'This is not a Python Literal. You can store things like strings, integers, or floats, but you must do it by typing them as you would type them in the Python Interpreter. For instance, strings must be surrounded by quote marks. We have converted it to a string for your convenience. If it is acceptable, please hit save again.', 'required': 'This field is required.'}</em><aclass="headerlink"href="#evennia.utils.picklefield.PickledFormField.default_error_messages"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">widget</code><aclass="headerlink"href="#evennia.utils.picklefield.PickledFormField.widget"title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal"href="#evennia.utils.picklefield.PickledWidget"title="evennia.utils.picklefield.PickledWidget"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">PickledWidget</span></code></a></p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.picklefield.PickledObject">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">PickledObject</code><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObject"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObject"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">PickledObjectField</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-name descname">formfield</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.formfield"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.formfield"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a django.forms.Field instance for this field.</p>
<codeclass="sig-name descname">from_db_value</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">*args</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.from_db_value"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.from_db_value"title="Permalink to this definition">¶</a></dt>
<dd><p>B64decode and unpickle the object, optionally decompressing it.</p>
<p>If an error is raised in de-pickling and we’re sure the value is
a definite pickle, the error is allowed to propagate. If we
aren’t sure if the value is a pickle or not, then we catch the
<codeclass="sig-name descname">get_db_prep_lookup</code><spanclass="sig-paren">(</span><emclass="sig-param">lookup_type</em>, <emclass="sig-param">value</em>, <emclass="sig-param">connection=None</em>, <emclass="sig-param">prepared=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.get_db_prep_lookup"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.get_db_prep_lookup"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">get_db_prep_value</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">connection=None</em>, <emclass="sig-param">prepared=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.get_db_prep_value"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.get_db_prep_value"title="Permalink to this definition">¶</a></dt>
<dd><p>Pickle and b64encode the object, optionally compressing it.</p>
<p>The pickling protocol is specified explicitly (by default 2),
rather than as -1 or HIGHEST_PROTOCOL, because we don’t want the
protocol to change over time. If it did, <codeclass="docutils literal notranslate"><spanclass="pre">exact</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">in</span></code>
lookups would likely fail, since pickle would now be generating
<codeclass="sig-name descname">get_default</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.get_default"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.get_default"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the default value for this field.</p>
<p>The default implementation on models.Field calls force_str
on the default, which means you can’t set arbitrary Python
objects as the default. To fix this, we just return the value
without calling force_str on it. Note that if you set a
callable as a default, the field will still call it. It will
<codeclass="sig-name descname">get_internal_type</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.get_internal_type"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.get_internal_type"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">pre_save</code><spanclass="sig-paren">(</span><emclass="sig-param">model_instance</em>, <emclass="sig-param">add</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.pre_save"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.pre_save"title="Permalink to this definition">¶</a></dt>
<dd><p>Return field’s value just before saving.</p>
<codeclass="sig-name descname">value_to_string</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledObjectField.value_to_string"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledObjectField.value_to_string"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a string value of this field from the passed obj.
This is used by the serialization framework.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.picklefield.PickledWidget">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">PickledWidget</code><spanclass="sig-paren">(</span><emclass="sig-param">attrs=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledWidget"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledWidget"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">media</code><aclass="headerlink"href="#evennia.utils.picklefield.PickledWidget.media"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">render</code><spanclass="sig-paren">(</span><emclass="sig-param">name</em>, <emclass="sig-param">value</em>, <emclass="sig-param">attrs=None</em>, <emclass="sig-param">renderer=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledWidget.render"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledWidget.render"title="Permalink to this definition">¶</a></dt>
<dd><p>Display of the PickledField in django admin</p>
<codeclass="sig-name descname">value_from_datadict</code><spanclass="sig-paren">(</span><emclass="sig-param">data</em>, <emclass="sig-param">files</em>, <emclass="sig-param">name</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#PickledWidget.value_from_datadict"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.PickledWidget.value_from_datadict"title="Permalink to this definition">¶</a></dt>
<dd><p>Given a dictionary of data and this widget’s name, return the value
of this widget or None if it’s not provided.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.picklefield._ObjectWrapper">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">_ObjectWrapper</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#_ObjectWrapper"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield._ObjectWrapper"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#_ObjectWrapper.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield._ObjectWrapper.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-name descname">_obj</code><aclass="headerlink"href="#evennia.utils.picklefield._ObjectWrapper._obj"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.picklefield.dbsafe_decode">
<codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">dbsafe_decode</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">compress_object=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#dbsafe_decode"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.dbsafe_decode"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.picklefield.dbsafe_encode">
<codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">dbsafe_encode</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">compress_object=False</em>, <emclass="sig-param">pickle_protocol=4</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#dbsafe_encode"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.dbsafe_encode"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.picklefield.</code><codeclass="sig-name descname">wrap_conflictual_object</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/picklefield.html#wrap_conflictual_object"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.picklefield.wrap_conflictual_object"title="Permalink to this definition">¶</a></dt>
<spanid="evennia-utils-search-module"></span><h2>evennia.utils.search module<aclass="headerlink"href="#module-evennia.utils.search"title="Permalink to this headline">¶</a></h2>
<p>This is a convenient container gathering all the main
search methods for the various database tables.</p>
<p>It is intended to be used e.g. as</p>
<p>> from evennia.utils import search
> match = search.objects(…)</p>
<p>Note that this is not intended to be a complete listing of all search
methods! You need to refer to the respective manager to get all
possible search methods. To get to the managers from your code, import
the database model and call its ‘objects’ property.</p>
<p>Also remember that all commands in this file return lists (also if
there is only one match) unless noted otherwise.</p>
<dlclass="simple">
<dt>Example: To reach the search method ‘get_object_with_account’</dt><dd><p>in evennia/objects/managers.py:</p>
</dd>
</dl>
<p>> from evennia.objects.models import ObjectDB
> match = Object.objects.get_object_with_account(…)</p>
<dlclass="function">
<dtid="evennia.utils.search.search_object">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_object</code><spanclass="sig-paren">(</span><emclass="sig-param">searchdata</em>, <emclass="sig-param">attribute_name=None</em>, <emclass="sig-param">typeclass=None</em>, <emclass="sig-param">candidates=None</em>, <emclass="sig-param">exact=True</em>, <emclass="sig-param">use_dbref=True</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.search.search_object"title="Permalink to this definition">¶</a></dt>
<dd><p>Search as an object globally or in a list of candidates and
return results. The result is always an Object. Always returns
a list.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>searchdata</strong> (<em>str</em><em> or </em><em>Object</em>) – The entity to match for. This is
usually a key string but may also be an object itself.
By default (if no <cite>attribute_name</cite> is set), this will
search <cite>object.key</cite> and <cite>object.aliases</cite> in order.
Can also be on the form #dbref, which will (if
<cite>exact=True</cite>) be matched against primary key.</p></li>
<li><p><strong>attribute_name</strong> (<em>str</em>) – Use this named Attribute to
match searchdata against, instead of the defaults. If
this is the name of a database field (with or without
the <cite>db_</cite> prefix), that will be matched too.</p></li>
<li><p><strong>typeclass</strong> (<em>str</em><em> or </em><em>TypeClass</em>) – restrict matches to objects
having this typeclass. This will help speed up global
searches.</p></li>
<li><p><strong>candidates</strong> (<em>list</em>) – If supplied, search will
only be performed among the candidates in this list. A
common list of candidates is the contents of the
current location searched.</p></li>
<li><p><strong>exact</strong> (<em>bool</em>) – Match names/aliases exactly or partially.
Partial matching matches the beginning of words in the
names/aliases, using a matching routine to separate
multiple matches in names with multiple components (so
“bi sw” will match “Big sword”). Since this is more
expensive than exact matching, it is recommended to be
used together with the <cite>candidates</cite> keyword to limit the
number of possibilities. This value has no meaning if
searching for attributes/properties.</p></li>
<li><p><strong>use_dbref</strong> (<em>bool</em>) – If False, bypass direct lookup of a string
on the form #dbref and treat it like any string.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Matching objects</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>matches (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_account">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_account</code><spanclass="sig-paren">(</span><emclass="sig-param">ostring</em>, <emclass="sig-param">exact=True</em>, <emclass="sig-param">typeclass=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.search.search_account"title="Permalink to this definition">¶</a></dt>
<dd><p>Searches for a particular account by name or
database id.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>ostring</strong> (<em>str</em><em> or </em><em>int</em>) – A key string or database id.</p></li>
<li><p><strong>exact</strong> (<em>bool</em><em>, </em><em>optional</em>) – Only valid for string matches. If
otherwise also match also keys containing the <cite>ostring</cite>
(non-case-sensitive fuzzy match).</p></li>
<li><p><strong>typeclass</strong> (<em>str</em><em> or </em><em>Typeclass</em><em>, </em><em>optional</em>) – Limit the search only to
accounts of this typeclass.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_script">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_script</code><spanclass="sig-paren">(</span><emclass="sig-param">ostring</em>, <emclass="sig-param">obj=None</em>, <emclass="sig-param">only_timed=False</em>, <emclass="sig-param">typeclass=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.search.search_script"title="Permalink to this definition">¶</a></dt>
<dd><p>Search for a particular script.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>ostring</strong> (<em>str</em>) – Search criterion - a script dbef or key.</p></li>
<li><p><strong>obj</strong> (<em>Object</em><em>, </em><em>optional</em>) – Limit search to scripts defined on
this object</p></li>
<li><p><strong>only_timed</strong> (<em>bool</em>) – Limit search only to scripts that run
on a timer.</p></li>
<li><p><strong>typeclass</strong> (<em>class</em><em> or </em><em>str</em>) – Typeclass or path to typeclass.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_message">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_message</code><spanclass="sig-paren">(</span><emclass="sig-param">sender=None</em>, <emclass="sig-param">receiver=None</em>, <emclass="sig-param">freetext=None</em>, <emclass="sig-param">dbref=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.search.search_message"title="Permalink to this definition">¶</a></dt>
<dd><p>Search the message database for particular messages. At least
one of the arguments must be given to do a search.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>sender</strong> (<em>Object</em><em> or </em><em>Account</em><em>, </em><em>optional</em>) – Get messages sent by a particular account or object</p></li>
<li><p><strong>receiver</strong> (<em>Object</em><em>, </em><em>Account</em><em> or </em><em>Channel</em><em>, </em><em>optional</em>) – Get messages
received by a certain account,object or channel</p></li>
<li><p><strong>freetext</strong> (<em>str</em>) – Search for a text string in a message. NOTE:
This can potentially be slow, so make sure to supply one of
the other arguments to limit the search.</p></li>
<li><p><strong>dbref</strong> (<em>int</em>) – The exact database id of the message. This will override
all other search criteria since it’s unique and
always gives only one match.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A list of message matches or a single match if <cite>dbref</cite> was given.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>messages (list or <aclass="reference internal"href="evennia.comms.html#evennia.comms.models.Msg"title="evennia.comms.models.Msg">Msg</a>)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_channel">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_channel</code><spanclass="sig-paren">(</span><emclass="sig-param">ostring</em>, <emclass="sig-param">exact=True</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.search.search_channel"title="Permalink to this definition">¶</a></dt>
<dd><p>Search the channel database for a particular channel.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>ostring</strong> (<em>str</em>) – The key or database id of the channel.</p></li>
<li><p><strong>exact</strong> (<em>bool</em><em>, </em><em>optional</em>) – Require an exact (but not
case sensitive) match.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_help_entry">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_help_entry</code><spanclass="sig-paren">(</span><emclass="sig-param">ostring</em>, <emclass="sig-param">help_category=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.search.search_help_entry"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve a search entry object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>ostring</strong> (<em>str</em>) – The help topic to look for.</p></li>
<li><p><strong>category</strong> (<em>str</em>) – Limit the search to a particular help topic</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_script_tag">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_script_tag</code><spanclass="sig-paren">(</span><emclass="sig-param">key=None</em>, <emclass="sig-param">category=None</em>, <emclass="sig-param">tagtype=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/search.html#search_script_tag"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.search.search_script_tag"title="Permalink to this definition">¶</a></dt>
<dd><p>Find script based on tag or category.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>optional</em>) – The tag key to search for.</p></li>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of tag
to search for. If not set, uncategorized
tags will be searched.</p></li>
<li><p><strong>tagtype</strong> (<em>str</em><em>, </em><em>optional</em>) –‘type’ of Tag, by default
this is either <cite>None</cite> (a normal Tag), <cite>alias</cite> or
<cite>permission</cite>. This always apply to all queried tags.</p></li>
<li><p><strong>kwargs</strong> (<em>any</em>) – Other optional parameter that may be supported
by the manager method.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>List of Scripts with tags matching</dt><dd><p>the search criteria, or an empty list if no
matches were found.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>matches (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_account_tag">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_account_tag</code><spanclass="sig-paren">(</span><emclass="sig-param">key=None</em>, <emclass="sig-param">category=None</em>, <emclass="sig-param">tagtype=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/search.html#search_account_tag"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.search.search_account_tag"title="Permalink to this definition">¶</a></dt>
<dd><p>Find account based on tag or category.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>optional</em>) – The tag key to search for.</p></li>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of tag
to search for. If not set, uncategorized
tags will be searched.</p></li>
<li><p><strong>tagtype</strong> (<em>str</em><em>, </em><em>optional</em>) –‘type’ of Tag, by default
this is either <cite>None</cite> (a normal Tag), <cite>alias</cite> or
<cite>permission</cite>. This always apply to all queried tags.</p></li>
<li><p><strong>kwargs</strong> (<em>any</em>) – Other optional parameter that may be supported
by the manager method.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>List of Accounts with tags matching</dt><dd><p>the search criteria, or an empty list if no
matches were found.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>matches (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.search.search_channel_tag">
<codeclass="sig-prename descclassname">evennia.utils.search.</code><codeclass="sig-name descname">search_channel_tag</code><spanclass="sig-paren">(</span><emclass="sig-param">key=None</em>, <emclass="sig-param">category=None</em>, <emclass="sig-param">tagtype=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/search.html#search_channel_tag"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.search.search_channel_tag"title="Permalink to this definition">¶</a></dt>
<dd><p>Find channel based on tag or category.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>optional</em>) – The tag key to search for.</p></li>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of tag
to search for. If not set, uncategorized
tags will be searched.</p></li>
<li><p><strong>tagtype</strong> (<em>str</em><em>, </em><em>optional</em>) –‘type’ of Tag, by default
this is either <cite>None</cite> (a normal Tag), <cite>alias</cite> or
<cite>permission</cite>. This always apply to all queried tags.</p></li>
<li><p><strong>kwargs</strong> (<em>any</em>) – Other optional parameter that may be supported
by the manager method.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>List of Channels with tags matching</dt><dd><p>the search criteria, or an empty list if no
<spanid="evennia-utils-test-resources-module"></span><h2>evennia.utils.test_resources module<aclass="headerlink"href="#module-evennia.utils.test_resources"title="Permalink to this headline">¶</a></h2>
<p>Various helper resources for writing unittests.</p>
<dlclass="class">
<dtid="evennia.utils.test_resources.EvenniaTest">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.test_resources.</code><codeclass="sig-name descname">EvenniaTest</code><spanclass="sig-paren">(</span><emclass="sig-param">methodName='runTest'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/test_resources.html#EvenniaTest"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">account_typeclass</code><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.account_typeclass"title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal"href="evennia.accounts.html#evennia.accounts.accounts.DefaultAccount"title="evennia.accounts.accounts.DefaultAccount"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">evennia.accounts.accounts.DefaultAccount</span></code></a></p>
<codeclass="sig-name descname">character_typeclass</code><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.character_typeclass"title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal"href="evennia.objects.html#evennia.objects.objects.DefaultCharacter"title="evennia.objects.objects.DefaultCharacter"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">evennia.objects.objects.DefaultCharacter</span></code></a></p>
<codeclass="sig-name descname">exit_typeclass</code><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.exit_typeclass"title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal"href="evennia.objects.html#evennia.objects.objects.DefaultExit"title="evennia.objects.objects.DefaultExit"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">evennia.objects.objects.DefaultExit</span></code></a></p>
<codeclass="sig-name descname">object_typeclass</code><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.object_typeclass"title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal"href="evennia.objects.html#evennia.objects.objects.DefaultObject"title="evennia.objects.objects.DefaultObject"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">evennia.objects.objects.DefaultObject</span></code></a></p>
<codeclass="sig-name descname">room_typeclass</code><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.room_typeclass"title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal"href="evennia.objects.html#evennia.objects.objects.DefaultRoom"title="evennia.objects.objects.DefaultRoom"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">evennia.objects.objects.DefaultRoom</span></code></a></p>
<codeclass="sig-name descname">script_typeclass</code><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.script_typeclass"title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal"href="evennia.scripts.html#evennia.scripts.scripts.DefaultScript"title="evennia.scripts.scripts.DefaultScript"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">evennia.scripts.scripts.DefaultScript</span></code></a></p>
<codeclass="sig-name descname">setUp</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/test_resources.html#EvenniaTest.setUp"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.setUp"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">tearDown</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/test_resources.html#EvenniaTest.tearDown"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.test_resources.EvenniaTest.tearDown"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook method for deconstructing the test fixture after testing it.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.test_resources.</code><codeclass="sig-name descname">LocalEvenniaTest</code><spanclass="sig-paren">(</span><emclass="sig-param">methodName='runTest'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/test_resources.html#LocalEvenniaTest"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.test_resources.LocalEvenniaTest"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">account_typeclass</code><emclass="property"> = 'typeclasses.accounts.Account'</em><aclass="headerlink"href="#evennia.utils.test_resources.LocalEvenniaTest.account_typeclass"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">character_typeclass</code><emclass="property"> = 'typeclasses.characters.Character'</em><aclass="headerlink"href="#evennia.utils.test_resources.LocalEvenniaTest.character_typeclass"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">exit_typeclass</code><emclass="property"> = 'typeclasses.exits.Exit'</em><aclass="headerlink"href="#evennia.utils.test_resources.LocalEvenniaTest.exit_typeclass"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">object_typeclass</code><emclass="property"> = 'typeclasses.objects.Object'</em><aclass="headerlink"href="#evennia.utils.test_resources.LocalEvenniaTest.object_typeclass"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">room_typeclass</code><emclass="property"> = 'typeclasses.rooms.Room'</em><aclass="headerlink"href="#evennia.utils.test_resources.LocalEvenniaTest.room_typeclass"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">script_typeclass</code><emclass="property"> = 'typeclasses.scripts.Script'</em><aclass="headerlink"href="#evennia.utils.test_resources.LocalEvenniaTest.script_typeclass"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.test_resources.</code><codeclass="sig-name descname">mockdeferLater</code><spanclass="sig-paren">(</span><emclass="sig-param">reactor</em>, <emclass="sig-param">timedelay</em>, <emclass="sig-param">callback</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/test_resources.html#mockdeferLater"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.test_resources.mockdeferLater"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.test_resources.mockdelay">
<codeclass="sig-prename descclassname">evennia.utils.test_resources.</code><codeclass="sig-name descname">mockdelay</code><spanclass="sig-paren">(</span><emclass="sig-param">timedelay</em>, <emclass="sig-param">callback</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/test_resources.html#mockdelay"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.test_resources.mockdelay"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.test_resources.</code><codeclass="sig-name descname">unload_module</code><spanclass="sig-paren">(</span><emclass="sig-param">module</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/test_resources.html#unload_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.test_resources.unload_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Reset import so one can mock global constants.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>module</strong> (<em>module</em><em>, </em><em>object</em><em> or </em><em>str</em>) – The module will
be removed so it will have to be imported again. If given
an object, the module in which that object sits will be unloaded. A string
should directly give the module pathname to unload.</p>
</dd>
</dl>
<pclass="rubric">Example</p>
<p># (in a test method)
unload_module(foo)
with mock.patch(“foo.GLOBALTHING”, “mockval”):</p>
<blockquote>
<div><p>import foo
… # test code using foo.GLOBALTHING, now set to ‘mockval’</p>
</div></blockquote>
<p>This allows for mocking constants global to the module, since
otherwise those would not be mocked (since a module is only
<spanid="evennia-utils-text2html-module"></span><h2>evennia.utils.text2html module<aclass="headerlink"href="#module-evennia.utils.text2html"title="Permalink to this headline">¶</a></h2>
<p>ANSI -> html converter</p>
<p>Credit for original idea and implementation
goes to Muhammad Alkarouri and his
snippet #577349 on <aclass="reference external"href="http://code.activestate.com">http://code.activestate.com</a>.</p>
<p>(extensively modified by Griatch 2010)</p>
<dlclass="class">
<dtid="evennia.utils.text2html.TextToHTMLparser">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.text2html.</code><codeclass="sig-name descname">TextToHTMLparser</code><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_sub_bg</code><spanclass="sig-paren">(</span><emclass="sig-param">colormatch</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser._sub_bg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser._sub_bg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_sub_bgfg</code><spanclass="sig-paren">(</span><emclass="sig-param">colormatch</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser._sub_bgfg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser._sub_bgfg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">_sub_fg</code><spanclass="sig-paren">(</span><emclass="sig-param">colormatch</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser._sub_fg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser._sub_fg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">bgfgstart</code><emclass="property"> = '((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m)(\\s*)((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[[3-4][0-8].*?m){0,1}'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.bgfgstart"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">bgfgstop</code><emclass="property"> = '(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m(\\s*)(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.bgfgstop"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">bgstart</code><emclass="property"> = '((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m)'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.bgstart"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">bgstop</code><emclass="property"> = '(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m|$'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.bgstop"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">blink</code><emclass="property"> = '\x1b[5m'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.blink"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">convert_linebreaks</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.convert_linebreaks"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.convert_linebreaks"title="Permalink to this definition">¶</a></dt>
<dd><p>Extra method for cleaning linebreaks</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">convert_urls</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.convert_urls"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.convert_urls"title="Permalink to this definition">¶</a></dt>
<dd><p>Replace urls (<aclass="reference external"href="http://">http://</a>…) by valid HTML.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">fgstart</code><emclass="property"> = '((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m)'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.fgstart"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">fgstop</code><emclass="property"> = '(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.fgstop"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">hilite</code><emclass="property"> = '\x1b[1m'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.hilite"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">inverse</code><emclass="property"> = '\x1b[7m'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.inverse"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">normal</code><emclass="property"> = '\x1b[0m'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.normal"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">parse</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">strip_ansi=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.parse"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.parse"title="Permalink to this definition">¶</a></dt>
<dd><p>Main access function, converts a text containing ANSI codes
into html statements.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – Text to process.</p></li>
<codeclass="sig-name descname">re_bgfg</code><emclass="property"> = re.compile('((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m)(\\s*)((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[[3-4][0-8].*?m){0,1}(.*?)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m(\\s*)(?:\x1b\\[1m|\x1b\)</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_bgfg"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_bgs</code><emclass="property"> = re.compile('((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m)(.*?)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m|$)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_bgs"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_blink</code><emclass="property"> = re.compile('(?:\x1b\\[5m)(.*?)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$|(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m|$)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_blink"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_blinking</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.re_blinking"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_blinking"title="Permalink to this definition">¶</a></dt>
<dd><p>Replace ansi blink with custom blink css class</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">re_bold</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.re_bold"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_bold"title="Permalink to this definition">¶</a></dt>
<dd><p>Clean out superfluous hilights rather than set <strong>to make
it match the look of telnet.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">re_color</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.re_color"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_color"title="Permalink to this definition">¶</a></dt>
<dd><p>Replace ansi colors with html color class names. Let the
client choose how it will display colors, if it wishes to.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – the string with color to replace.</p>
<codeclass="sig-name descname">re_dblspace</code><emclass="property"> = re.compile(' {2,}', re.MULTILINE)</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_dblspace"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_double_space</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.re_double_space"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_double_space"title="Permalink to this definition">¶</a></dt>
<dd><p>HTML will swallow any normal space after the first, so if any slipped
through we must make sure to replace them with ” &nbsp;”</p>
<codeclass="sig-name descname">re_fgs</code><emclass="property"> = re.compile('((?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m)(.*?)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_fgs"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_hilite</code><emclass="property"> = re.compile('(?:\x1b\\[1m)(.*)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$|(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m|$)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_hilite"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_inverse</code><emclass="property"> = re.compile('(?:\x1b\\[7m)(.*?)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$|(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m|$)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_inverse"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_inversing</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.re_inversing"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_inversing"title="Permalink to this definition">¶</a></dt>
<dd><p>Replace ansi inverse with custom inverse css class</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">re_mxplink</code><emclass="property"> = re.compile('\\|lc(.*?)\\|lt(.*?)\\|le', re.DOTALL)</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_mxplink"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_normal</code><emclass="property"> = re.compile('\x1b\\[0m')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_normal"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_uline</code><emclass="property"> = re.compile('(?:\x1b\\[4m)(.*?)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$|(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m|$)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_uline"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_underline</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.re_underline"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_underline"title="Permalink to this definition">¶</a></dt>
<dd><p>Replace ansi underline with html underline class name.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">re_unhilite</code><emclass="property"> = re.compile('(?:\x1b\\[22m)(.*)(?=(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[3[0-8].*?m|\x1b\\[0m|$|(?:\x1b\\[1m|\x1b\\[22m){0,1}\x1b\\[4[0-8].*?m|\x1b\\[0m|$)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_unhilite"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">re_url</code><emclass="property"> = re.compile('((?:ftp|www|https?)\\W+(?:(?!\\.(?:\\s|$)|&\\w+;)[^"\\\',;$*^\\\\(){}<>\\[\\]\\s])+)(\\.(?:\\s|$)|&\\w+;|)')</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.re_url"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">remove_backspaces</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.remove_backspaces"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.remove_backspaces"title="Permalink to this definition">¶</a></dt>
<dd><p>Removes special escape sequences</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">remove_bells</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.remove_bells"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.remove_bells"title="Permalink to this definition">¶</a></dt>
<dd><p>Remove ansi specials</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>text</strong> (<em>str</em>) – Text to process.</p>
<codeclass="sig-name descname">sub_dblspace</code><spanclass="sig-paren">(</span><emclass="sig-param">match</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.sub_dblspace"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.sub_dblspace"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">sub_mxp_links</code><spanclass="sig-paren">(</span><emclass="sig-param">match</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.sub_mxp_links"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.sub_mxp_links"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper method to be passed to re.sub,
replaces MXP links with HTML code.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>match</strong> (<em>re.Matchobject</em>) – Match for substitution.</p>
<codeclass="sig-name descname">sub_text</code><spanclass="sig-paren">(</span><emclass="sig-param">match</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#TextToHTMLparser.sub_text"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.sub_text"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper method to be passed to re.sub,
for handling all substitutions.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>match</strong> (<em>re.Matchobject</em>) – Match for substitution.</p>
<codeclass="sig-name descname">tabstop</code><emclass="property"> = 4</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.tabstop"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">underline</code><emclass="property"> = '\x1b[4m'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.underline"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">unhilite</code><emclass="property"> = '\x1b[22m'</em><aclass="headerlink"href="#evennia.utils.text2html.TextToHTMLparser.unhilite"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.text2html.parse_html">
<codeclass="sig-prename descclassname">evennia.utils.text2html.</code><codeclass="sig-name descname">parse_html</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">strip_ansi=False</em>, <emclass="sig-param">parser=<evennia.utils.text2html.TextToHTMLparser object></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/text2html.html#parse_html"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.text2html.parse_html"title="Permalink to this definition">¶</a></dt>
<dd><p>Parses a string, replace ANSI markup with html</p>
<spanid="evennia-utils-utils-module"></span><h2>evennia.utils.utils module<aclass="headerlink"href="#module-evennia.utils.utils"title="Permalink to this headline">¶</a></h2>
<p>General helper functions that don’t fit neatly under any given category.</p>
<p>They provide some useful string and conversion methods that might
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">LimitedSizeOrderedDict</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#LimitedSizeOrderedDict"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.LimitedSizeOrderedDict"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#LimitedSizeOrderedDict.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.LimitedSizeOrderedDict.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Limited-size ordered dict.</p>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>size_limit (int): Use this to limit the number of elements</dt><dd><p>alloweds to be in this list. By default the overshooting elements
will be removed in FIFO order.</p>
</dd>
<dt>fifo (bool, optional): Defaults to <cite>True</cite>. Remove overshooting elements</dt><dd><p>in FIFO order. If <cite>False</cite>, remove in FILO order.</p>
<codeclass="sig-name descname">_check_size</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#LimitedSizeOrderedDict._check_size"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.LimitedSizeOrderedDict._check_size"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">update</code><spanclass="sig-paren">(</span><spanclass="optional">[</span><emclass="sig-param">E</em>, <spanclass="optional">]</span><emclass="sig-param">**F</em><spanclass="sig-paren">)</span>→ None. Update D from dict/iterable E and F.<aclass="reference internal"href="../_modules/evennia/utils/utils.html#LimitedSizeOrderedDict.update"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.LimitedSizeOrderedDict.update"title="Permalink to this definition">¶</a></dt>
<dd><p>If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils._DA">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">_DA</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.utils._DA"title="Permalink to this definition">¶</a></dt>
<dd><p>Implement delattr(self, name).</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils._GA">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">_GA</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.utils._GA"title="Permalink to this definition">¶</a></dt>
<dd><p>Return getattr(self, name).</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils._SA">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">_SA</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.utils._SA"title="Permalink to this definition">¶</a></dt>
<dd><p>Implement setattr(self, name, value).</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.all_from_module">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">all_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">module</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#all_from_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.all_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Return all global-level variables defined in a module.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>module</strong> (<em>str</em><em>, </em><em>module</em>) – This can be either a Python path
(dot-notation like <cite>evennia.objects.models</cite>), an absolute path
(e.g. <cite>/home/eve/evennia/evennia/objects.models.py</cite>) or an
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">callables_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">module</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#callables_from_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.callables_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Return all global-level callables defined in a module.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>module</strong> (<em>str</em><em>, </em><em>module</em>) – A python-path to a module or an actual
module object.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A dict of {name: callable, …} from the module.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>callables (dict)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Will ignore callables whose names start with underscore “_”.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.calledby">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">calledby</code><spanclass="sig-paren">(</span><emclass="sig-param">callerdepth=1</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#calledby"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.calledby"title="Permalink to this definition">¶</a></dt>
<dd><p>Only to be used for debug purposes. Insert this debug function in
another function; it will print which function called it.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>callerdepth</strong> (<em>int</em>) – Must be larger than 0. When > 1, it will
print the caller of the caller etc.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A debug string detailing which routine called</dt><dd><p>us.</p>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">check_evennia_dependencies</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#check_evennia_dependencies"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.check_evennia_dependencies"title="Permalink to this definition">¶</a></dt>
<dd><p>Checks the versions of Evennia’s dependencies including making
some checks for runtime libraries.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><dlclass="simple">
<dt><cite>False</cite> if a show-stopping version mismatch is</dt><dd><p>found.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>result (bool)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.class_from_module">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">class_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em>, <emclass="sig-param">defaultpaths=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#class_from_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.class_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a class from a module, given the module’s path. This is
primarily used to convert db_typeclass_path:s to classes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>path</strong> (<em>str</em>) – Full Python dot-path to module.</p></li>
<li><p><strong>defaultpaths</strong> (<em>iterable</em><em>, </em><em>optional</em>) – If a direct import from <cite>path</cite> fails,
try subsequent imports by prepending those paths to <cite>path</cite>.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An uninstatiated class recovered from path.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>class (Class)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>ImportError</strong>– If all loading failed.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.columnize">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">columnize</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">columns=2</em>, <emclass="sig-param">spacing=4</em>, <emclass="sig-param">align='l'</em>, <emclass="sig-param">width=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#columnize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.columnize"title="Permalink to this definition">¶</a></dt>
<dd><p>Break a string into a number of columns, using as little
vertical space as possible.</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 columnize.</p></li>
<li><p><strong>columns</strong> (<em>int</em><em>, </em><em>optional</em>) – The number of columns to use.</p></li>
<li><p><strong>spacing</strong> (<em>int</em><em>, </em><em>optional</em>) – How much space to have between columns.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – The max width of the columns.
Defaults to client’s default width.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Text divided into columns.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>columns (str)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>RuntimeError</strong>– If given invalid values.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.crop">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">crop</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width=None</em>, <emclass="sig-param">suffix='[...]'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#crop"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.crop"title="Permalink to this definition">¶</a></dt>
<dd><p>Crop text to a certain width, throwing away text from too-long
lines.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – Text to crop.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – Width of line to crop, in characters.</p></li>
<li><p><strong>suffix</strong> (<em>str</em><em>, </em><em>optional</em>) – This is appended to the end of cropped
lines to show that the line actually continues. Cropping
will be done so that the suffix will also fit within the
given width. If width is too small to fit both crop and
suffix, the suffix will be dropped.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The cropped text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.datetime_format">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">datetime_format</code><spanclass="sig-paren">(</span><emclass="sig-param">dtobj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#datetime_format"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.datetime_format"title="Permalink to this definition">¶</a></dt>
<dd><p>Pretty-prints the time since a given time.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>dtobj</strong> (<em>datetime</em>) – An datetime object, e.g. from Django’s
<cite>DateTimeField</cite>.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A string describing how long ago <cite>dtobj</cite></dt><dd><p>took place.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>deltatime (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.dbid_to_obj">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">dbid_to_obj</code><spanclass="sig-paren">(</span><emclass="sig-param">inp</em>, <emclass="sig-param">objclass</em>, <emclass="sig-param">raise_errors=True</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.utils.dbid_to_obj"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a #dbref to a valid object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>inp</strong> (<em>str</em><em> or </em><em>int</em>) – A valid #dbref.</p></li>
<li><p><strong>objclass</strong> (<em>class</em>) – A valid django model to filter against.</p></li>
<li><p><strong>raise_errors</strong> (<em>bool</em><em>, </em><em>optional</em>) – Whether to raise errors
or return <cite>None</cite> on errors.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An entity loaded from the dbref.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>obj (Object or None)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>Exception</strong>– If <cite>raise_errors</cite> is <cite>True</cite> and
<cite>objclass.objects.get(id=dbref)</cite> did not return a valid
object.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.dbref">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">dbref</code><spanclass="sig-paren">(</span><emclass="sig-param">inp</em>, <emclass="sig-param">reqhash=True</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#dbref"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.dbref"title="Permalink to this definition">¶</a></dt>
<dd><p>Converts/checks if input is a valid dbref.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>inp</strong> (<em>int</em><em>, </em><em>str</em>) – A database ref on the form N or #N.</p></li>
<li><p><strong>reqhash</strong> (<em>bool</em><em>, </em><em>optional</em>) – Require the #N form to accept
input as a valid dbref.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The integer part of the dbref or <cite>None</cite></dt><dd><p>if input was not a valid dbref.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>dbref (int or None)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.dbref_to_obj">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">dbref_to_obj</code><spanclass="sig-paren">(</span><emclass="sig-param">inp</em>, <emclass="sig-param">objclass</em>, <emclass="sig-param">raise_errors=True</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#dbref_to_obj"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.dbref_to_obj"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a #dbref to a valid object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>inp</strong> (<em>str</em><em> or </em><em>int</em>) – A valid #dbref.</p></li>
<li><p><strong>objclass</strong> (<em>class</em>) – A valid django model to filter against.</p></li>
<li><p><strong>raise_errors</strong> (<em>bool</em><em>, </em><em>optional</em>) – Whether to raise errors
or return <cite>None</cite> on errors.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An entity loaded from the dbref.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>obj (Object or None)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>Exception</strong>– If <cite>raise_errors</cite> is <cite>True</cite> and
<cite>objclass.objects.get(id=dbref)</cite> did not return a valid
object.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.dedent">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">dedent</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">baseline_index=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#dedent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.dedent"title="Permalink to this definition">¶</a></dt>
<dd><p>Safely clean all whitespace at the left of a paragraph.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – The text to dedent.</p></li>
<li><p><strong>baseline_index</strong> (<em>int</em><em> or </em><em>None</em><em>, </em><em>optional</em>) – Which row to use as a ‘base’
for the indentation. Lines will be dedented to this level but
no further. If None, indent so as to completely deindent the
least indented text.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>Dedented string.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This is useful for preserving triple-quoted string indentation
while still shifting it all to be next to the left edge of the
display.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.deepsize">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">deepsize</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em>, <emclass="sig-param">max_depth=4</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#deepsize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.deepsize"title="Permalink to this definition">¶</a></dt>
<dd><p>Get not only size of the given object, but also the size of
objects referenced by the object, down to <cite>max_depth</cite> distance
from the object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>obj</strong> (<em>object</em>) – the object to be measured.</p></li>
<li><p><strong>max_depth</strong> (<em>int</em><em>, </em><em>optional</em>) – maximum referential distance
from <cite>obj</cite> that <cite>deepsize()</cite> should cover for
measuring objects referenced by <cite>obj</cite>.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>deepsize of <cite>obj</cite> in Bytes.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>size (int)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This measure is necessarily approximate since some
memory is shared between objects. The <cite>max_depth</cite> of 4 is roughly
tested to give reasonable size information about database models
and their handlers.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.delay">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">delay</code><spanclass="sig-paren">(</span><emclass="sig-param">timedelay</em>, <emclass="sig-param">callback</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#delay"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.delay"title="Permalink to this definition">¶</a></dt>
<dd><p>Delay the return of a value.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>timedelay</strong> (<em>int</em><em> or </em><em>float</em>) – The delay in seconds</p></li>
<li><p><strong>callback</strong> (<em>callable</em>) – Will be called as <cite>callback(*args, **kwargs)</cite>
after <cite>timedelay</cite> seconds.</p></li>
<li><p><strong>args</strong> (<em>any</em><em>, </em><em>optional</em>) – Will be used as arguments to callback</p></li>
</ul>
</dd>
</dl>
<dl>
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>persistent (bool, optional): should make the delay persistent</dt><dd><p>over a reboot or reload</p>
</dd>
</dl>
<p>any (any): Will be used as keyword arguments to callback.</p>
</dd>
</dl>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><dlclass="simple">
<dt>Will fire with callback after</dt><dd><p><cite>timedelay</cite> seconds. Note that if <cite>timedelay()</cite> is used in the
commandhandler callback chain, the callback chain can be
defined directly in the command body and don’t need to be
specified here.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>deferred (deferred)</p>
</dd>
</dl>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>The task handler (<cite>evennia.scripts.taskhandler.TASK_HANDLER</cite>) will
be called for persistent or non-persistent tasks.
If persistent is set to True, the callback, its arguments
and other keyword arguments will be saved in the database,
assuming they can be. The callback will be executed even after
a server restart/reload, taking into account the specified delay
(and server down time).</p>
</div>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.fill">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">fill</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width=None</em>, <emclass="sig-param">indent=0</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.utils.fill"title="Permalink to this definition">¶</a></dt>
<dd><p>Safely wrap text to a certain number of characters.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – The text to wrap.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – The number of characters to wrap to.</p></li>
<li><p><strong>indent</strong> (<em>int</em>) – How much to indent each line (with whitespace).</p></li>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">format_grid</code><spanclass="sig-paren">(</span><emclass="sig-param">elements</em>, <emclass="sig-param">width=78</em>, <emclass="sig-param">sep=' '</em>, <emclass="sig-param">verbatim_elements=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#format_grid"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.format_grid"title="Permalink to this definition">¶</a></dt>
<dd><p>This helper function makes a ‘grid’ output, where it distributes the given
string-elements as evenly as possible to fill out the given width.
will not work well if the variation of length is very big!</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>elements</strong> (<em>iterable</em>) – A 1D list of string elements to put in the grid.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – The width of the grid area to fill.</p></li>
<li><p><strong>sep</strong> (<em>str</em><em>, </em><em>optional</em>) – The extra separator to put between words. If
set to the empty string, words may run into each other.</p></li>
<li><p><strong>verbatim_elements</strong> (<em>list</em><em>, </em><em>optional</em>) – This is a list of indices pointing to
specific items in the <cite>elements</cite> list. An element at this index will
not be included in the calculation of the slot sizes. It will still
be inserted into the grid at the correct position and may be surrounded
by padding unless filling the entire line. This is useful for embedding
decorations in the grid, such as horizontal bars.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The grid as a list of ready-formatted rows. We return it</dt><dd><p>like this to make it easier to insert decorations between rows, such
as horizontal bars.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>gridstr (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.format_table">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">format_table</code><spanclass="sig-paren">(</span><emclass="sig-param">table</em>, <emclass="sig-param">extra_space=1</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#format_table"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.format_table"title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Note: <cite>evennia.utils.evtable</cite> is more powerful than this, but this
function can be useful when the number of columns and rows are
unknown and must be calculated on the fly.</p>
<dlclass="simple">
<dt>Args.</dt><dd><dlclass="simple">
<dt>table (list): A list of lists to represent columns in the</dt><dd><p>table: <cite>[[val,val,val,…], [val,val,val,…], …]</cite>, where
each val will be placed on a separate row in the
column. All columns must have the same number of rows (some
positions may be empty though).</p>
</dd>
<dt>extra_space (int, optional): Sets how much <em>minimum</em> extra</dt><dd><p>padding (in characters) should be left between columns.</p>
</dd>
</dl>
</dd>
<dt>Returns:</dt><dd><dlclass="simple">
<dt>table (list): A list of lists representing the rows to print</dt><dd><p>out one by one.</p>
</dd>
</dl>
</dd>
<dt>Notes:</dt><dd><p>The function formats the columns to be as wide as the widest member
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">fuzzy_import_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em>, <emclass="sig-param">variable</em>, <emclass="sig-param">default=None</em>, <emclass="sig-param">defaultpaths=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#fuzzy_import_from_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.fuzzy_import_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Import a variable based on a fuzzy path. First the literal
<cite>path</cite> will be tried, then all given <cite>defaultpaths</cite> will be
prepended to see a match is found.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>path</strong> (<em>str</em>) – Full or partial python path.</p></li>
<li><p><strong>variable</strong> (<em>str</em>) – Name of variable to import from module.</p></li>
<li><p><strong>default</strong> (<em>string</em><em>, </em><em>optional</em>) – Default value to use if a variable fails to
be extracted. Ignored if <cite>variable</cite> is not given.</p></li>
<li><p><strong>defaultpaths</strong> (<em>iterable</em><em>, </em><em>options</em>) – Python paths to attempt in order if
importing directly from <cite>path</cite> doesn’t work.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The variable imported from the module, or <cite>default</cite>, if</dt><dd><p>not found.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>value (any)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.get_all_typeclasses">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">get_all_typeclasses</code><spanclass="sig-paren">(</span><emclass="sig-param">parent=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#get_all_typeclasses"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.get_all_typeclasses"title="Permalink to this definition">¶</a></dt>
<dd><p>List available typeclasses from all available modules.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>parent</strong> (<em>str</em><em>, </em><em>optional</em>) – If given, only return typeclasses inheriting (at any distance)
from this parent.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>On the form {“typeclass.path”: typeclass, …}</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>typeclasses (dict)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This will dynamicall retrieve all abstract django models inheriting at any distance
from the TypedObject base (aka a Typeclass) so it will work fine with any custom
classes being added.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.get_evennia_pids">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">get_evennia_pids</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#get_evennia_pids"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.get_evennia_pids"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the currently valid PIDs (Process IDs) of the Portal and
Server by trying to access a PID file.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><dlclass="simple">
<dt>The PIDs of the respective processes,</dt><dd><p>or two <cite>None</cite> values if not found.</p>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">get_evennia_version</code><spanclass="sig-paren">(</span><emclass="sig-param">mode='long'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#get_evennia_version"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.get_evennia_version"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper method for getting the current evennia version.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>mode</strong> (<em>str</em><em>, </em><em>optional</em>) – One of:
- long: 0.9.0 rev342453534
- short: 0.9.0
- pretty: Evennia 0.9.0</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The version string.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>version (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.get_game_dir_path">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">get_game_dir_path</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#get_game_dir_path"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.get_game_dir_path"title="Permalink to this definition">¶</a></dt>
<dd><p>This is called by settings_default in order to determine the path
of the game directory.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Full OS path to the game dir</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>path (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.has_parent">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">has_parent</code><spanclass="sig-paren">(</span><emclass="sig-param">basepath</em>, <emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#has_parent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.has_parent"title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if <cite>basepath</cite> is somewhere in <ahref="#id195"><spanclass="problematic"id="id196">`</span></a>obj`s parent tree.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>basepath</strong> (<em>str</em>) – Python dotpath to compare against obj path.</p></li>
<li><p><strong>obj</strong> (<em>any</em>) – Object whose path is to be checked.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>If the check was successful or not.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>has_parent (bool)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.host_os_is">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">host_os_is</code><spanclass="sig-paren">(</span><emclass="sig-param">osname</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#host_os_is"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.host_os_is"title="Permalink to this definition">¶</a></dt>
<dd><p>Check to see if the host OS matches the query.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>osname</strong> (<em>str</em>) – Common names are “posix” (linux/unix/mac) and
“nt” (windows).</p></li>
<li><p><strong>is_os</strong> (<em>bool</em>) – If the os matches or not.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.inherits_from">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">inherits_from</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em>, <emclass="sig-param">parent</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#inherits_from"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.inherits_from"title="Permalink to this definition">¶</a></dt>
<dd><p>Takes an object and tries to determine if it inherits at <em>any</em>
distance from parent.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>obj</strong> (<em>any</em>) – Object to analyze. This may be either an instance
or a class.</p></li>
<li><p><strong>parent</strong> (<em>any</em>) – Can be either instance, class or python path to class.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>If <cite>parent</cite> is a parent to <cite>obj</cite> or not.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>inherits_from (bool)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>What differs this function from e.g. <cite>isinstance()</cite> is that <cite>obj</cite>
may be both an instance and a class, and parent may be an
instance, a class, or the python path to a class (counting from
the evennia root directory).</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.init_new_account">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">init_new_account</code><spanclass="sig-paren">(</span><emclass="sig-param">account</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#init_new_account"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.init_new_account"title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.interactive">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">interactive</code><spanclass="sig-paren">(</span><emclass="sig-param">func</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#interactive"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.interactive"title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator to make a method pausable with yield(seconds)
and able to ask for user-input with response=yield(question).
For the question-asking to work, ‘caller’ must the name
of an argument or kwarg to the decorated function.</p>
<p>Note that this turns the method into a generator.</p>
<p>Example usage:</p>
<p>@interactive
def myfunc(caller):</p>
<blockquote>
<div><p>caller.msg(“This is a test”)
# wait five seconds
yield(5)
# ask user (caller) a question
response = yield(“Do you want to continue waiting?”)
if response == “yes”:</p>
<blockquote>
<div><p>yield(5)</p>
</div></blockquote>
<dlclass="simple">
<dt>else:</dt><dd><p># …</p>
</dd>
</dl>
</div></blockquote>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.is_iter">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">is_iter</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#is_iter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.is_iter"title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if an object behaves iterably.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>obj</strong> (<em>any</em>) – Entity to check for iterability.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>If <cite>obj</cite> is iterable or not.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>is_iterable (bool)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Strings are <em>not</em> accepted as iterable (although they are
actually iterable), since string iterations are usually not
what we want to do with a string.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.justify">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">justify</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width=None</em>, <emclass="sig-param">align='f'</em>, <emclass="sig-param">indent=0</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#justify"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.justify"title="Permalink to this definition">¶</a></dt>
<dd><p>Fully justify a text so that it fits inside <cite>width</cite>. When using
full justification (default) this will be done by padding between
words with extra whitespace where necessary. Paragraphs will
be retained.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – Text to justify.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – The length of each line, in characters.</p></li>
<li><p><strong>align</strong> (<em>str</em><em>, </em><em>optional</em>) – The alignment, ‘l’, ‘c’, ‘r’ or ‘f’
for left, center, right or full justification respectively.</p></li>
<li><p><strong>indent</strong> (<em>int</em><em>, </em><em>optional</em>) – Number of characters indentation of
entire justified text block.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The justified and indented block of text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>justified (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.latinify">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">latinify</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">default='?'</em>, <emclass="sig-param">pure_ascii=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#latinify"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.latinify"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a unicode string to “safe” ascii/latin-1 characters.
This is used as a last resort when normal encoding does not work.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string</strong> (<em>str</em>) – A string to convert to ‘safe characters’ convertable
to an latin-1 bytestring later.</p></li>
<li><p><strong>default</strong> (<em>str</em><em>, </em><em>optional</em>) – Characters resisting mapping will be replaced
with this character or string. The intent is to apply an encode operation
on the string soon after.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A ‘latinified’ string where each unicode character has been</dt><dd><p>replaced with a ‘safe’ equivalent available in the ascii/latin-1 charset.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>string (str)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<dlclass="simple">
<dt>This is inspired by the gist by Ricardo Murri:</dt><dd><p><aclass="reference external"href="https://gist.github.com/riccardomurri/3c3ccec30f037be174d3">https://gist.github.com/riccardomurri/3c3ccec30f037be174d3</a></p>
</dd>
</dl>
</dd></dl>
<dlclass="class">
<dtid="evennia.utils.utils.lazy_property">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">lazy_property</code><spanclass="sig-paren">(</span><emclass="sig-param">func</em>, <emclass="sig-param">name=None</em>, <emclass="sig-param">doc=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#lazy_property"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.lazy_property"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param">func</em>, <emclass="sig-param">name=None</em>, <emclass="sig-param">doc=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#lazy_property.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.lazy_property.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Store all properties for now</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.list_to_string">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">list_to_string</code><spanclass="sig-paren">(</span><emclass="sig-param">inlist</em>, <emclass="sig-param">endsep='and'</em>, <emclass="sig-param">addquote=False</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#list_to_string"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.list_to_string"title="Permalink to this definition">¶</a></dt>
<dd><p>This pretty-formats a list as string output, adding an optional
alternative separator to the second to last entry. If <cite>addquote</cite>
is <cite>True</cite>, the outgoing strings will be surrounded by quotes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>inlist</strong> (<em>list</em>) – The list to print.</p></li>
<li><p><strong>endsep</strong> (<em>str</em><em>, </em><em>optional</em>) – If set, the last item separator will
be replaced with this value.</p></li>
<li><p><strong>addquote</strong> (<em>bool</em><em>, </em><em>optional</em>) – This will surround all outgoing
values with double quotes.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The list represented as a string.</p>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">m_len</code><spanclass="sig-paren">(</span><emclass="sig-param">target</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#m_len"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.m_len"title="Permalink to this definition">¶</a></dt>
<dd><p>Provides length checking for strings with MXP patterns, and falls
back to normal len for other objects.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>target</strong> (<em>string</em>) – A string with potential MXP components
to search.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The length of <cite>target</cite>, ignoring MXP components.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>length (int)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.make_iter">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">make_iter</code><spanclass="sig-paren">(</span><emclass="sig-param">obj</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#make_iter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.make_iter"title="Permalink to this definition">¶</a></dt>
<dd><p>Makes sure that the object is always iterable.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>obj</strong> (<em>any</em>) – Object to make iterable.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The same object</dt><dd><p>passed-through or made iterable.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>iterable (list or iterable)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.mod_import">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">mod_import</code><spanclass="sig-paren">(</span><emclass="sig-param">module</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#mod_import"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.mod_import"title="Permalink to this definition">¶</a></dt>
<dd><p>A generic Python module loader.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>module</strong> (<em>str</em><em>, </em><em>module</em>) – This can be either a Python path
(dot-notation like <cite>evennia.objects.models</cite>), an absolute path
(e.g. <cite>/home/eve/evennia/evennia/objects/models.py</cite>) or an
<ddclass="field-even"><p>An imported module. If the input argument was
already a module, this is returned as-is, otherwise the path is
parsed and imported. Returns <cite>None</cite> and logs error if import failed.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>(module or None)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.mod_import_from_path">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">mod_import_from_path</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#mod_import_from_path"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.mod_import_from_path"title="Permalink to this definition">¶</a></dt>
<dd><p>Load a Python module at the specified path.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>path</strong> (<em>str</em>) – An absolute path to a Python module to load.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An imported module if the path was a valid
Python module. Returns <cite>None</cite> if the import failed.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>(module or None)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.object_from_module">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">object_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em>, <emclass="sig-param">defaultpaths=None</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.utils.utils.object_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Return a class from a module, given the module’s path. This is
primarily used to convert db_typeclass_path:s to classes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>path</strong> (<em>str</em>) – Full Python dot-path to module.</p></li>
<li><p><strong>defaultpaths</strong> (<em>iterable</em><em>, </em><em>optional</em>) – If a direct import from <cite>path</cite> fails,
try subsequent imports by prepending those paths to <cite>path</cite>.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An uninstatiated class recovered from path.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>class (Class)</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>ImportError</strong>– If all loading failed.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.pad">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">pad</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width=None</em>, <emclass="sig-param">align='c'</em>, <emclass="sig-param">fillchar=' '</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#pad"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.pad"title="Permalink to this definition">¶</a></dt>
<dd><p>Pads to a given width.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – Text to pad.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – The width to pad to, in characters.</p></li>
<li><p><strong>align</strong> (<em>str</em><em>, </em><em>optional</em>) – This is one of ‘c’, ‘l’ or ‘r’ (center,
left or right).</p></li>
<li><p><strong>fillchar</strong> (<em>str</em><em>, </em><em>optional</em>) – The character to fill with.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The padded text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>text (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.percent">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">percent</code><spanclass="sig-paren">(</span><emclass="sig-param">value</em>, <emclass="sig-param">minval</em>, <emclass="sig-param">maxval</em>, <emclass="sig-param">formatting='{:3.1f}%'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#percent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.percent"title="Permalink to this definition">¶</a></dt>
<dd><p>Get a value in an interval as a percentage of its position
in that interval. This also understands negative numbers.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>value</strong> (<em>number</em>) – This should be a value minval<=value<=maxval.</p></li>
<li><p><strong>minval</strong> (<em>number</em><em> or </em><em>None</em>) – Smallest value in interval. This could be None
for an open interval (then return will always be 100%)</p></li>
<li><p><strong>maxval</strong> (<em>number</em><em> or </em><em>None</em>) – Biggest value in interval. This could be None
for an open interval (then return will always be 100%)</p></li>
<li><p><strong>formatted</strong> (<em>str</em><em>, </em><em>optional</em>) – This is a string that should
accept one formatting tag. This will receive the
current value as a percentage. If None, the
raw float will be returned instead.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>The formatted value or the raw percentage</dt><dd><p>as a float.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>str or float</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>We try to handle a weird interval gracefully.
- If either maxval or minval is None (open interval),</p>
<blockquote>
<div><p>we (aribtrarily) assume 100%.</p>
</div></blockquote>
<ulclass="simple">
<li><p>If minval > maxval, we return 0%.</p></li>
<li><dlclass="simple">
<dt>If minval == maxval == value we are looking at a single value match</dt><dd><p>and return 100%.</p>
</dd>
</dl>
</li>
<li><p>If minval == maxval != value we return 0%.</p></li>
<li><dlclass="simple">
<dt>If value not in [minval..maxval], we set value to the closest</dt><dd><p>boundary, so the result will be 0% or 100%, respectively.</p>
</dd>
</dl>
</li>
</ul>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.percentile">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">percentile</code><spanclass="sig-paren">(</span><emclass="sig-param">iterable</em>, <emclass="sig-param">percent</em>, <emclass="sig-param">key=<function <lambda>></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#percentile"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.percentile"title="Permalink to this definition">¶</a></dt>
<dd><p>Find the percentile of a list of values.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>iterable</strong> (<em>iterable</em>) – A list of values. Note N MUST BE already sorted.</p></li>
<li><p><strong>percent</strong> (<em>float</em>) – A value from 0.0 to 1.0.</p></li>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">pypath_to_realpath</code><spanclass="sig-paren">(</span><emclass="sig-param">python_path</em>, <emclass="sig-param">file_ending='.py'</em>, <emclass="sig-param">pypath_prefixes=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#pypath_to_realpath"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.pypath_to_realpath"title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a dotted Python path to an absolute path under the
Evennia library directory or under the current game directory.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>python_path</strong> (<em>str</em>) – A dot-python path</p></li>
<li><p><strong>file_ending</strong> (<em>str</em>) – A file ending, including the period.</p></li>
<li><p><strong>pypath_prefixes</strong> (<em>list</em>) – A list of paths to test for existence. These
should be on python.path form. EVENNIA_DIR and GAME_DIR are automatically
checked, they need not be added to this list.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>All existing, absolute paths created by</dt><dd><p>converting <cite>python_path</cite> to an absolute paths and/or
prepending <cite>python_path</cite> by <cite>settings.EVENNIA_DIR</cite>,
<cite>settings.GAME_DIR</cite> and by`pypath_prefixes` respectively.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>abspaths (list)</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This will also try a few combinations of paths to allow cases
where pypath is given including the “evennia.” or “mygame.”
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">random_string_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">module</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#random_string_from_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.random_string_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a random global string from a module.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>module</strong> (<em>string</em><em> or </em><em>module</em>) – Python path, absolute path or a module.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A random stribg variable from <cite>module</cite>.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>random (string)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.run_async">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">run_async</code><spanclass="sig-paren">(</span><emclass="sig-param">to_execute</em>, <emclass="sig-param">*args</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#run_async"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.run_async"title="Permalink to this definition">¶</a></dt>
<dd><p>Runs a function or executes a code snippet asynchronously.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>to_execute</strong> (<em>callable</em>) – If this is a callable, it will be
executed with <ahref="#id213"><spanclass="problematic"id="id214">*</span></a>args and non-reserved <ahref="#id215"><spanclass="problematic"id="id216">*</span></a>kwargs as arguments.
The callable will be executed using ProcPool, or in a thread
if ProcPool is not available.</p>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>at_return (callable): Should point to a callable with one</dt><dd><p>argument. It will be called with the return value from
to_execute.</p>
</dd>
<dt>at_return_kwargs (dict): This dictionary will be used as</dt><dd><p>keyword arguments to the at_return callback.</p>
</dd>
<dt>at_err (callable): This will be called with a Failure instance</dt><dd><p>if there is an error in to_execute.</p>
</dd>
<dt>at_err_kwargs (dict): This dictionary will be used as keyword</dt><dd><p>arguments to the at_err errback.</p>
</dd>
</dl>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>All other <cite>*args</cite> and <cite>**kwargs</cite> will be passed on to
<cite>to_execute</cite>. Run_async will relay executed code to a thread
or procpool.</p>
<p>Use this function with restrain and only for features/commands
that you know has no influence on the cause-and-effect order of your
game (commands given after the async function might be executed before
it has finished). Accessing the same property from different threads
can lead to unpredicted behaviour if you are not careful (this is called a
“race condition”).</p>
<p>Also note that some databases, notably sqlite3, don’t support access from
multiple threads simultaneously, so if you do heavy database access from
your <cite>to_execute</cite> under sqlite3 you will probably run very slow or even get
tracebacks.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.server_services">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">server_services</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#server_services"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.server_services"title="Permalink to this definition">¶</a></dt>
<dd><p>Lists all services active on the Server. Observe that since
services are launched in memory, this function will only return
any results if called from inside the game.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>A dict of available services.</p>
</dd>
<dtclass="field-even">Return type</dt>
<ddclass="field-even"><p>services (dict)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.string_from_module">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">string_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">module</em>, <emclass="sig-param">variable=None</em>, <emclass="sig-param">default=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#string_from_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.string_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>This is a wrapper for <cite>variable_from_module</cite> that requires return
value to be a string to pass. It’s primarily used by login screen.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>module</strong> (<em>string</em><em> or </em><em>module</em>) – Python path, absolute path or a module.</p></li>
<li><p><strong>variable</strong> (<em>string</em><em> or </em><em>iterable</em><em>, </em><em>optional</em>) – Single variable name or iterable
of variable names to extract. If not given, all variables in
the module will be returned.</p></li>
<li><p><strong>default</strong> (<em>string</em><em>, </em><em>optional</em>) – Default value to use if a variable fails to
be extracted. Ignored if <cite>variable</cite> is not given.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A single (string) value or a list of values
depending on if <cite>variable</cite> is given or not. Errors in lists (such
as the value not being a string) are replaced by the <cite>default</cite> argument.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>variables (value or list)</p>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">string_partial_matching</code><spanclass="sig-paren">(</span><emclass="sig-param">alternatives</em>, <emclass="sig-param">inp</em>, <emclass="sig-param">ret_index=True</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#string_partial_matching"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.string_partial_matching"title="Permalink to this definition">¶</a></dt>
<dd><p>Partially matches a string based on a list of <cite>alternatives</cite>.
Matching is made from the start of each subword in each
alternative. Case is not important. So e.g. “bi sh sw” or just
“big” or “shiny” or “sw” will match “Big shiny sword”. Scoring is
done to allow to separate by most common demoninator. You will get
multiple matches returned if appropriate.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>alternatives</strong> (<em>list of str</em>) – A list of possible strings to
<li><p><strong>ret_index</strong> (<em>bool</em><em>, </em><em>optional</em>) – Return list of indices (from alternatives
array) instead of strings.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>String-matches or indices if <cite>ret_index</cite> is <cite>True</cite>.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>matches (list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.string_similarity">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">string_similarity</code><spanclass="sig-paren">(</span><emclass="sig-param">string1</em>, <emclass="sig-param">string2</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#string_similarity"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.string_similarity"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="simple">
<dt>This implements a “cosine-similarity” algorithm as described for example in</dt><dd><p><em>Proceedings of the 22nd International Conference on Computation
Linguistics</em> (Coling 2008), pages 593-600, Manchester, August 2008.</p>
</dd>
</dl>
<p>The measure-vectors used is simply a “bag of words” type histogram
(but for letters).</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string1</strong> (<em>str</em>) – String to compare (may contain any number of words).</p></li>
<li><p><strong>string2</strong> (<em>str</em>) – Second string to compare (any number of words).</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A value 0…1 rating how similar the two</dt><dd><p>strings are.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>similarity (float)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.string_suggestions">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">string_suggestions</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em>, <emclass="sig-param">vocabulary</em>, <emclass="sig-param">cutoff=0.6</em>, <emclass="sig-param">maxnum=3</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#string_suggestions"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.string_suggestions"title="Permalink to this definition">¶</a></dt>
<dd><p>Given a <cite>string</cite> and a <cite>vocabulary</cite>, return a match or a list of
suggestions based on string similarity.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>string</strong> (<em>str</em>) – A string to search for.</p></li>
<li><p><strong>vocabulary</strong> (<em>iterable</em>) – A list of available strings.</p></li>
<li><p><strong>cutoff</strong> (<em>int</em><em>, </em><em>0-1</em>) – Limit the similarity matches (the higher
the value, the more exact a match is required).</p></li>
<li><p><strong>maxnum</strong> (<em>int</em>) – Maximum number of suggestions to return.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>Suggestions from <cite>vocabulary</cite> with a</dt><dd><p>similarity-rating that higher than or equal to <cite>cutoff</cite>.
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">strip_control_sequences</code><spanclass="sig-paren">(</span><emclass="sig-param">string</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#strip_control_sequences"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.strip_control_sequences"title="Permalink to this definition">¶</a></dt>
<dd><p>Remove non-print text sequences.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>string</strong> (<em>str</em>) – Text to strip.</p>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">time_format</code><spanclass="sig-paren">(</span><emclass="sig-param">seconds</em>, <emclass="sig-param">style=0</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#time_format"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.time_format"title="Permalink to this definition">¶</a></dt>
<dd><p>Function to return a ‘prettified’ version of a value in seconds.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>seconds</strong> (<em>int</em>) – Number if seconds to format.</p></li>
<li><p><strong>style</strong> (<em>int</em>) – One of the following styles:
0. “1d 08:30”
1. “1d”
2. “1 day, 8 hours, 30 minutes”
3. “1 day, 8 hours, 30 minutes, 10 seconds”
4. highest unit (like “3 years” or “8 months” or “1 second”)</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A pretty time string.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>timeformatted (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.to_bytes">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">to_bytes</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">session=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#to_bytes"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.to_bytes"title="Permalink to this definition">¶</a></dt>
<dd><p>Try to encode the given text to bytes, using encodings from settings or from Session. Will
always return a bytes, even if given something that is not str or bytes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>any</em>) – The text to encode to bytes. If bytes, return unchanged. If not a str, convert
to str before converting.</p></li>
<li><p><strong>session</strong> (<aclass="reference internal"href="evennia.server.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – A Session to get encoding info from. Will try this before
falling back to settings.ENCODINGS.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>the encoded text following the session’s protocol flag followed by the</dt><dd><p>encodings specified in settings.ENCODINGS. If all attempt fail, log the error and send
the text with “?” in place of problematic characters. If the specified encoding cannot
be found, the protocol flag is reset to utf-8. In any case, returns bytes.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>encoded_text (bytes)</p>
</dd>
</dl>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>If <cite>text</cite> is already bytes, return it as is.</p>
</div>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.to_str">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">to_str</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">session=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#to_str"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.to_str"title="Permalink to this definition">¶</a></dt>
<dd><p>Try to decode a bytestream to a python str, using encoding schemas from settings
or from Session. Will always return a str(), also if not given a str/bytes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>any</em>) – The text to encode to bytes. If a str, return it. If also not bytes, convert
to str using str() or repr() as a fallback.</p></li>
<li><p><strong>session</strong> (<aclass="reference internal"href="evennia.server.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – A Session to get encoding info from. Will try this before
falling back to settings.ENCODINGS.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The decoded text.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>decoded_text (str)</p>
</dd>
</dl>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>If <cite>text</cite> is already str, return it as is.</p>
</div>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.uses_database">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">uses_database</code><spanclass="sig-paren">(</span><emclass="sig-param">name='sqlite3'</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#uses_database"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.uses_database"title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if the game is currently using a given database. This is a
shortcut to having to use the full backend name.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>name</strong> (<em>str</em>) – One of ‘sqlite3’, ‘mysql’, ‘postgresql’</p></li>
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">validate_email_address</code><spanclass="sig-paren">(</span><emclass="sig-param">emailaddress</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#validate_email_address"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.validate_email_address"title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if an email address is syntactically correct.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>emailaddress</strong> (<em>str</em>) – Email address to validate.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>If this is a valid email or not.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>is_valid (bool)</p>
</dd>
</dl>
<dlclass="simple">
<dt>Notes.</dt><dd><p>(This snippet was adapted from
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">variable_from_module</code><spanclass="sig-paren">(</span><emclass="sig-param">module</em>, <emclass="sig-param">variable=None</em>, <emclass="sig-param">default=None</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#variable_from_module"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.variable_from_module"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve a variable or list of variables from a module. The
variable(s) must be defined globally in the module. If no variable
is given (or a list entry is <cite>None</cite>), all global variables are
extracted from the module.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>module</strong> (<em>string</em><em> or </em><em>module</em>) – Python path, absolute path or a module.</p></li>
<li><p><strong>variable</strong> (<em>string</em><em> or </em><em>iterable</em><em>, </em><em>optional</em>) – Single variable name or iterable
of variable names to extract. If not given, all variables in
the module will be returned.</p></li>
<li><p><strong>default</strong> (<em>string</em><em>, </em><em>optional</em>) – Default value to use if a variable fails to
be extracted. Ignored if <cite>variable</cite> is not given.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A single value or a list of values
depending on if <cite>variable</cite> is given or not. Errors in lists
are replaced by the <cite>default</cite> argument.</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>variables (value or list)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.wildcard_to_regexp">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">wildcard_to_regexp</code><spanclass="sig-paren">(</span><emclass="sig-param">instring</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#wildcard_to_regexp"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.wildcard_to_regexp"title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a player-supplied string that may have wildcards in it to
regular expressions. This is useful for name matching.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>instring</strong> (<em>string</em>) – A string that may potentially contain
wildcards (<cite>*</cite> or <cite>?</cite>).</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><dlclass="simple">
<dt>A string where wildcards were replaced with</dt><dd><p>regular expressions.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Return type</dt>
<ddclass="field-odd"><p>regex (str)</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.utils.wrap">
<codeclass="sig-prename descclassname">evennia.utils.utils.</code><codeclass="sig-name descname">wrap</code><spanclass="sig-paren">(</span><emclass="sig-param">text</em>, <emclass="sig-param">width=None</em>, <emclass="sig-param">indent=0</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/utils.html#wrap"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.utils.wrap"title="Permalink to this definition">¶</a></dt>
<dd><p>Safely wrap text to a certain number of characters.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>text</strong> (<em>str</em>) – The text to wrap.</p></li>
<li><p><strong>width</strong> (<em>int</em><em>, </em><em>optional</em>) – The number of characters to wrap to.</p></li>
<li><p><strong>indent</strong> (<em>int</em>) – How much to indent each line (with whitespace).</p></li>
<spanid="evennia-utils-validatorfuncs-module"></span><h2>evennia.utils.validatorfuncs module<aclass="headerlink"href="#module-evennia.utils.validatorfuncs"title="Permalink to this headline">¶</a></h2>
<p>Contains all the validation functions.</p>
<p>All validation functions must have a checker (probably a session) and entry arg.</p>
<p>They can employ more paramters at your leisure.</p>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.boolean">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">boolean</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='True/False'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#boolean"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.boolean"title="Permalink to this definition">¶</a></dt>
<dd><p>Simplest check in computer logic, right? This will take user input to flick the switch on or off
:param entry: A value such as True, On, Enabled, Disabled, False, 0, or 1.
:type entry: str
:param option_key: What kind of Boolean we are setting. What Option is this for?
:type option_key: str</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>Boolean</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.color">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">color</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Color'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#color"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.color"title="Permalink to this definition">¶</a></dt>
<dd><p>The color should be just a color character, so ‘r’ if red color is desired.</p>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.datetime">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">datetime</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Datetime'</em>, <emclass="sig-param">account=None</em>, <emclass="sig-param">from_tz=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#datetime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.datetime"title="Permalink to this definition">¶</a></dt>
<dd><p>Process a datetime string in standard forms while accounting for the inputer’s timezone. Always
returns a result in UTC.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>entry</strong> (<em>str</em>) – A date string from a user.</p></li>
<li><p><strong>option_key</strong> (<em>str</em>) – Name to display this datetime as.</p></li>
<li><p><strong>account</strong> (<aclass="reference internal"href="evennia.accounts.html#evennia.accounts.models.AccountDB"title="evennia.accounts.models.AccountDB"><em>AccountDB</em></a>) – The Account performing this lookup. Unless <cite>from_tz</cite> is provided,
the account’s timezone option will be used.</p></li>
<li><p><strong>from_tz</strong> (<em>pytz.timezone</em>) – An instance of a pytz timezone object from the
user. If not provided, tries to use the timezone option of the <ahref="#id217"><spanclass="problematic"id="id218">`</span></a>account’.
If neither one is provided, defaults to UTC.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>datetime in UTC.</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>ValueError</strong>– If encountering a malformed timezone, date string or other format error.</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.duration">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">duration</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Duration'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#duration"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.duration"title="Permalink to this definition">¶</a></dt>
<dd><p>Take a string and derive a datetime timedelta from it.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>entry</strong> (<em>string</em>) – This is a string from user-input. The intended format is, for example: “5d 2w 90s” for
‘five days, two weeks, and ninety seconds.’ Invalid sections are ignored.</p></li>
<li><p><strong>option_key</strong> (<em>str</em>) – Name to display this query as.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>timedelta</p>
</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.email">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">email</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Email Address'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#email"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.email"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.future">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">future</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Future Datetime'</em>, <emclass="sig-param">from_tz=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#future"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.future"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.lock">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">lock</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='locks'</em>, <emclass="sig-param">access_options=None</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#lock"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.lock"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">positive_integer</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Positive Integer'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#positive_integer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.positive_integer"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">signed_integer</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Signed Integer'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#signed_integer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.signed_integer"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.text">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">text</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Text'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#text"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.text"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="evennia.utils.validatorfuncs.timezone">
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">timezone</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Timezone'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#timezone"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.timezone"title="Permalink to this definition">¶</a></dt>
<dd><p>Takes user input as string, and partial matches a Timezone.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>entry</strong> (<em>str</em>) – The name of the Timezone.</p></li>
<li><p><strong>option_key</strong> (<em>str</em>) – What this Timezone is used for.</p></li>
<codeclass="sig-prename descclassname">evennia.utils.validatorfuncs.</code><codeclass="sig-name descname">unsigned_integer</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">option_key='Unsigned Integer'</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/validatorfuncs.html#unsigned_integer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.validatorfuncs.unsigned_integer"title="Permalink to this definition">¶</a></dt>