HomeSoftware Heritage

Make config keys (sections and names) case insensitive

Description

Make config keys (sections and names) case insensitive

This is done to match the behaviour of git itself.

The main change here is to add the lower_key function
and the CaseInsensitiveDict class.

lower_key coerces keys that are used in DictConfig to
make sure all keys consist only of lower-cased strings.

CaseInsensitiveDict has altered getitem and
setitem methods to call lower_key on the key for
both get and set operations.

CaseInsensitiveDict.make takes care of the creation
logic found in ConfigDict.init as well as converting
any passed-in dicts to CaseInsensitiveDict.

CaseInsensitiveDict.get and CaseInsensitiveDict.setdefault
allow the default value returned to be a CaseInsensitiveDict
without repeating it everywhere.

ConfigDict.check_section_and_name just moves some logic
that was previously repeated.

Fixes #599

Details

Provenance
Alistair Broomhead <alistair.broomhead@gmail.com>Authored on Jan 6 2018, 5:50 PM
ardumontPushed on Sep 27 2021, 5:34 PM
Parents
rPPDW134c28a85fa9: Fix spelling of my surname.
Branches
Unknown
Tags
Unknown

Event Timeline