Skip to main content

A utilities module made for personal use, has small snippets which I use in many projects.

Project description

pypers



PyPI CI (pip) PyPI - Wheel Supported Python Versions Downloads

Package with helper scripts.

Contains some helper function which make up its name: python+helpers = pypers.

Usage:

pypers.mongo_helpers:

from pypers.mongo_helpers import AsyncMongoDB

db = AsyncMongoDB('localhost:27017', 'pypers')
db.collection = "test"

await db.insert_one({'name': 'pypers'})
results = await db.find_one({'name': 'pypers'})
print(results)
await db.delete_one({'name': 'pypers'})

pypers.namespace:

from pypers.namespace import Namespace

ns = Namespace(
    a=1,
    b=2,
    c=Namespace(
        d=3,
        e=4,
    ),
)

print(ns.a)
print(ns.b)
print(ns.c.d)
print(ns.c.e)

pypers.url_helpers:

from pypers.url_helpers import UrlHelpers
from pypers.url_helpers import AioHttp

new_url = await UrlHelpers.shorten_url('https://www.google.com')
print(new_url)

json, resp = AioHttp.get_json('https://www.google.com')
print(json, resp)

text, resp = AioHttp.get_text('https://www.google.com')
print(text, resp)

raw, resp = AioHttp.get_raw('https://www.google.com')
print(raw, resp)

json, resp = AioHttp.post_json('https://www.google.com')
print(json, resp)

pypers.image_tools:

from pypers.image_tools import ImageTools

new_img = ImageTools.compress_image('/path/to/image.jpg', quality=50)
print(new_img)

pypers.formatters:

from pypers.formatters import Formatters

humanbytes_size = Formatters.humanbytes(1024*1024)
print(humanbytes_size)

human_time = Formatters.time_formatter(15000)
print(human_time)

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

pypers-1.1.0.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

pypers-1.1.0-py3-none-any.whl (7.7 kB view hashes)

Uploaded Python 3

Supported by

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