MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / load_config

Method load_config

21-async/mojifinder/bottle.py:2095–2109  ·  view source on GitHub ↗

Load values from an *.ini style config file. If the config file contains sections, their names are used as namespaces for the values within. The two special sections ``DEFAULT`` and ``bottle`` refer to the root namespace (no prefix).

(self, filename)

Source from the content-addressed store, hash-verified

2093 self.update(*a, **ka)
2094
2095 def load_config(self, filename):
2096 ''' Load values from an *.ini style config file.
2097
2098 If the config file contains sections, their names are used as
2099 namespaces for the values within. The two special sections
2100 ``DEFAULT`` and ``bottle`` refer to the root namespace (no prefix).
2101 '''
2102 conf = ConfigParser()
2103 conf.read(filename)
2104 for section in conf.sections():
2105 for key, value in conf.items(section):
2106 if section not in ('DEFAULT', 'bottle'):
2107 key = section + '.' + key
2108 self[key] = value
2109 return self
2110
2111 def load_dict(self, source, namespace='', make_namespaces=False):
2112 ''' Import values from a dictionary structure. Nesting can be used to

Callers

nothing calls this directly

Calls 2

readMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected