1# Copyright (c) 2014 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import os 6 7import config_json_iterator 8 9 10class ConfigurationManager(object): 11 """A helper class to read configuration file. 12 13 This class will load a given configuration file and 14 save all the settings into a dictionary. 15 """ 16 17 def __init__(self, config): 18 """Constructor 19 20 @param config: String of config file path. 21 """ 22 if os.path.isfile(config): 23 config_parser = config_json_iterator.ConfigJsonIterator() 24 config_parser.set_config_dir(config) 25 self._settings = config_parser.aggregated_config(config) 26 else: 27 raise IOError('configuration file does not exist') 28 29 30 def get_config_settings(self): 31 """Returns all _settings.""" 32 return self._settings 33