deep-filter
A simple package that filters out values from dicts/lists, including all dicts/lists nested within it.
Usage
from deep_filter import deep_filter
x = {
'nope': 69,
'yep': [
69,
{'maybe': None},
99
]
}
def filter_func:
return value != 69
result = deep_filter(x, filter_func)
print(result)
# {'yep': [{}, 99]}
deep_filter(dict_or_list, filter_func=default_filter_func)
- dict_or_list: A dictionary or list
- filter_func: An optional callback function. It will take a value as an argument, and return
Trueif the value will be kept andFalseif not. If omitted,Nonevalues will be filtered out.
Returns your dict or list, filtered.
Dev instructions
Get started
- Install Python (Python 3.7 works, probably other versions too)
- Install Poetry. Poetry is used to manage dependencies, the virtual environment and publishing to PyPI
- Run
poetry installto install Python package dependencies
I recommend running poetry config virtualenvs.in-project true, which makes Poetry store your Python virtual environment inside the project folder. Additionally, it lets VSCode's Python extension detect the virtual environment if you set the python.pythonPath setting to ${workspaceFolder}/.venv/bin/python in your settings.
Running
To test if things work, you can run the following command to open the Python REPL. Then you can write Python, such as the usage examples:
poetry run python
Releasing a new version
- Consider updating the lockfile by running
poetry update, then check if thing still work - Bump the version number:
poetry version <version> - Update
CHANGELOG.md - Build:
poetry build - Commit and create git tag
- Create GitHub release with release notes and attach the build files
- Publish to PyPi:
poetry publish
Metadata
Release files for deep-filter 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deep-filter-1.0.1.tar.gz | 2.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deep_filter-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.6 kB
Release files / deep-filter-1.0.1.tar.gz
| Download URL | deep-filter-1.0.1.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecafc5fdd6f2f049aef5a76758e0d51ea500afd4f890420c7083a0cf5e40b6c4
|
|
BLAKE2b-256 checksum How to use checksums |
a71268654bb6e2fb2f4cb1ff8cbc56e7ef748326f59a9f331e99fbfbc388f660
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.5 Darwin/18.7.0
|
Release files / deep_filter-1.0.1-py3-none-any.whl
| Download URL | deep_filter-1.0.1-py3-none-any.whl |
|---|---|
| Size | 2.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c063c22f6d03353e3f26d2f281dae7eaa3333d7242df3c05e29f94c689311896
|
|
BLAKE2b-256 checksum How to use checksums |
21aecdd5dbaae2ee6d12ddb5965e7f8e8e95edcf4becd92b550e2a2a17c1e6f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.5 Darwin/18.7.0
|