def save_pickle(file_name, obj): """ Pickle the Python object to the given file. """ pickle_path = join(Config.get_config_folder(), file_name) with open(pickle_path, "wb") as f: dump(obj, f)
def load_pickle(file_name, default=None): """ Unpickle the Python object from the given file. If it does not exist, return the default value. """ pickle_path = join(Config.get_config_folder(), file_name) if exists(pickle_path): with open(pickle_path, "rb") as f: return load(f) else: return default
def _get_data_frame(path): """ Return a pandas DataFrame with 'Artist', 'Album', 'Track', and 'Cover' columns. """ # This code saves the state in a pickle file for speed. Not worth it state_file = join(Config.get_config_folder(), "library-pd.pkl") if exists(state_file): df = pd.read_pickle(state_file) else: df = Library._build_data_frame(path) df.to_pickle(state_file) return df
def get(): """ Build and return an appropriately configured Storage class """ return JsonStore( join(Config.get_config_folder(), "zenplayer_state.json"))