Bravo! You have received a Mercantilism Diploma in "law_dictionary" from
the Orbital Convergence University International Air and Water
Embassy of the Tangerine Planet 🍊 (the planet that is one ellipse further from
the Sun than Earth's ellipse).
You are now officially certified to include "law_dictionary" in your practice!
Encore! Encore! Encore! Encore!
law_dictionary
description
This module checks that dictionaries provided are legit.
install
[xonsh] pip install law_dictionary
tutorial
The "dictionary" passed to the "check" function might be modified.
Therefore dictionary_2 = copy.deepcopy (dictionary_1) should be used
if you'd like the original dictionary_1 to be preserved.
101
In this example, an obstacle is found because "directory_2" is not in the "laws"
and "allow_extra_fields" is False.
With "return_obstacle_if_not_legit" a report is returned instead of an exception
being raised.
import law_dictionary
dictionary = {
"directory_1": "/",
"directory_2": "/drives"
}
report = law_dictionary.check (
return_obstacle_if_not_legit = True,
allow_extra_fields = False,
laws = {
"directory_1": {
"required": True
}
},
dictionary = dictionary
)
if (report ["advance"] != True):
raise Exception (report ["obstacle"])
contigencies
If "required" is False, then the "contingency" value is returned or the value returned by a "contingency" function.
After "contingency" step, the "type" is checked, if "type" is passed to the "laws".
import law_dictionary
dictionary = {}
def retrieve_directory ():
return "/"
report = law_dictionary.check (
return_obstacle_if_not_legit = True,
laws = {
"directory_1": {
"required": False,
"contingency": retrieve_directory,
"type": str
},
"directory_2": {
"required": False,
"contingency": "/drives",
"type": str
}
},
dictionary = dictionary
)
if (report ["advance"] != True):
raise Exception (report ["obstacle"])
assert (dictionary ["directory_1"] == "/")
assert (dictionary ["directory_2"] == "/drives")
# The consequence of this check is that there are no "obstacles"
# and the dictionary is modified to have this structure:
'''
{
"directory_1": "/",
"directory_2": "/drives"
}
'''
allowance
The consequence of this check is that there are no "obstacles" or modifications to either dictionary.
import law_dictionary
dictionaries = [{ "directory_1": "/" }, { "directory_1": "/drives" }]
for dictionary in dictionaries:
law_dictionary.check (
laws = {
"directory_1": {
"required": True,
"allow": [ "/", "/drives" ]
}
},
dictionary = dictionary
)
multiple levels
There's not a tree structure possible for multiple levels,
however after a level 1 check, level 2, etc. checks can
be run.
import law_dictionary
dictionary = {
"paths": {
"directory_1": "/"
}
}
law_dictionary.check (
laws = {
"paths": {
"required": True,
"type": dict
}
},
dictionary = dictionary
)
law_dictionary.check (
laws = {
"directory_1": {
"required": True,
"type": str
}
},
dictionary = dictionary ["paths"]
)
Metadata
Release files for law_dictionary 1.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| law_dictionary-1.0.12.tar.gz | 25.6 kB | Without provenance | Details for law_dictionary-1.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| law_dictionary-1.0.12-py3-none-any.whl | Python 3 | none | any | Details for law_dictionary-1.0.12-py3-none-any.whl |
Total release size: 53.6 kB
Release files / law_dictionary-1.0.12.tar.gz
| Download URL | law_dictionary-1.0.12.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7018d3483dc818c8c0a40852cbecc17a8c43d3481f0b540fb394bc3990763b1f
|
|
BLAKE2b-256 checksum How to use checksums |
cbca345b5b09ad2a9e915612f665388b1af2ee5c2b98bed95f5d9826dc328422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-27-generic
|
Release files / law_dictionary-1.0.12-py3-none-any.whl
| Download URL | law_dictionary-1.0.12-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d58557e3196ae3151177bea9f5a3a4b707edca4905964eb80f211d00e0a078a
|
|
BLAKE2b-256 checksum How to use checksums |
5593a3f471fe5cb8a96ec3dacc4ffc91483f73b55f9962b778bcf6bc04880145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-27-generic
|
Security for law_dictionary 1.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.