No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

picklefile.py 797B

1234567891011121314151617181920212223
  1. #-*- coding: utf-8 -*-
  2. ##@package lodel.editorial_model.translator.picklefile
  3. # This module handles the file storage of an editorial model
  4. import pickle
  5. from pickle import Pickler
  6. ##@brief Saves a model in a file
  7. # @param model EditorialModel : the model to save
  8. # @param filename str|None : if None return the model as pickle bytes (by default : None)
  9. # @return None if filename is a string, else returns bytes representation of model
  10. def save(model, filename = None):
  11. with open(filename, 'w+b') as ffd:
  12. pickle.dump(model, ffd)
  13. return filename
  14. ##@brief Loads a model from a file
  15. # @param filename str : the filename to use to load the model
  16. # @return EditorialModel
  17. def load(filename):
  18. with open(filename, 'rb') as ffd:
  19. edmod = pickle.load(ffd)
  20. return edmod