twh_parser
(c) Michael Perkins, 2023, 2024
Introduction/usage
Parses exported files from TroopWebHost, into YAML/TOML/JSON format or for use in Python projects. Also hooks into the objexplore browser for data checking/viewing.
Installation
pip install twh-parser
Instructions:
In troopwebhost
YAML can be read in python with:
import yaml
with open('output.yaml') as f:
scouts = yaml.safe_load(f)
Using twh_parser in code:
from twh_parser import Parser
#initializing the parser automatically parses the file and stores
#the information in TmParser().scouts
parser = TmParser(infile='filename.pdf')
# Iterating on the parser yields scouts
for scout in parser:
print('----------------------------------------------')
print(f"{scout['Data']['Name']:26}Date Eagle Req")
print('----------------------------------------------')
## do something with scout
if "Merit Badges" in scout:
#sort merit badges by date ascending
for badge, data in sorted(scout['Merit Badges'].items(),
key=lambda x: x[1]['date']):
print(f"{badge:26}{data['date']} {data['eagle_required']}")
Yields:
----------------------------------------------
Smith, John Date Eagle Req
----------------------------------------------
Climbing 2017-03-11 False
Mammal Study 2017-06-29 False
Leatherwork 2017-06-30 False
Swimming 2017-06-30 True
Kayaking 2018-06-29 False
Wilderness Survival 2018-06-29 False
Rifle Shooting 2018-06-29 False
First Aid 2018-09-29 True
By default the information is a dictionary, with the scout names as keys, and each scout is a dictionary with the following keys:
- Data - contains biographical data
- Merit Badges
- Partial Merit Badges
- Rank Advancement
All dates have been parsed into datetime.date objects, in YYYY-MM-DD format, and are null if not assigned in the incoming data.
Metadata
Release files for twh-parser 0.15.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 |
|---|---|---|---|---|
| twh_parser-0.15.0.tar.gz | 538.7 kB | Without provenance | Details for twh_parser-0.15.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| twh_parser-0.15.0-py3-none-any.whl | Python 3 | none | any | Details for twh_parser-0.15.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / twh_parser-0.15.0.tar.gz
| Download URL | twh_parser-0.15.0.tar.gz |
|---|---|
| Size | 538.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ad4a47911c4533ba2480618e4234198a87cd58ce8fc212e531baf1477cedc69
|
|
BLAKE2b-256 checksum How to use checksums |
6e73a7a37b2d0979843cc7a37f13c02a9b218fec08bd485b9be1795ba45e63d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Release files / twh_parser-0.15.0-py3-none-any.whl
| Download URL | twh_parser-0.15.0-py3-none-any.whl |
|---|---|
| Size | 546.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d3238d7690ce3221e5b76b38310e883852ae397bfd47f028aec0fffd3fd5b26
|
|
BLAKE2b-256 checksum How to use checksums |
73fb1b84e346aa0c3f0d3f8d150112c46ef66c8e80ba7d8b0e990c4a9548f44e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Security for twh-parser 0.15.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.