Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goldenm-software/general-conversors
Helper library multi-purposes used in our systems
https://github.com/goldenm-software/general-conversors
Last synced: 9 days ago
JSON representation
Helper library multi-purposes used in our systems
- Host: GitHub
- URL: https://github.com/goldenm-software/general-conversors
- Owner: goldenm-software
- License: mit
- Created: 2024-02-15T07:02:36.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-15T07:04:14.000Z (11 months ago)
- Last Synced: 2024-03-15T07:23:50.429Z (10 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Multi-purposes conversors for Python
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/goldenm-software/open-source-libraries/general-conversors/blob/master/LICENSE)
[![pypi version](https://badge.fury.io/py/general-conversors.svg)](https://pypi.org/project/general-conversors/)## Installation
Use the package manager [pip](https://pypi.org/) to install general-conversors.```bash
pip3 install general-conversors
```## Usage
To 1-Level dictionary
```python
from conversor.dict import ToOneLevelsource = {
'error': False,
'result': {
'executed': True,
'payload': 'Hello world',
'code': 200,
'source_code_url': 'http://google.com'
}
}## replace_underscore as True
conversor = ToOneLevel(source=source, replace_underscore=True)
result = conversor.convert()
print('Result replacing underscore:', result)
# Result replacing underscore: {'error': False, 'result.executed': True, 'result.payload': 'Hello world', 'result.code': 200, 'result.source.code.url': 'http://google.com'}## replace_underscore as False (Default)
conversor = ToOneLevel(source=source)
result = conversor.convert()
print('Result:', result)
# Result: {'error': False, 'result.executed': True, 'result.payload': 'Hello world', 'result.code': 200, 'result.source_code_url': 'http://google.com'}```
To N-level level dictionary
```python
from conversor.dict import ToMultiLevelsource = {
'error': False,
'result.executed': True,
'result.payload': 'Hello world',
'result.code': 200
}conversor = ToMultiLevel(source=source)
result = conversor.convert()
print('Result:', result)
# Result: {'error': False, 'result': {'executed': True, 'payload': 'Hello world', 'code': 200}}
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)