Helpers
various helpers from nic gist
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
Dict utilities
from nicHelper.dictUtil import printDict
printDict({'key':'sjfhdkljhafsdlkjhdfaslkjhkljfadshklhfa', 'nestedKey':{'nestedKey2':'938023840843', 'nested3':{'nested4':'hello'}}})
key : sjfhdkljha
nestedKey
nestedKey2 : 9380238408
nested3
nested4 : hello
Exception module
from nicHelper.exception import errorString
try:
error
except:
print(f'error is \n{errorString()}')
error is
Traceback (most recent call last):
File "<ipython-input-5-86083feec525>", line 3, in <module>
error
NameError: name 'error' is not defined
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)
PIL.JpegImagePlugin.JpegImageFile
save Image to S3
imageToS3(img, bucket, key)
S3.exist(key,bucket)
saving image to villa-remove-bg-small-output/testCat.png
True
display image from s3
## full test
showImgS3(bucket, key)
Secrets
from nicHelper.secrets import getSecret
secret = getSecret(name="removeBg", region='ap-southeast-1')
Metadata
Release files for nicHelper 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nicHelper-0.0.7.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nicHelper-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.5 kB
Release files / nicHelper-0.0.7.tar.gz
| Download URL | nicHelper-0.0.7.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
163b3e909f89e40a07a558b01cc73b8187d4d10228a2c8188af5c4bbb7435f40
|
|
BLAKE2b-256 checksum How to use checksums |
bbbecf3e7a7f543f521305aeab0b1da2b1a14f951d932055dc0e8be004b43263
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
|
Release files / nicHelper-0.0.7-py3-none-any.whl
| Download URL | nicHelper-0.0.7-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dcac106b45797a0a5d58455589d972c797884751f10dc91466904bda9007b6e
|
|
BLAKE2b-256 checksum How to use checksums |
6ac1a23bffca29e1a952517809d56840ab46f053687611e08aafab338362e2f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
|