param-parser
param-parser is a parser library for a param string expression. Those expressions are arbitrary strings with
placeholders in it, where a placeholder consists of a name, an optional type and a list of options.
Installation
With a correctly configured pipenv toolchain:
pipenv install param-parser
You may also use classic pip to install the package:
pip install param-parser
Getting started
Examples of param string expressions look as follows:
this-is-a-{param:string:option1,option2,option3}-expression
this-is-a-{param:string}-expression
this-is-a-{param}-expression
As you see, a param is introduced by an opening curly bracket, followed by the name of the param, a colon, the type of the param, another colon and a comma separated list of options. The param configuration gets terminated by a closing curly bracket. Note that the type and option configuration are optional, but the name is mandatory.
To parse an expression shown above, use the Python code as follows:
import param_parser
result = param_parser.parse(r"this-is-a-{param:string:option1,option2,option3}-expression")
result[0] # Gets a `param_parser.node.SequenceNode` instance
result[0].sequence_value # Gets `"this-is-a-"` as a string
result[1] # Gets a `param_parser.node.ParamNode` instance
result[1].param_name # Gets `"param"` as a string
result[1].param_type # Gets `"string"` as a string
result[1].param_options # Gets `["option1", "option2", "option3"]` as a list of strings
result[2] # Gets a `param_parser.node.SequenceNode` instance
result[2].sequence_value # Gets `"-expression"` as a string
It is also possible to escape opening curly brackets, closing curly brackets, colons and commas as follows:
import param_parser
result = param_parser.parse(r"this-is-a-\{param:string:option1,option2,option3\}-expression")
result[0] # Gets a `param_parser.node.SequenceNode` instance
result[0].sequence_value # Gets `"this-is-a-{param:string:option1,option2,option3}-expression"` as a string
Supported versions
| This Project | Python Version |
|---|---|
| 1.2.* | 3.10-3.14 |
| 1.1.* | 3.9-3.13 |
| 1.0.* | 3.7-3.11 |
List of developers
- Andreas Stocker AStocker@anexia-it.com, Lead Developer
Metadata
Release files for param-parser 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| param_parser-1.2.0.tar.gz | 13.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| param_parser-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / param_parser-1.2.0.tar.gz
| Download URL | param_parser-1.2.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
018e7d9ac4bab1590636fa106482c32c5fe33bf01e21676cd5c127da73479893
|
|
BLAKE2b-256 checksum How to use checksums |
3ec265b0bee0697262e1627b33ef57a844c9aa742c8acd6004a3dc0781f092e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / param_parser-1.2.0-py3-none-any.whl
| Download URL | param_parser-1.2.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
664733350654cc1a5f2e6cc408030ea5fec6f56455513113ea1fa78e32113b86
|
|
BLAKE2b-256 checksum How to use checksums |
840142579a4fb075bfeea25749b801edbe2d091d327aa3f7aa5967a1b0c9d1be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|