Commit 2fd2f1c
committed
2.5.0 - Converters, construct_dict, get_function_params
**New Features / Additions**
- `privex.helpers.common`
- Added `get_function_params` - which extracts and filters a function/method or class constructor's parameters, and
outputs them in a dictionary
- Added `construct_dict`, which allows you to either construct a class, or call a function using a dictionary of keyword arguments,
using `get_function_params` to detect what arguments the class/function/method can take, including any parent classes, then
filtering out any keyword arguments which would otherwise be rejected and cause a TypeError.
- Added `_filter_params`, a private function used by the aforementioned functions to filter a dictionary or iterable of Parameter objects.
- New module `converters`, containing functions/classes designed to convert/parse one type into another
- `convert_datetime` converts both string date/time's as well as unix timestamps into `datetime.datetime` objects using `dateutil.parser`
- `convert_unixtime_datetime` converts specifically UNIX epoch timestamps (can be string, int, float, Decimal etc.) into `datetime.datetime` objects,
and is used by `convert_datetime` to handle unix timestamps.
- `convert_bool_int` converts booleans `True` / `False` as well as string / int versions into integers 1 (true) and 0 (false)
- `convert_int_bool` is mostly an alias to `is_true`, but exists for convenience and semantics (if there's a convert_bool_int, why not a convert_int_bool?)
**Changes / Updates**
- Shrank the rather large copyright notice in most modules down to the small copyright block, and instead of dumping the whole X11 / MIT License text in there,
the licence block simply states `License: X11 / MIT`. This should make the docs a bit more readable.
- Added `python-dateutil` to the `Pipfile`
- For sanity reasons, `python-dateutil` has been added to the `install_requires` (meaning it's auto-installed when you install privex-helpers). The package is relatively
small and depends on just `six`, weighing in around 500kb (python-dateutil = 468kb, six = 36kb).
It may be removed and refactored into a setup.py extra at a later point, but for now it's small and commonly required enough that it can be a dependency.
- Added `dateutil` to the sphinx intersphinx mapping
- Possibly other small changes I forgot to include
**Testing**
- Added new test case `TestInspectFunctions` to test_general, which tests the new `get_function_params` and `construct_dict` functions.
- Added new test module `test_converters.py` which contains test cases for the new converters module
- `TestConvertDate` covers date/time related converters such as `convert_datetime` and `convert_unixtime_datetime`
- `TestConvertGeneral` covers other converters that don't fit into a specific category (or would otherwise be pointless to categorize)1 parent d254b8c commit 2fd2f1c
97 files changed
Lines changed: 1593 additions & 227 deletions
File tree
- docs/source
- helpers
- common
- t_param
- converters
- tests
- test_converters
- testconvertdate
- testconvertgeneral
- test_general
- baseone
- basetwo
- inheritexample
- simpleexample
- testinspectfunctions
- privex/helpers
- cache
- crypto
- extras
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
194 | 195 | | |
195 | 196 | | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments