Пример #1
0
 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']
Пример #2
0
 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
Пример #3
0
 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)
Пример #4
0
 def __init__(self, token_dir):
     self.token_dir = file_utils.resolve_path(token_dir)
Пример #5
0
 def save_config(self, config):
     path = file_utils.resolve_path(self.config_file_name, self.config_dir)
     file_utils.save_yaml(config, path)
Пример #6
0
 def __init__(self, config_dir, default_config):
     self.config_dir = file_utils.resolve_path(config_dir)
     self.default_config = default_config