Coverage for appr/config.py : 36%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Store Auth object """
self.conf_directory = conf_directory home = os.path.expanduser("~") mkdir_p(os.path.join(home, conf_directory)) path = "%s/%s/config.yaml" % (home, conf_directory) self.configfile = os.path.join(home, path) self._config = None
def config(self): if self._config is None: if os.path.exists(self.configfile): with open(self.configfile, 'r') as configfile: self._config = yaml.load(configfile.read()) else: self._config = {} return self._config
self.config[key] = value self._write_config(self.config)
with open(self.configfile, 'w') as configfile: configfile.write( yaml.safe_dump(config, indent=2, default_style='"', default_flow_style=False))
if 'repositories' not in self.config: self.config['repositories'] = {} self.config['repositories'][alias] = target self._write_config(self.config)
if 'repositories' in self.config: return self.config['repositories'].get(alias, None) return None |