
| Current Path : /usr/local/lib/python3.8/dist-packages/SPARQLWrapper/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //usr/local/lib/python3.8/dist-packages/SPARQLWrapper/KeyCaseInsensitiveDict.py |
# -*- coding: utf-8 -*-
"""
A simple implementation of a key case-insensitive dictionary.
..
Developers involved:
* Ivan Herman <http://www.ivan-herman.net>
* Sergio Fernández <http://www.wikier.org>
* Carlos Tejo Alonso <http://www.dayures.net>
* Alexey Zakhlestin <https://indeyets.ru/>
Organizations involved:
* `World Wide Web Consortium <http://www.w3.org>`_
* `Foundation CTIC <http://www.fundacionctic.org/>`_
:license: `W3C® Software notice and license <http://www.w3.org/Consortium/Legal/copyright-software>`_
"""
class KeyCaseInsensitiveDict(dict):
"""
A simple implementation of a key case-insensitive dictionary
"""
def __init__(self, d={}):
"""
:param dict d: The source dictionary.
"""
for k, v in list(d.items()):
self[k] = v
def __setitem__(self, key, value):
if hasattr(key, "lower"):
key = key.lower()
dict.__setitem__(self, key, value)
def __getitem__(self, key):
if hasattr(key, "lower"):
key = key.lower()
return dict.__getitem__(self, key)
def __delitem__(self, key):
if hasattr(key, "lower"):
key = key.lower()
dict.__delitem__(self, key)