def save(self, name, data, location='local', kind='json'): """Save a dictionary in a JSON file within the cache directory.""" file_ext = '.json' if kind == 'json' else '.pkl' path = self._get_path(name, location, file_ext=file_ext) _ensure_dir_exists(op.dirname(path)) logger.debug("Save data to `%s`.", path) if kind == 'json': _save_json(path, data) else: _save_pickle(path, data)
def download_test_file(name, config_dir=None, force=False): """Download a test file.""" config_dir = config_dir or phy_config_dir() path = op.join(config_dir, 'test_data', name) _ensure_dir_exists(op.dirname(path)) if not force and op.exists(path): return path url = _BASE_URL + name download_file(url, output_path=path) return path
def __init__(self, name='GUI', config_dir=None, **kwargs): super(GUIState, self).__init__(**kwargs) self.name = name self.config_dir = config_dir or phy_config_dir() _ensure_dir_exists(op.join(self.config_dir, self.name)) self.load()
def save(self, name, data, location='local'): """Save a dictionary in a JSON file within the cache directory.""" path = self._get_path(name, location) _ensure_dir_exists(op.dirname(path)) logger.debug("Save data to `%s`.", path) _save_json(path, data)