Skip to main content

Utilities for Python

Project description

py-utls

Utilities for Python

PyPI GitHub tag (latest by date) GitHub last commit GitHub issues GitHub

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 and TypeScript.

Usage

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;
  • number:
    • euclidean_division: compute the euclidean division of the passed integers.
from pyutls.hex import from_hex, to_hex
from pyutls.list import chunk, flatten
from pyutls.number import euclidean_division

# 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)

# Euclidean division
quotient, remainder = euclidean_division(numerator, denominator)
assertEqual(quotient * denominator + remainder == numerator)

It also constains a CustomLogger class (see its documentation for usage):

import logging
from pyutls import CustomLogger

logger = CustomLogger(level=logging.DEBUG)
logger.with_time("This test line should appear in test logs!", logging.INFO)

Tests

Eventually, add a setup step:

$ git clone https://github.com/cyrildever/py-utls.git
$ cd py-utls/
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install build twine setuptools

Then, proceed to testing:

$ python3 -m unittest discover

License

These modules are distributed under a MIT license.
See the LICENSE file.


© 2022-2026 Cyril Dever. All rights reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_utls-0.3.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_utls-0.3.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file py_utls-0.3.2.tar.gz.

File metadata

  • Download URL: py_utls-0.3.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for py_utls-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e82b3ce46b2a1d4c271b96df85f02ae83a2a1b45d4fbb25c2a4cf312a3af479e
MD5 7b737cb2eea0f5f5f0986ea7964c462e
BLAKE2b-256 6f06132acbf60decdd1a6a1e852fe87ab94c8217200b1c558003a720847904f2

See more details on using hashes here.

File details

Details for the file py_utls-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: py_utls-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for py_utls-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d8d531bdbf1301a501058e2e6d53f3f057657adf93d8f5b343254e816fdf3092
MD5 50fb707caaaefe71d8aab389937cfb3f
BLAKE2b-256 96e8dc9ce84f6f997254bee24f09366af94333a9b7795aa06da5d74857ecd687

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page