Skip to main content

emote-utils

Emote utilities for text-based games.

This package is most useful for formatting social strings for use with text-based games like MUDs and MOOs.

A social string might look like:

%1N smile%1s at %2n.

Quickstart

First get a factory ready. You could use the base SocialsFactory class or the helpfully-populated PopulatedSocialsFactory.

This second class contains useful english grammar suffixes for properly converting words like are to is and proper use of e and s for use at the end of words.

from emote_utils import PopulatedSocialsFactory
f = PopulatedSocialsFactory()
@f.suffix('n', 'name')
    def get_name(obj, suffix):
        return ('you', obj.name)

Next let's create a test class.

class Person:
    def __init__(self, name):
        self.name = name

p1 = Person('Jack')
p2 = Person('Jill')

Now we'll get strings which can be sent to Jack, Jill and anyone else who should see the message.

jack_string, jill_string, others_string = f.get_strings('%1N smile%1s at %2n.', [p1, p2])
print(jack_string)

You smile at Jill.

print(jill_string)

Jack smiles at you.

print(others_string)

Jack smiles at Jill.

More advanced usage

Social Formatters

Each social formatter is made up of three parts:

  • a per cent (%) sign representing the start of a social formatter.
  • an optional number indicating the index of the object you wish to reference in the list of objects.
  • An optional filter name preceded by a vertical bar (|).

Defaults

  • If no index is provided, SocialsFactory.default_index is used.
  • If no suffix is provided, SocialsFactory.default_suffix is used.
  • If no filter is provided then one of 3 things will happen.

In the below list suffix refers either to the name of a suffix provided as part of the social string or the default_suffix attribute on the instance of SocialsFactory that get_strings is being called on.

Attribute names refer to the attributes of SocialsFactory that get_strings is being called on.

  • If the suffix is title case then the title_case_filter attribute will be used.
  • If the suffix is all upper case then the upper_case_filter attribute will be used.
  • If neither of these things are true then suffix is assumed to be lower case and the lower_case_filter is used.

Of course any of these names could be None in which case no filtering is applied.

Filters

Here is an example of a custom filter:

f.filters['strong'] = lambda string: f'<strong>{string}</strong>'

If you were printing your socil strings to HTML you could use this filter to make certain parts of the text stand out.

With this filter created, you could do:

%1N punch%1e %2n|strong.

A string might then look like:

John punches Jack.

Conclusion

To see all the other configuration options see the docstrings in the package.

Metadata

Release files for emote-utils 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for emote-utils 2.0.1
File Size Uploaded Provenance Actions
emote_utils-2.0.1.tar.gz 14.3 kB Without provenance Details for emote_utils-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for emote-utils 2.0.1
File Interpreter ABI Platform Actions
emote_utils-2.0.1-py3-none-any.whl Python 3 none any Details for emote_utils-2.0.1-py3-none-any.whl

Total release size: 26.4 kB

Release files / emote_utils-2.0.1.tar.gz

Download URL emote_utils-2.0.1.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
173929e93edce70a8a62a1645d56b487c97f2a18cb3a84e350bc037ca5d18433
BLAKE2b-256 checksum
How to use checksums
a83473c8e7b0d736cc3b5ca0ca7754c608d4273de2f51f37e77ef2ad49f67f1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Release files / emote_utils-2.0.1-py3-none-any.whl

Download URL emote_utils-2.0.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ac92db91273d9cc5da36731fc4ad92943d7b45193a330f5a1a436959ec0703e
BLAKE2b-256 checksum
How to use checksums
96dbfbd4d5ff741835c71414de8ecfaffb3c8bf8606e1ab7425238c8609400e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Security for emote-utils 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page