Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyrildever/py-utls
Utilities for Python
https://github.com/cyrildever/py-utls
python utilities-library
Last synced: about 2 months ago
JSON representation
Utilities for Python
- Host: GitHub
- URL: https://github.com/cyrildever/py-utls
- Owner: cyrildever
- License: mit
- Created: 2022-02-18T10:32:39.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-08T07:44:44.000Z (11 months ago)
- Last Synced: 2024-11-13T08:46:10.318Z (about 2 months ago)
- Topics: python, utilities-library
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# py-utls
_Utilities for Python_![PyPI](https://img.shields.io/pypi/v/py-utls)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/cyrildever/py-utls)
![GitHub last commit](https://img.shields.io/github/last-commit/cyrildever/py-utls)
![GitHub issues](https://img.shields.io/github/issues/cyrildever/py-utls)
![GitHub](https://img.shields.io/github/license/cyrildever/py-utls)`py-utls` is a small Python repository where I put all the useful stuff I regularly need in my projects. \
Feel free to use at your discretion with the appropriate license mentions._NB: I've developed the same kind of libraries for both [Go](https://github.com/cyrildever/go-utls) and [TypeScript](https://www.npmjs.com/package/ts-utls)._
### Usage
```console
pip install py-utls
```This repository contains the following modules:
* `hex`:
- `from_hex`: builds the byte array from a string;
- `to_hex`: creates the hexadecimal representation of a byte array;
* `list`:
- `chunk`: split a list into chunks of a maximum size;
- `flatten`: transforms a list of list of items to a list of items.```python
from pyutls.hex import from_hex, to_hex
from pyutls.list import chunk, flatten# Hex utilities
barray = from_hex('1234abcd')
hex_string = to_hex(barray)
assertEqual(hex_string == '1234abcd')# Flatten a list of list
chunks = chunk(some_list, size)
flat_list = flatten(chunks)
assertListEqual(flat_list == some_list)
```### Tests
```console
$ python3 -m unittest discover
```### License
These modules are distributed under a MIT license. \
See the [LICENSE](LICENSE) file.
© 2022-2024 Cyril Dever. All rights reserved.