A python parser combinator library, inspired by Nom for Rust
Project description
Nompy
A Python parser combinator library inspired by the Nom library in Rust. This project is in no way affiliated with the original Nom Rust project.
Examples
Parse Name
Parse a name and apply a simple transformation.
from nom.combinators import succeeded, tag, take_rest, take_until, tuple_
from nom.modifiers import apply
to_parse = "john doe"
parser = tuple_(
apply(succeeded(take_until(" "), tag(" ")), str.capitalize),
apply(take_rest(), str.capitalize),
)
result, remaining = parser(to_parse)
firstname, lastname = result
print(firstname, lastname) # John Doe
Parse Phone Number
Parse an MSISDN with preceeding +
from nom.combinators import preceeded, tag, take_while
to_parse = "+1234567890"
parser = preceeded(take_while(str.isnumeric), tag("+"))
result, remaining = parser(to_parse)
print(result)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nom-0.1.0b3.tar.gz.
File metadata
- Download URL: nom-0.1.0b3.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd5fe2893fd9392d518b7ec1708eec4d8e661b8f85848be3207ba4783ab2c3cd
|
|
| MD5 |
956695b4e8ec409f7f2995ccb12db65e
|
|
| BLAKE2b-256 |
4846528320dc239f843cb7d41a235255af93671d8cc76a54f86f983d43c38c9d
|
Provenance
The following attestation bundles were made for nom-0.1.0b3.tar.gz:
Publisher:
publish.yml on Harry-Lees/Nompy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nom-0.1.0b3.tar.gz -
Subject digest:
dd5fe2893fd9392d518b7ec1708eec4d8e661b8f85848be3207ba4783ab2c3cd - Sigstore transparency entry: 211008921
- Sigstore integration time:
-
Permalink:
Harry-Lees/Nompy@c5f4164d6c61e16d90bcd29da51a63e0a9424ae1 -
Branch / Tag:
refs/tags/v0.1.0b3 - Owner: https://github.com/Harry-Lees
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c5f4164d6c61e16d90bcd29da51a63e0a9424ae1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file nom-0.1.0b3-py3-none-any.whl.
File metadata
- Download URL: nom-0.1.0b3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c97635aa344a1d01f2a48926f7f059b048dcc0a76029edf97dad2e6c23659f2e
|
|
| MD5 |
a4a586ad3238c6d15bd1917adedeafd1
|
|
| BLAKE2b-256 |
8e0bf7008de1a0eef13d151e67518809fc90f462f1a980203f327bb51d945a7e
|
Provenance
The following attestation bundles were made for nom-0.1.0b3-py3-none-any.whl:
Publisher:
publish.yml on Harry-Lees/Nompy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nom-0.1.0b3-py3-none-any.whl -
Subject digest:
c97635aa344a1d01f2a48926f7f059b048dcc0a76029edf97dad2e6c23659f2e - Sigstore transparency entry: 211008937
- Sigstore integration time:
-
Permalink:
Harry-Lees/Nompy@c5f4164d6c61e16d90bcd29da51a63e0a9424ae1 -
Branch / Tag:
refs/tags/v0.1.0b3 - Owner: https://github.com/Harry-Lees
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c5f4164d6c61e16d90bcd29da51a63e0a9424ae1 -
Trigger Event:
release
-
Statement type: