Skip to main content

No project description provided

Project description

fastomit

PyPI - Version PyPI - Python Version


Fast k-v omission

Table of Contents

Installation

pip install fastomit

Usage

Trust Omitter

from fastomit.omit import Omitter, always_omit, globally_hidden, hide, reset_omissions

# always omit keys abc and pw
om = Omitter(["abc", "pw"])
my_dict = {"abc": "val", "pw": "val2", "ok": True, "val": "v2"}
assert om.omit(my_dict) == {"abc": "***", "pw": "****", "ok": True, "val": "v2"}

# always omit keys abc and def
always_omit(["abc", "def"])
om = Omitter()
my_dict = {"abc": "v1", "def": "value", "deg": "nohide"}
assert om.omit(my_dict) == {"abc": "**", "def": "*****", "deg": "nohide"}

# no global omissions
reset_omissions()

om = Omitter()

assert om.omit(my_dict) == my_dict

No-Trust Omitter

from fastomit.omit import NoTrustOmitter, always_trust, globally_trusted, reset_trusted

# omits anything but these keys
om = NoTrustOmitter(["abc", "pw"])

my_dict = {"abc": "val", "pw": "val2", "ok": True, "val": "v2"}
assert om.omit(my_dict) == {"abc": "val", "pw": "val2", "val": "**"}

# trust keys abc and def
always_trust(["abc", "def"])
om = NoTrustOmitter([])
my_dict = {"abc": "v1", "def": "value", "deg": "hide"}
assert om.omit(my_dict) == {"abc": "v1", "def": "value", "deg": "****"}

# trust nothing
reset_trusted()

om = NoTrustOmitter()

assert om.omit(my_dict) == {"abc": "**", "def": "*****", "deg": "****"}
assert globally_trusted() == []

License

fastomit is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastomit-0.1.1.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distributions

fastomit-0.1.1-cp311-cp311-win_amd64.whl (259.6 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

fastomit-0.1.1-cp311-cp311-win32.whl (251.1 kB view hashes)

Uploaded CPython 3.11 Windows x86

fastomit-0.1.1-cp311-cp311-manylinux_2_35_x86_64.whl (819.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.35+ x86-64

fastomit-0.1.1-cp311-cp311-macosx_10_16_x86_64.whl (438.8 kB view hashes)

Uploaded CPython 3.11 macOS 10.16+ x86-64

fastomit-0.1.1-cp310-cp310-win_amd64.whl (259.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

fastomit-0.1.1-cp310-cp310-win32.whl (251.2 kB view hashes)

Uploaded CPython 3.10 Windows x86

fastomit-0.1.1-cp310-cp310-manylinux_2_35_x86_64.whl (782.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.35+ x86-64

fastomit-0.1.1-cp310-cp310-macosx_10_16_x86_64.whl (436.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.16+ x86-64

fastomit-0.1.1-cp39-cp39-win_amd64.whl (260.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

fastomit-0.1.1-cp39-cp39-win32.whl (251.7 kB view hashes)

Uploaded CPython 3.9 Windows x86

fastomit-0.1.1-cp39-cp39-manylinux_2_35_x86_64.whl (788.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.35+ x86-64

fastomit-0.1.1-cp39-cp39-macosx_10_16_x86_64.whl (315.8 kB view hashes)

Uploaded CPython 3.9 macOS 10.16+ x86-64

fastomit-0.1.1-cp38-cp38-win_amd64.whl (260.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

fastomit-0.1.1-cp38-cp38-win32.whl (251.8 kB view hashes)

Uploaded CPython 3.8 Windows x86

fastomit-0.1.1-cp38-cp38-manylinux_2_35_x86_64.whl (794.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.35+ x86-64

fastomit-0.1.1-cp38-cp38-macosx_10_16_x86_64.whl (316.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.16+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page