def get_token(self): try: d = file_utils.read_yaml( file_utils.resolve_path(self.token_file_name, self.token_dir)) except IOError: raise self.TokenNotFound if 'token' not in d: raise self.TokenNotFound return d['token']
def get_config(self): config_path = file_utils.resolve_path(self.config_file_name, self.config_dir) try: conf = file_utils.read_yaml(config_path) except IOError: conf = self.default_config else: if not conf: conf = self.default_config return conf
def save_token(self, token): d = {'token': token} filename = file_utils.resolve_path(self.token_file_name, self.token_dir) file_utils.save_yaml(d, filename) file_utils.chmod(filename, self.token_file_mode)
def __init__(self, token_dir): self.token_dir = file_utils.resolve_path(token_dir)
def save_config(self, config): path = file_utils.resolve_path(self.config_file_name, self.config_dir) file_utils.save_yaml(config, path)
def __init__(self, config_dir, default_config): self.config_dir = file_utils.resolve_path(config_dir) self.default_config = default_config