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