jbasko / configmanager

Forget about configparser, YAML, or JSON parsers. Focus on configuration. NOT RECOMMENDED FOR USE (2019-01-26)
MIT License
17 stars 5 forks source link

Allow passing Item class to Config on creation #68

Closed jbasko closed 7 years ago

jbasko commented 7 years ago
class CustomItem(Item):
    pass

config = Config({'x': 23}, item_cls=CustomItem)
assert config.cm__item_cls is CustomItem
assert isinstance(config.x, CustomItem)

This doesn't guarantee that all items will be of that class. If items have been created before, we shouldn't touch them of course (apart from the usual name assigning).

jbasko commented 7 years ago

parse_config_declaration is no longer cool because generating a OrderedDict is very different from generating a Config. Should probably move it to Config itself and no longer support custom tree_cls.