stift
An awesome module for executing "safe" functions from strings.
Parser Module
Parse a string with functions, strings, variables, and arrays. This allows an executor to construct the response of the string execution.
A tool to use these arguments should start at the end of the returned array (lowest level) and work upwards. Anything of type "str", "int", or "float" can be used as-is. Anything with type ParseTypes.array, ParseTypes.function, or ParseTypes.variable need to be processed.
:param s: String to be parsed
:type s: str
:raises ParserError: Issue with parsing somewhere along the line
:return: Returns a nested list of "Token" dictionaries. These always include a value and a type.
For functions, there will also be an argc and argv element (see example)
For arrays, there will also be an index element (See example)
{
type: ParseTypes.function, # Type can be str, int, float, or a ParseTypes element
value: "ceiling" # Variable value or function/array name
argc: 2, # (Functions only) number of arguments
argv: [(1,2), (1,3)], # (Functions only) pointer to arg locations e.g. parsed[1][2]
}
:rtype: List[List[dict]]
Parser Example
from stift.parser import Parser, ParserError, ParseTypes
s = r"""blend(banana, kiwi(1,2,"\"yes\" or \"no\"", mango[0]))"""
parsed = Parser().parse(s)
# Returns the following:
# [
# [
# {
# "type": ParseTypes.function,
# "value": "b",
# "argc": 2,
# "argv": [(1, 0), (1, 1)],
# }
# ],
# [
# {"type": str, "value": "a"},
# {"type": ParseTypes.array, "value": "s", "index": (2, 0)},
# ],
# [{"type": int, "value": 0}],
# ]
Functions (WIP)
Metadata
Release files for stift 0.3.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 | Provenance | Actions |
|---|---|---|---|---|
| stift-0.3.0.tar.gz | 9.5 kB | Without provenance | Details for stift-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stift-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for stift-0.3.0-py3-none-any.whl |
Total release size: 20.1 kB
Release files / stift-0.3.0.tar.gz
| Download URL | stift-0.3.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70b76a41d868f8141ac45a7adf29ee6cb36f5fd57dc505b767cd6426cf93a4ed
|
|
BLAKE2b-256 checksum How to use checksums |
90ec5108a3e9e4f185c81eca4be6918c743c9ba82915dd20705bec3eee4bfddd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Release files / stift-0.3.0-py3-none-any.whl
| Download URL | stift-0.3.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e67ef0e7506f877dfb13cabb73241b8e4595893c063a86500a5429ed616feaf
|
|
BLAKE2b-256 checksum How to use checksums |
3728c9fd8a4c66d98078b840b6966b7f4876df2d639a3d9e5ce3c4cd553248f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Security for stift 0.3.0
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.