Helpers
various helpers from nic gist
full docs here https://thanakijwanavit.github.io/nicHelper/
from nicHelper.wrappers import add_method
Install
pip install nicHelper
How to use
method module
add method to a class
class A:
pass
@add_method(A)
def printHello(self):
print('hello')
A().printHello()
hello
This is equivalent to
class A:
def printHello(self):
print('hello')
Dict utilities
Pretty print a dict
print only the first 10 characters of dict key, works with deep nested dict
from nicHelper.dictUtil import printDict
printDict({'key':'sjfhdkljhafsdlkjhdfaslkjhkljfadshklhfa', 'nestedKey':{'nestedKey2':'938023840843', 'nested3':{'nested4':'hello'}}})
key : sjfhdkljha
nestedKey
nestedKey2 : 9380238408
nested3
nested4 : hello
change all nested datetime object into timestamp for json compatibility
from nicHelper.dictUtil import filterDt
from datetime import datetime
filterDt({'time': {'time2':datetime.now()}, 'hello': 'world'})
{'time': {'time2': 1606887911.36901}, 'hello': 'world'}
Exception module
from nicHelper.exception import errorString
try:
error
except:
print(f'error is \n{errorString()}')
Image utils
from nicHelper.images import imageFromUrl, imageToS3, showImgS3, resizeImage
from s3bz.s3bz import S3
## test variables
key = 'testCat.png'
path = '/tmp/testCat.png'
bucket = 'villa-remove-bg-small-output'
url = 'https://sites.google.com/site/funnycatmeawww/_/rsrc/1422326075261/home/6997052-funny-cat.jpg?height=675&width=1200'
Resize images
resizeImage(url, 400)
load image from url
img = imageFromUrl(url)
type(img)
save Image to S3
imageToS3(img, bucket, key)
S3.exist(key,bucket)
display image from s3
## full test
showImgS3(bucket, key)
Secrets
from nicHelper.secrets import getSecret
secret = getSecret(name="removeBg", region='ap-southeast-1')
Shorten link with tenxor.sh
from nicHelper.shortenLink import shorten
shorten('https://www.youtube.com/watch?v=fp85zRg2cwg')
Metadata
Release files for nicHelper 0.0.35
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nicHelper-0.0.35.tar.gz | 16.5 kB | Without provenance | Details for nicHelper-0.0.35.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nicHelper-0.0.35-py3-none-any.whl | Python 3 | none | any | Details for nicHelper-0.0.35-py3-none-any.whl |
Total release size: 34.3 kB
Release files / nicHelper-0.0.35.tar.gz
| Download URL | nicHelper-0.0.35.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e59e3ce522119b9020aabf862c1b814f8c1432d66e74a3103710404afc27523
|
|
BLAKE2b-256 checksum How to use checksums |
85f1dbb31c22f60e6f95e370312dc842fd74986ffbfb9c07900c5329411dba7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
|
Release files / nicHelper-0.0.35-py3-none-any.whl
| Download URL | nicHelper-0.0.35-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d6cf4da9e5e1f7b4f6841f88f50a8e5ef03ce2663ca45ab453457398c1469e5
|
|
BLAKE2b-256 checksum How to use checksums |
831b4e8d20e7b24e4a7f306cb32098be9155d3a94177fd5e9679cdb880effee9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
|
Security for nicHelper 0.0.35
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.