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 634B

1234567891011121314151617181920
  1. #-*- coding: utf-8 -*-
  2. import pickle
  3. from pickle import Pickler
  4. ##@brief Save a model in a file
  5. # @param model EditorialModel : the model to save
  6. # @param filename str|None : if None return the model as pickle bytes
  7. # @return None if filename is a string, else returns bytes representation of model
  8. def save(model, filename = None):
  9. with open(filename, 'w+b') as ffd:
  10. pickle.dump(model, ffd)
  11. return filename
  12. ##@brief Load a model from a file
  13. # @param filename str : the filename to use to load the model
  14. def load(filename):
  15. with open(filename, 'rb') as ffd:
  16. edmod = pickle.load(ffd)
  17. return edmod