smartparse
Makes the ConfigParser smarter.
A SmartParser provides methods to parse options as objects of the datetime-modules, as list or as ‘smartlist’. Items of a smartlist are automatically tried to converted into different types (such as: int, float, time, date, datetime).
It also provides additional get- and itme-methods (xget, xitem): xget tries to get the option as one of the following types (in this order): int, float, boolean, time, date, datetime, smartlist. If every type fails the option is given as string.
Latest Version
The latest version of this project can be found at : http://github.com/thomst/smartparse.
Installation
Option 1 : Install via pip
pip install smartparse
Option 2 : If you have downloaded the source
python setup.py install
Documentation
How to use?
import io
from smartparse import SmartParser
CONFIG = """
[Section]
bool = yes
int = 3
float = 3.3
time = 23:55:00
date = 2013.04.24
datetime = 2013.04.24 23:55:00
list = one two three four
smartlist = 3 4.4 1:55 yes 2013.04.24 2013.04.24_01:55
"""
config = SmartParser(allow_no_value=True)
config.readfp(io.BytesIO(CONFIG))
section = dict(self.config.xitems('Section'))
section['bool'] # True
section['datetime'] # datetime.datetime(2013, 4, 24, 23, 55)
section['list'] # ['one', 'two', 'three', 'four']
section['smartlist'][2] # datetime.time(1, 55)
section['smartlist'][4] # datetime.date(2013, 4, 24)
Changes v0.5:
- Backwards incompatibility:
getsmartlist became getxlist. Removed the config-methods. Use the timeparser-module directly to change the configuration about parsing time-, date- and datetime-objects.
Reporting Bugs
Please report bugs at github issue tracker: https://github.com/thomst/smartparse/issues
Metadata
Release files for smartparse 0.4.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 |
|---|---|---|---|---|
| smartparse-0.4.0.tar.gz | 3.4 kB | Without provenance | Details for smartparse-0.4.0.tar.gz |
Release files / smartparse-0.4.0.tar.gz
| Download URL | smartparse-0.4.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69ea7c989c085c45da0f3cb3655750aa1c5f6a9f0c593c5c925f850108aed08f
|
|
BLAKE2b-256 checksum How to use checksums |
d36608cbc1b9d631849051ff5ca3aa683435fc1a3425acb1004f9a2a5bd61608
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for smartparse 0.4.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.