Created
June 25, 2014 11:59
-
-
Save stefanooldeman/7634e68c4d7d88eeffdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ConfigParser import ConfigParser | |
class LoaderConfig(dict): | |
def __init__(self, config_path, section): | |
_dyn_kwargs = self.load_config(config_path) | |
super(LoaderConfig, self).__init__(_dyn_kwargs[section]) | |
self.__dict__ = self | |
def load_config(self, config_path): | |
config = ConfigParser() | |
config.read(config_path) | |
section_values = config._sections | |
for key, values in section_values.items(): | |
del section_values[key]['__name__'] | |
return section_values | |
if __name__ == "__main__": | |
cnf = LoaderConfig("myfilefooo.conf", "mysql") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment