conversion
Utility functions to convert strings to Python types.
convert_base64
Converts base64 encoded strings or bytes into strings:
>>> from conversion import convert_base64
>>> convert_base64('dGVzdA==')
'test'
If the payload is expected to be bytes, string conversion can be suppressed:
>>> convert_base64('dGVzdA==', convert_string=False)
b'test'
When the function does not find the string can be converted, an exception can be raised:
>>> convert_base64('dGVzdA=', raise_exceptions=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/berto/Projects/home/conversion/conversion/base64.py", line 28, in convert_base64
converted = base64.b64decode(value)
File "/Users/berto/.local/share/virtualenvs/conversion-bncB6LgQ/lib/python3.6/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
convert_bool
Converts truthy strings to True and falsey strings to False:
>>> from conversion import convert_bool
>>> convert_bool('yes')
True
>>> convert_bool('no')
False
When the function does not find the string can be converted, ValueError is raised:
>>> convert_bool('yup')
ValueError: invalid truth value 'yup'
convert_delta
Converts time with unit suffixes into datetime.timedelta objects:
>>> from conversion import convert_delta
>>> convert_delta('1h')
datetime.timedelta(0, 3600)
convert_json
Converts JSON strings into objects:
>>> from conversion import convert_json
>>> convert_json('{"some": "dict", "in": "json"}')
{'some': 'dict', 'in': 'json'}
convert_list
Converts a comma-delimited string into a list:
>>> from conversion import convert_list
>>> convert_list('a,comma,delimited,list')
['a', 'comma', 'delimited', 'list']
And an optional kwarg can specify the delimiter:
>>> convert_list('a:colon:delimited:list', delimiter=':')
['a', 'colon', 'delimited', 'list']
Metadata
Release files for conversion 0.0.9
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 | |
|---|---|---|---|---|
| conversion-0.0.9.tar.gz | 46.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| conversion-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.0 kB
Release files / conversion-0.0.9.tar.gz
| Download URL | conversion-0.0.9.tar.gz |
|---|---|
| Size | 46.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b09e71c93b1bc876d73a6644ceb09df9cab9af78ecb6d309b880c5f355b4b51
|
|
BLAKE2b-256 checksum How to use checksums |
e9c4a3b4e8a2d3d6566f16e16484b3b7215b15bdbee6b26486c458dac72ebecd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.19
|
Release files / conversion-0.0.9-py3-none-any.whl
| Download URL | conversion-0.0.9-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4bcbe02338daaf3335221d97f6cc728eda3c7d7140ab41cde7d82f15d53d6a8
|
|
BLAKE2b-256 checksum How to use checksums |
00c4781c23b08e2af43ef3aedfa0467486d129fd0906882a784f92c21c9d277a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.19
|
Security for conversion 0.0.9
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.