{"id":15442894,"url":"https://github.com/tybruno/caseless-dictionary","last_synced_at":"2025-04-19T20:13:33.667Z","repository":{"id":65849732,"uuid":"592404654","full_name":"tybruno/caseless-dictionary","owner":"tybruno","description":" simple, fast, typed, and tested implementation for a python3.6+ case-insensitive  and attribute case-insensitive dictionary.","archived":false,"fork":false,"pushed_at":"2024-06-20T21:20:01.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-18T13:16:43.236Z","etag":null,"topics":["attribute-dictionary","case-insensitive-dict","caseless-attribute-dictionary","caseless-dict","dictionary","modifiable-dict","python-dictionary","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/caseless-dictionary/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tybruno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-23T16:58:44.000Z","updated_at":"2024-06-20T21:18:12.000Z","dependencies_parsed_at":"2025-03-03T00:32:18.507Z","dependency_job_id":"2fbab0cb-e542-4f9c-934f-df1e51faa47e","html_url":"https://github.com/tybruno/caseless-dictionary","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fcaseless-dictionary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fcaseless-dictionary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fcaseless-dictionary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fcaseless-dictionary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tybruno","download_url":"https://codeload.github.com/tybruno/caseless-dictionary/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249788923,"owners_count":21325774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attribute-dictionary","case-insensitive-dict","caseless-attribute-dictionary","caseless-dict","dictionary","modifiable-dict","python-dictionary","python3"],"created_at":"2024-10-01T19:31:17.486Z","updated_at":"2025-04-19T20:13:33.648Z","avatar_url":"https://github.com/tybruno.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)\n[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-0000ff.svg)](https://github.com/psf/blue)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blueviolet.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/tybruno/caseless-dictionary/branch/main/graph/badge.svg?token=ZO94EJFI3G)](https://codecov.io/gh/tybruno/caseless-dictionary)\n[![Pylint](https://img.shields.io/badge/Pylint-10.0%2F10-green)](10.0/10)\n[![Mypy](https://img.shields.io/badge/Mypy-checked-blue)](10.0/10)\n\n# caseless-dictionary\n\nA simple, fast, typed, and tested implementation for a python3.6+ case-insensitive and attribute case-insensitive \ndictionaries. This class extends and maintains the original functionality of the builtin `dict` while providing extra \nfeatures.\n\n#### Key Features:\n\n* **Easy**: If you don't care about the case of the key in a dictionary then this implementation is easy to use since it\n  acts just like a `dict` obj. \n* **Attribute Access**: `CaselessAttrDict` allows attribute-style access to dictionary items, providing an alternative, \n  often more readable way to access dictionary items.\n* **Great Developer Experience**: Being fully typed makes it great for editor support.\n* **Fully Tested**: Our test suit fully tests the functionality to ensure that `CaselessDict` runs as expected.\n* **There is More!!!**:\n    * [ModifiableItemsDict](https://github.com/tybruno/modifiable-items-dictionary): CaselessDict is built on top of\n      the `ModifiableItemsDict`, which is a library that enables the user to modify the key or/and value of `dict` type\n      object at runtime.\n\n## Installation\n\n`pip install caseless-dictionary`\n\n## Caseless Dictionaries\n\n| Class Name           | Description                                                    | Example                                                                      |\n|----------------------|----------------------------------------------------------------|------------------------------------------------------------------------------|\n| CaselessDict         | A dictionary where keys that are strings are case-folded.      | `CaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'hello world': 1}`         |\n| CaseFoldCaselessDict | A dictionary where keys that are strings are case-folded.      | `CaseFoldCaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'hello world': 1}` |\n| LowerCaselessDict    | A dictionary where keys that are strings are in lower case.    | `LowerCaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'hello world': 1}`    |\n| UpperCaselessDict    | A dictionary where keys that are strings are in upper case.    | `UpperCaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'HELLO WORLD': 1}`    |\n| TitleCaselessDict    | A dictionary where keys that are strings are in title case.    | `TitleCaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'Hello World': 1}`    |\n| SnakeCaselessDict    | A dictionary where keys that are strings are in snake case.    | `SnakeCaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'hello_world': 1}`    |\n| KebabCaselessDict    | A dictionary where keys that are strings are in kebab case.    | `KebabCaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'hello-world': 1}`    |\n| ConstantCaselessDict | A dictionary where keys that are strings are in constant case. | `ConstantCaselessDict({\"  HeLLO WoRLD  \": 1})  # Output: {'HELLO_WORLD': 1}` |\n## Caseless Attribute Dictionaries\n\n| Class Name               | Description                                                                                                 | Example                                                                     |\n|--------------------------|-------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|\n| SnakeCaselessAttrDict    | A dictionary where keys that are strings are in snake case and can be accessed using attribute notation.    | `SnakeCaselessAttrDict({\"  HeLLO WoRLD  \": 1}).hello_world  # Output: 1`    |\n| ConstantCaselessAttrDict | A dictionary where keys that are strings are in constant case and can be accessed using attribute notation. | `ConstantCaselessAttrDict({\"  HeLLO WoRLD  \": 1}).HELLO_WORLD  # Output: 1` |\n\n### Basic CaselessDict Example\n\n```python\nfrom caseless_dictionary import CaselessDict\n\n# Create a CaselessDict\ncaseless_dict = CaselessDict({\"  HeLLO WoRLD  \": 1, 2: \"two\"})\n\nprint(caseless_dict)  # Output: {'hello world': 1, 2: 'two'}\n\n# Accessing the value using different cases\nprint(caseless_dict[\"  hello world  \"])  # Output: 1\nprint(caseless_dict[\"  HELLO WORLD  \"])  # Output: 1\n\n# Accessing non string value\nprint(caseless_dict[2])  # Output: two\n```\n\n### Caseless Dictionary with Key as Str Only\n\n```python\nfrom caseless_dictionary import CaselessDict\n\n# Create a CaselessDict with key_is_str_only set to True\nCaselessDict.key_is_str_only = True\ncaseless_dict = CaselessDict({\"  HeLLO WoRLD  \": 1})\n\n# Attempt to set a non-string key\ntry:\n    caseless_dict[1] = 2\nexcept TypeError:\n    print(\"TypeError raised as expected when key_is_str_only is True\")\n```\n\n\n### Basic SnakeCaselessAttrDict Example\n\n```python\nfrom caseless_dictionary import SnakeCaselessAttrDict\n\n# Create a SnakeCaselessAttrDict\nsnake_caseless_attr_dict = SnakeCaselessAttrDict({\"  HeLLO WoRLD  \": 1, 2: \"two\"})\nprint(snake_caseless_attr_dict)  # Output: {'hello_world': 1, 2: 'two'}\n\n# Accessing the value using attribute notation\nprint(snake_caseless_attr_dict.hello_world)  # Output: 1\nprint(snake_caseless_attr_dict.HELLO_WORLD)  # Output: 1\n\n# Accessing the value using Keys\nprint(snake_caseless_attr_dict[\"  hello_world  \"])  # Output: 1\nprint(snake_caseless_attr_dict[\"  HELLO WORLD  \"])  # Output: 1\n\n# Accessing non string value\nprint(snake_caseless_attr_dict[2])  # Output: two\n\n```\n\n### SnakeCaselessAttrDict with Key as Str Only\n\n```python\nfrom caseless_dictionary import SnakeCaselessAttrDict\n\n# Create a SnakeCaselessAttrDict with key_is_str_only set to True\nSnakeCaselessAttrDict.key_is_str_only = True\nsnake_caseless_attr_dict = SnakeCaselessAttrDict({\"  HeLLO WoRLD  \": 1})\n\n# Attempt to set a non-string key\ntry:\n    snake_caseless_attr_dict[1] = 2\nexcept TypeError:\n    print(\"TypeError raised as expected when key_is_str_only is True\")\n```\n\n## Acknowledgments\n\nDuring the class '(Advanced) Python For Engineers III' taught by [Raymond Hettinger](https://github.com/rhettinger),\nRaymond taught us how to inherit from the builtin Python `dict` by creating a Case-insensitive Dict.\nI thought this was a wonderful learning experience so I decided to create a project that would build upon what he\ntaught.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftybruno%2Fcaseless-dictionary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftybruno%2Fcaseless-dictionary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftybruno%2Fcaseless-dictionary/lists"}