Misc Python utils
pip install git+https://github.com/Jylpah/pyutils.git
pip install --upgrade git+https://github.com/Jylpah/pyutils.git
- AliasMapper(): Pydantic helper class to map field names to field aliases.
- AsyncQueue(asyncio.Queue, Generic[T]): Implement
async.Queue()
interface for non-async queues usingasyncio.sleep()
andget_nowait()
andput_nowait()
methods. Handy when using async code withmultiprocessing
- BucketMapper(Generic[T]): Class to map objects into fixed buckets according to an attribute (
float|int
). Usesbisect
package. - CounterQueue(asyncio.Queue): Async Queue that keeps count on
task_done()
completed - EventCounter(): Count / log statistics and merge different
EventCounter()
instances to provide aggregated stats of the events counted - FileQueue(asyncio.Queue): Class to build file queue to process from command line arguments or STDIN (
-
) - IterableQueue(Queue[T], AsyncIterable[T], Countable):: Async queue that implements
AsyncIterable()
. The queue supports join(). Bit complex, but I could not figure how to simplify it while implenting bothjoin()
andAsyncIterable()
- MultilevelFormatter(logging.Formatter): Log using different formats per logging level
- ThrottledClientSession(aiohttp.ClientSession): Rate-throttled client session class inherited from aiohttp.ClientSession
- utils module for ... utils of pyutils