A Package containing my utils
Project description
cbaxter1988_utils
These Packages are a collection of helpful utilities I utilize in numerous projects.
Usage
Running Tests
git clone https://github.com/cbaxter1988/utils.git
pip install -r requirements.txt
python invoke_tests.py
Instalation
Using PIP
pip install cbaxter1988-utils
From Source
git clone https://github.com/cbaxter1988/utils.git
python setup.py install
Utilities
core_utils
Cloning Objects:
from cbaxter1988_utils import core_utils
original_list = [1, 2, 3, 4]
cloned_list = core_utils.clone_object(original_list)
enviornment_utils
Utilities for interacting with your enviornment.
Examples:
from cbaxter1988_utils import environment_utils
# Gets env with side-effect
try:
var = environment_utils.get_env_strict(key="AWS_REGION")
except KeyError:
raise
# Gets env
var = environment_utils.get_env(key="AWS_REGION", default_value="us-east-1")
# Sets env
environment_utils.set_env(key="AWS_REGION", val="us-west-1")
pika_utils
Utitilies for publishing and consuming messages with pika
from cbaxter1988_utils import pika_utils
from cbaxter1988_utils.pika_utils import BlockingChannel
from pika.spec import Basic, BasicProperties
AMQP_USER = 'guest'
AMQP_PW = 'guest'
AMQP_HOST = '127.0.0.1'
AMQP_PORT = 5672
EXCHANGE_NAME = 'test_exchange'
ROUTING_KEY_NAME = 'test_routing_key'
QUEUE_NAME = 'QUEUE_NAME'
AMQP_URL = pika_utils.make_amqp_url(amqp_user=AMQP_USER, amqp_pw=AMQP_PW, amqp_host=AMQP_HOST, amqp_port=AMQP_PORT)
publisher = pika_utils.make_basic_pika_publisher(
amqp_url=AMQP_URL,
queue=QUEUE_NAME,
exchange=EXCHANGE_NAME,
routing_key=ROUTING_KEY_NAME
)
def message_handler(ch: BlockingChannel, method: Basic.Deliver, properties: BasicProperties, body):
pass
# Do Work
subscriber = pika_utils.make_basic_pika_consumer(
amqp_url=AMQP_URL,
queue=QUEUE_NAME,
on_message_callback=message_handler
)
publisher.publish_message(body={"test": "data"})
subscriber.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cbaxter1988_utils-0.9.4.tar.gz
(19.4 kB
view details)
Built Distribution
File details
Details for the file cbaxter1988_utils-0.9.4.tar.gz
.
File metadata
- Download URL: cbaxter1988_utils-0.9.4.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13a926b83877e661035dcf64c692c75a6508770cb9518132d6429ca926a46043 |
|
MD5 | 0d95588bf5da0b9197510ef80398abf1 |
|
BLAKE2b-256 | 5b492a3623f04520eace5ea0e16d308c9c4f9843da225cf0ddd5039b06597f5a |
File details
Details for the file cbaxter1988_utils-0.9.4-py3-none-any.whl
.
File metadata
- Download URL: cbaxter1988_utils-0.9.4-py3-none-any.whl
- Upload date:
- Size: 29.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edf0beefd217b7ca80f3f8f982b081b6eff15b944d30393247523bc4ceb4e105 |
|
MD5 | 713c6d3258c1edaeea50e4d544ddd39d |
|
BLAKE2b-256 | 2ba164e2359a9f9438b45130a0fb8d161b3fe16bf519484b429af03494ad1725 |