Additional useful mappings
Project description
Description
- Provides
AttributeDict (keys accessible as dot-denoted attributes, remains subscriptable)
GroupDict (groups keys based on prefix, makes it easy to write complex configuration in a single dictionary and access it easily)
SuperDict (a dictionary that is defaultdict, OrderedDict, case-insensitive, and recursive,, each customizable by user)
Examples of AttributeDict:
from mapping_kit import AttributeDict
# All the standard ways that a Python dict can be created in, can be used to
# create AttributeDict. It can also be used as a normal dictionary.
my_dict = {
"first_name": "Charlie",
"last_name": "Brown",
}
from_dict = AttributeDict(**my_dict)
print("Hello", from_dict.first_name, from_dict["last_name"])
# Hello Charlie Brown
my_tuples = [("model", "Hindustan Ambassador"),
("production", "1957-2014")]
from_tuples = AttributeDict(my_tuples)
print(from_tuples.model, "was produced in the years", from_tuples["production"])
# Hindustan Ambassador was produced in the years 1957-2014
Examples of GroupDict:
from mapping_kit import GroupDict
my_dict = {
"#Version": "1.4.9a1",
"beverages": {
"_lassi": "A yoghurt based beverage",
"_aamras": "Thick mango pulp",
"*jaljeera": "Spices mixed in water, out of stock",
"*alcoholic_drinks": {
"beer": "4-6% alcohol",
"red_wine": "5.5-10% alcohol"
},
},
"appetizers": {
"_pani_puri": "Masala water filled crispy puffed bread",
"!chicken_pakora": "Deep-fried chicken stuffing in Indian pakoras",
"_aloo_chaat": "Potato with spicy gravy",
"!prawn_toast": "Sesame and prawns rolled in bread"
}
}
gd = GroupDict(my_dict,
grouping={"#": "comment", # arbitrary group names
"_": "vegetarian",
"!": "non_vegetarian",
"*": "not_available"},
recursive=True,
ignorecase_get=True)
# Accessing group `comment`
print("The version is", gd.comment["version"])
# The version is 1.4.9a1
for key, value in gd.comment.items():
print("key:", key, ", value:", value)
# key: Version , value: 1.4.9a1
# Chained groups
veg_appetizers = gd.public["appetizers"].vegetarian
print("Vegetarian appetizers are:")
for key in veg_appetizers.keys():
print(f" {key}")
# Vegetarian appetizers are:
# pani_puri
# aloo_chaat
beverages_not_available = gd["beverages"].not_available
print("Beverages not available are:")
for bna, bna_desc in beverages_not_available.items():
if isinstance(bna_desc, dict):
for bna_sub, bna_sub_desc in bna_desc.public.items():
print(f" {bna_sub} ({bna_sub_desc})")
else:
print(f" {bna} ({bna_desc})")
# Beverages not available are:
# jaljeera (Spices mixed in water, out of stock)
# beer (4-6% alcohol)
# red_wine (5.5-10% alcohol)
Examples of SuperDict:
from mapping_kit import SuperDict
# TODO
Note: This is an alpha version, and things may change quite a bit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mapping_kit-0.1.0a3.tar.gz.
File metadata
- Download URL: mapping_kit-0.1.0a3.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.3 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21fc5051b33b50c4e76816ea066603d854f55d3c6e622942b0d477968f97c380
|
|
| MD5 |
a943b1a1f1ebb5ac10d06f21ac2b6920
|
|
| BLAKE2b-256 |
66d9105f821183d027167b7c59432c378a751a92976daded53345999eea16ed0
|
File details
Details for the file mapping_kit-0.1.0a3-py3-none-any.whl.
File metadata
- Download URL: mapping_kit-0.1.0a3-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.3 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8701e9ca760bdb872285cb7918385c9c5e8696d0b4b8d44a9ebbeddd9c078a9a
|
|
| MD5 |
a8a5e3a97a4d0dd9cecc9f86e3d87779
|
|
| BLAKE2b-256 |
f00185d3faea84912e0219f8e201feda831d84edb5478e3a9a2e5c2c5923b7a6
|