Tags: bt-cryptomancer/python-helpers
Tags
v1.3.0 - Added `async_sync`, `run_sync` + More **asyncx.py** - Added `async_sync` decorator for easily running async functions/methods from non-async functions/methods. Useful for unit tests. - Added `run_sync` function, mainly intended for running async functions from the REPL with ease **common.py** - Added `dec_round` for rounding `Decimal` objects to arbitrary DP - Added `env_cast`, `env_int`, and `env_decimal` - Added `chunked` function for slicing a list into multiple equal sized lists - Added `Dictable` abstract class - eases creating Python 3.7 `dataclass` objects from `dict`'s as well as converting them back into `dict`'s **tests.py** - Added new `TestGeneral` test case, for unit testing some of the new functions **Documentation** - Added docs for `asyncx` module - Updated `common` module to include new functions/classes - Fixed docs for `tests` - Various cleanup to reduce warnings from Sphinx
v1.2.0 - Added r_cache decorator, plus settings/plugin module - Added `r_cache` decorator, for easily caching the output of any function/method in Redis - Created `plugins.py` module - for initialising and storing third party connection classes e.g. Redis - Created `settings.py` module - for dynamically setting certain global configuration options e.g. redis connection details - Added `redis` requirement to `docs/requirements.txt` and `README.md` (optional requirement) - Created new Test Case for `r_cache` called `TestRedisCache` - tests that caching works, as well as the dynamic cache key feature.
v1.1.4 - Added `env_bool` function, csv/kval functions now allow sepa…
…rator to be overriden.
**New functions / code improvements**
- Added `env_bool` function to `common.py` for loading an environment var as a boolean
- Added `csvsplit` parameter to parse/env_csv and keyval, to allow changing the item separator from `,`
- Added `valsplit` parameter to parse/env_keyval, to allow customising the separator between key's and value's from `:`
**Documentation**
- Added PyDoc param's / return's for various functions, and fleshed out some others
- Wrapped various docstring values such as ``True`` and ``0`` with backticks so they display better
- Various small formatting improvements to existing docstrings
- Added `PrivexBaseCase` and `env_bool` to the docs
**Unit Testing**
- Refactored various attributes in `test.py` into the base class `PrivexBaseClass`
- Added example to the PyDoc in `tests.py` showing how to run tests with `pytest`
- Wrote new unit tests:
- `test_kval_custom_clean` - Validates that `parse_keyval` works properly with custom `valsplit`/`csvsplit`
- `test_kval_custom_spaced` - Validates that `parse_keyval` works properly with space padded values and custom `valsplit`/`csvsplit`
- `test_env_nonexist_bool`, `test_env_bool_true`, `test_env_bool_false` - Validate that the new `env_bool` function returns the correct values.
PreviousNext