Pre-release
This release is a pre-release and may not be stable for production use.
devpytools
Tools for development.
Installation
$ pip install devpytools
Usage
Cacher
Get and use default inmemory cacher
from devpytools import getCacher
c = getCacher()
@c.cache()
def a(b):
...
Create the cacher that saves a pickled data on disk and can be used between runs
from devpytools import Cacher
c = Cacher(name='dev', tmpDirPath='./tmp')
Get previously configured cacher in other file and use
from devpytools import getCacher
c = getCacher("dev")
@c.cache
def a(b):
...
Example
from devpytools import Cacher
from devpytools.cacher import extensions
IS_DEV = os.getenv("IS_DEV", "") == "true"
devCacher = Cacher(
name="dev",
tmpDirPath="./tmp",
isEnable=IS_DEV, # work only if run in dev environment
isExpired=extensions.expireAfterHours(1), # recache if cached data older than 1 hour
isSavable=lambda result: bool(result), # only cache positive function call results
)
@devCacher.cache
def a(b):
...
# works with the same params as devCacher but saves caches to ./tmp1 folder
@devCacher.cache(tmpDirPath="./tmp1")
def a1(b):
...
# currently disable cache for that func
@devCacher.cache(isEnable=False)
def a2(b):
...
# cache only those calls that return more than 0 elements
@devCacher.cache(isSavable=lambda result: result['count'] > 0)
def a3(b):
...
# use only a and b arguments to determine unique key of the function call
@devCacher.cache(uniqueKey=lambda args: args['a'] + args['b'])
def a4(a: str, b: str, c: str):
...
c = getCacher()
# to determine the uniqueness of a function call use only a and b arguments
@c.cache(uniqueKey=("a", "b"))
def a(a, b, c):
...
Other
- replaceFunc
from devpytools import replaceFunc
IS_DEV = os.getenv("IS_DEV", "") == "true"
def devFunc():
# predefined results for development
...
# replace only if IS_DEV is True
@replaceFunc(devFunc, isEnabled=IS_DEV)
def prodFunc():
# time consuming function
...
Metadata
Release files for devpytools 0.1.0.dev8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| devpytools-0.1.0.dev8.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| devpytools-0.1.0.dev8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / devpytools-0.1.0.dev8.tar.gz
| Download URL | devpytools-0.1.0.dev8.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f5f61d80b8c7b94d0cce8a0f1cdb2ba85a1c45a529ff1bfe64521ec37e9e56f
|
|
BLAKE2b-256 checksum How to use checksums |
20eb87992a7c7c559d4e4315341cce5311509868a709ed91aa868ff4c8ab9a24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / devpytools-0.1.0.dev8-py3-none-any.whl
| Download URL | devpytools-0.1.0.dev8-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c31afd67722def7434c22d403f9731c2a16e22a7661a5d4581dbf4016d431592
|
|
BLAKE2b-256 checksum How to use checksums |
8324b3a598719adbc21e04696c59805bb1572ba8d2785549cc09f4ad0902beaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|