예제 #1
0
 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)
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 def get():
     """
     Build and return an appropriately configured Storage class
     """
     return JsonStore(
         join(Config.get_config_folder(), "zenplayer_state.json"))