youconfigme package¶
Module contents¶
Entrypoint to make relevant classes available at the top level.
-
class
youconfigme.AutoConfig(max_up_levels=1, filename='settings.ini', sep='_')¶ Bases:
youconfigme.youconfigme.ConfigSafe Config item.
Searches for an ini file upwards. If there’s no ini file, it returns an empty Config file that can be used with defaults and/or env vars.
Create a new AutoConfig item.
- Parameters:
max_up_levels (int) – how many parents should it traverse searching for an ini file
filename (str) – filename to search for
-
class
youconfigme.Config(from_items='settings.ini', default_section='settings', sep='_')¶ Bases:
objectBase Config item.
Create a new Config item.
- Parameters:
from_items (mapping or str or filename) – where the config should be populated from: - filename: path for an ini file - mapping: mapping of sections -> mapping of name -> value - str: string representation of an ini file
default_section (str) – config items that need not be under a section
sep (str) – string to separate sections from items in env vars.
-
to_dict()¶ Return as dict.
- Parameters:
None –
- Returns:
dict – all the key:value pairs from the initial mapping, neglecting environment variables not present there.
-
exception
youconfigme.ConfigItemNotFound¶ Bases:
ExceptionThe config item could not be found.
-
class
youconfigme.ConfigSection(name, items, sep='_')¶ Bases:
objectA section from a Config item.
Create a new ConfigSection.
- Parameters:
name (str) – name of the section
items (mapping) – mapping of attributes names to values
sep (str) – string to separate sections from items in env vars.
-
to_dict()¶ Return as dict.
- Parameters:
None –
- Returns:
dict – all the key:value pairs from the initial mapping, neglecting environment variables not present there.