Skip to main content

param-parser

PyPI Test Status Codecov

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

param_parser-1.2.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

param_parser-1.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file param_parser-1.2.0.tar.gz.

File metadata

  • Download URL: param_parser-1.2.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for param_parser-1.2.0.tar.gz
Algorithm Hash digest
SHA256 018e7d9ac4bab1590636fa106482c32c5fe33bf01e21676cd5c127da73479893
MD5 356021ac57ef9d92b365b2aec1e53daf
BLAKE2b-256 3ec265b0bee0697262e1627b33ef57a844c9aa742c8acd6004a3dc0781f092e4

See more details on using hashes here.

File details

Details for the file param_parser-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: param_parser-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for param_parser-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 664733350654cc1a5f2e6cc408030ea5fec6f56455513113ea1fa78e32113b86
MD5 09c8affc29875d04846799172505e3b4
BLAKE2b-256 840142579a4fb075bfeea25749b801edbe2d091d327aa3f7aa5967a1b0c9d1be

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 files

1.1.0

2 files

1.0.0

2 files

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