blackbull.utils¶
blackbull.utils
¶
Shared utilities and enumerations.
Provides:
Scheme:StrEnumwithhttpandwebsocketvalues used throughout routing.check_port: returnsTruewhen a host/port is not yet in use.pop_safe: moves a key between dicts with an optional rename, no-op when absent.parse_post_data: parsesapplication/x-www-form-urlencodedbodies.EventEmitter: lightweight async event-emitter backed byasyncio.create_task.
EventEmitter
¶
Lightweight async event-emitter backed by asyncio.create_task.
Experimental
This class is under active development and its API is not yet stable. Do not use in production code — method signatures and behaviour may change without notice.
Listeners registered with on are called every time the event fires.
Listeners registered with once are called exactly once, then removed.
serializable
¶
Bases: ABC
Abstract base for serializable classes. Subclasses must implement save() and load().
check_port(host='localhost', port=None)
¶
Returns True: Port is not used. Returns False: Port is used.
pop_safe(key, source, target, *, new_key=None)
¶
Move source[key] into target (under new_key if given), if present.
Returns target unchanged when key is absent from source.