Skip to content

Repository files navigation

MappingTools

Do stuff with Mappings and more

This library provides utility functions for creating, manipulating, and transforming data structures, which have or include Mapping-like characteristics.

Including inverting dictionaries, converting class-like objects to dictionaries, creating nested defaultdicts, and unwrapping complex objects.

PackagePyPI - VersionPyPI - StatusPyPI - Python VersionPyPI - DownloadsPyPI - DependentsLibraries.io SourceRank
CodeGitHubGitHub repo sizeGitHub last commit (by committer)Contributors
ToolsPyCharmuvRuffHatch projectcommitizenZensical
CI/CDTestPublishCodSpeedPublishPublish Docs
ScansCoverageQuality Gate StatusSecurity RatingMaintainability RatingReliability RatingLines of CodeVulnerabilitiesBugsCodacy QualityCodacy CoverageCodeFactorDeepSourceDeepSourceSnykCodSpeed
MentionsPython HubX

🚀 Why use MappingTools?

Built for developers who need more than just standard dictionaries.

ProblemSolution
Boilerplate ReductionUse Dictifier to broadcast method calls to a collection of objects (users.greet() instead of a for loop).
Deep JSON DiffingUse flatten() to collapse nested JSON into single-layer paths for easy comparison.
Data CollisionsUse inverse() to swap keys/values without losing data (automatically creates sets for duplicates).
Slow Config LoadingUse MeteredDict to profile exactly how many times your app reads specific config keys.
Quick SerializationUse simplify() to instantly convert Dataclasses, DateTime, and custom objects into pure Dicts.
Complex GroupingUse reshape() to pivot lists of dicts into N-dimensional nested dictionaries (tensors).
Key RemappingUse rename() or rekey() to transform dictionary keys using functions or maps.
Multi-Dimensional CountingUse CategoryCollector to aggregate data into multiple buckets simultaneously (e.g., by type AND by status).
Safe Deep ModificationUse Lens to immutably update nested values without cloning the entire structure manually.

Documentation

https://erivlis.github.io/mappingtools/

Development

Ruff

ruff check src
ruff check tests

Test

Standard terminal Coverage Report

python -m pytest tests --cov=src --cov-branch --doctest-modules --cov-report=term-missing

Standard (cobertura) XML Coverage Report

python -m pytest tests --cov=src --cov-branch --doctest-modules --cov-report=xml

HTML Coverage Report

python -m pytest tests --cov=src --cov-branch --doctest-modules --cov-report=html

About

Python tools to manipulate Mapping objects

Topics

Resources

Contributing

Stars

8 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages