class GlobalSettings: def __init__(self): home = str(Path.home()) self._fileinfo = FileInfo(os.path.join(home, SYNC_CONFIG_NAME)) self._data = self._fileinfo.load() if self._fileinfo.is_exists( ) else {} def _save(self): self._fileinfo.dump(self._data) @property def token(self): return self._data.get('token') @token.setter def token(self, value): self._data['token'] = value self._save()
def save(self, path): ''' save template to file so we can get it next time. ''' fileinfo = FileInfo(path) fileinfo.dump(self.__dict__, kwargs={'indent': 2})