From: Zack Cerza Date: Fri, 11 Jul 2014 16:33:43 +0000 (-0600) Subject: Don't use double underscores X-Git-Tag: 1.1.0~1334^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4a6352e372ebe7f772203e196cae2f9560b46d14;p=teuthology.git Don't use double underscores Signed-off-by: Zack Cerza --- diff --git a/teuthology/config.py b/teuthology/config.py index 3641bef5..713b34e0 100644 --- a/teuthology/config.py +++ b/teuthology/config.py @@ -18,14 +18,14 @@ class YamlConfig(object): if self.yaml_path: self.load() else: - self.__conf = dict() + self._conf = dict() def load(self): if os.path.exists(self.yaml_path): - self.__conf = yaml.safe_load(file(self.yaml_path)) + self._conf = yaml.safe_load(file(self.yaml_path)) else: log.debug("%s not found", self.yaml_path) - self.__conf = dict() + self._conf = dict() def update(self, in_dict): """ @@ -33,7 +33,7 @@ class YamlConfig(object): :param in_dict: The dict to use to update """ - self.__conf.update(in_dict) + self._conf.update(in_dict) @classmethod def from_dict(cls, in_dict): @@ -44,14 +44,14 @@ class YamlConfig(object): :returns: The config object """ conf_obj = cls() - conf_obj.__conf = in_dict + conf_obj._conf = in_dict return conf_obj def to_dict(self): """ :returns: A shallow copy of the configuration as a dict """ - return dict(self.__conf) + return dict(self._conf) @classmethod def from_str(cls, in_str): @@ -62,7 +62,7 @@ class YamlConfig(object): :returns: The config object """ conf_obj = cls() - conf_obj.__conf = yaml.safe_load(in_str) + conf_obj._conf = yaml.safe_load(in_str) return conf_obj def to_str(self): @@ -72,22 +72,22 @@ class YamlConfig(object): return str(self) def __str__(self): - return yaml.safe_dump(self.__conf, default_flow_style=False).strip() + return yaml.safe_dump(self._conf, default_flow_style=False).strip() def __getitem__(self, name): - return self.__conf.__getitem__(name) + return self._conf.__getitem__(name) def __getattr__(self, name): - return self.__conf.get(name, self.defaults.get(name)) + return self._conf.get(name, self.defaults.get(name)) def __setattr__(self, name, value): - if name.endswith('__conf') or name in ('yaml_path'): + if name.endswith('_conf') or name in ('yaml_path'): object.__setattr__(self, name, value) else: - self.__conf[name] = value + self._conf[name] = value def __delattr__(self, name): - del self.__conf[name] + del self._conf[name] class TeuthologyConfig(YamlConfig): diff --git a/teuthology/test/test_config.py b/teuthology/test/test_config.py index f3d03e0b..ac5d9e49 100644 --- a/teuthology/test/test_config.py +++ b/teuthology/test/test_config.py @@ -65,7 +65,7 @@ class TestTeuthologyConfig(TestYamlConfig): def test_set_ceph_git_base_via_private(self): conf_obj = self.test_class() - conf_obj._YamlConfig__conf['ceph_git_base_url'] = \ + conf_obj._conf['ceph_git_base_url'] = \ "git://ceph.com/" assert conf_obj.ceph_git_base_url == "git://ceph.com/"