Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

renum

pypi Licensed under the MIT License Ruff pre-commit.ci status

Regex Enum

A utility class for generating Enum-like regular expression patterns.

Installing

python3 -m pip install -U renum

Development version:

python3 -m pip install -U https://github.com/Zephyrkul/renum/archive/master.zip#egg=renum

Support

If you need help with using renum, find a bug, or have a feature request, feel free to file an issue.

Examples

Parsing from standard input:

import regex
from renum import renum


class Actions(renum, flags=regex.IGNORECASE):
    GO = r"go (?P<direction>north|south|east|west)"
    EXAMINE = r"examine (?P<item>[\w\s]+)"
    OPEN = r"open (?P<object>door|chest)"


if __name__ == "__main__":
    while True:
        line = input()
        if not line:
            break
        action = Actions.match(line)  # The renum class acts like a Pattern...
        if action is Actions.GO:
            print("You went %s" % action.group("direction"))  # and each entry acts like a Match
        elif action is Actions.EXAMINE:
            print("You take a closer look at %s. Looks grungy." % action.group("item"))
        elif action is Actions.OPEN:
            print("You tried to open the %s, but it was locked." % action.group("object"))
        else:
            print("Unknown action: %s" % line)

Troubleshooting a misbehaving renum:

>>> import regex
>>> from renum import renum
>>>
>>> class Bad(renum, flags=regex.IGNORECASE | regex.DEBUG):
...     GOOD = r"no (?:issues|problems) here"
...     BAD = r"whoops,\s(?P<missed something)"
...
regex.error: bad character in group name at position 29 in BAD
whoops,\s(?P<missed something)
                             ^

Requirements

Metadata

Release files for renum 0.0.1b1

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

Source distribution (sdist)

Source distribution for renum 0.0.1b1
File Size Uploaded Provenance Actions
renum-0.0.1b1.tar.gz 10.2 kB Without provenance Details for renum-0.0.1b1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for renum 0.0.1b1
File Interpreter ABI Platform Actions
renum-0.0.1b1-py3-none-any.whl Python 3 none any Details for renum-0.0.1b1-py3-none-any.whl

Total release size: 18.3 kB

Release files / renum-0.0.1b1.tar.gz

Download URL renum-0.0.1b1.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
30c367de3f95f079210508d497b5224002337422ddb43ae4dd83a199b3c87df7
BLAKE2b-256 checksum
How to use checksums
c0af6808c4b073bcef563169ab389a1641ef87f10672bacc0663793bd98e80af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / renum-0.0.1b1-py3-none-any.whl

Download URL renum-0.0.1b1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8610e2c1cecfc39cce56a58216a2fecf9c6d369dfe5addec8773ca9fac4e18b
BLAKE2b-256 checksum
How to use checksums
d934390007ac148c9df3c63cb27351dad5a3b20f687b41aa448c03957c5bc5e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Security for renum 0.0.1b1

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.

Release history Release notifications | RSS feed

This release
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