tag-formatter
Tag-formatter is a Python Package designed to format strings that based on user-input.
For example, tag-formatter can parse something such as:
Hello there, {user}!
Into something like:
Hello there, John!
Installation
You can install tag-formatter using pip.
pip install tag-formatter
Features
- Highly customizable
- Uses regex delimiters that you can set.
- Uses a parser rather than things like
str.format- Because this was meant for user input, str.format wouldn't work (invalid tags mean KeyErrors)
- str.replace on the other hand, would be too tedious and limited.
- Argument parsing for tags
- Basic and function-based converters
- Default values for arguments
Example
You can find more examples in the examples folder.
import random
import tagformatter
class User:
name = 'John'
age = 21
parser = tagformatter.Parser()
@parser.tag("user")
def user_tag(env):
return env.user.name
@user_tag.tag("age")
def user_age_tag(env):
return env.user.age
@parser.tag("random", alias="rng")
def rng_tag(env, low: int = 1, high: int = 10):
return random.randint(low, high)
print(parser.parse("{user} is {user.age} years old. Random number: {random:1, 20}",
env={"user": User()}))
Metadata
Release files for tag-formatter 1.3.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tag-formatter-1.3.11.tar.gz | 5.3 kB | Without provenance | Details for tag-formatter-1.3.11.tar.gz |
Release files / tag-formatter-1.3.11.tar.gz
| Download URL | tag-formatter-1.3.11.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d6fb63114b4e3f506d922aae035f3393b9e173601f442b0b8267ad4f506361d
|
|
BLAKE2b-256 checksum How to use checksums |
2a191e201de7348bddd3fb6a0b8e6337fbd433a684d6267158fed63fc9b25ad5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for tag-formatter 1.3.11
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.