parspy
A tool to parse text into a list where it can be interpreted and executed.
Install
Install using pip install parspy.
Usage
First, import and initiate the class:
import re
import parspy
parsertool = parspy.Parser()
Then, add elements to the alphabet:
parsertool.addelems("ad", "bc", " ")
If you have things more complicated than static elements, use the setregelems method by feeding it compiled regex objects:
parsertool.setregelems(number = re.compile("Number: \d+"), string = re.compile("String: '.*'"))
But what use is this without using it to parse something? None. Here is how you parse a string with this:
parsertool.parse("adbcbcbcad Number: 123 String: 'banana!'")
The output should be:
['ad', 'bc', 'bc', 'bc', 'ad', ' ', ' ', {'number':'Number: 123'}, ' ', ' ', ' ', ' ', ' ', ' ', {'string':"String: 'banana!'"}]
Now you can pass this into a program where it can be processed more easily.
If something goes wrong during parsing, a ParseError will be thrown.
Notes
It seems to have an issue when executing in a REPL environment (name 're' is not defined).
Metadata
Release files for parspy 0.0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| parspy-0.0.1.1.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| parspy-0.0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / parspy-0.0.1.1.tar.gz
| Download URL | parspy-0.0.1.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5262ac42dbfef4935ca79f8df15a41c9a4565d21dd7b09d12e9c0e1ceb12fc0
|
|
BLAKE2b-256 checksum How to use checksums |
0e0f57457318e4b643ac0127bc700f4e1cb2589d0795feed1527a9392d3b6fd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / parspy-0.0.1.1-py3-none-any.whl
| Download URL | parspy-0.0.1.1-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b9d6849650746c10e7c21c897699776eeb35e287ea1baefcceba03688ba6b00
|
|
BLAKE2b-256 checksum How to use checksums |
d5bab38b2e62f01d49ded30d802b8b47848603931f7962bb689211fd245ec7d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|