17
17
***************************************************************************
18
18
"""
19
19
20
+
20
21
__author__ = 'Victor Olaya'
21
22
__date__ = 'August 2012'
22
23
__copyright__ = '(C) 2012, Victor Olaya'
26
27
__revision__ = '$Format:%H$'
27
28
28
29
import os
29
- import pickle
30
+ import json
30
31
from PyQt4 .QtCore import *
31
32
from PyQt4 .QtGui import *
32
33
from qgis .core import *
33
34
from processing .ui .ui_DlgHelpEdition import Ui_DlgHelpEdition
35
+ from processing .core .ProcessingLog import ProcessingLog
34
36
35
37
36
38
class HelpEditionDialog (QDialog , Ui_DlgHelpEdition ):
@@ -49,8 +51,13 @@ def __init__(self, alg):
49
51
if self .alg .descriptionFile is not None :
50
52
helpfile = alg .descriptionFile + '.help'
51
53
if os .path .exists (helpfile ):
52
- f = open (helpfile , 'rb' )
53
- self .descriptions = pickle .load (f )
54
+ try :
55
+ with open (helpfile ) as f :
56
+ self .descriptions = json .load (f )
57
+ except Exception , e :
58
+ print e
59
+ ProcessingLog .addToLog (ProcessingLog .LOG_WARNING , "Cannot open gelp file: " + helpfile )
60
+
54
61
self .currentName = self .ALG_DESC
55
62
if self .ALG_DESC in self .descriptions :
56
63
self .text .setText (self .descriptions [self .ALG_DESC ])
@@ -67,17 +74,15 @@ def accept(self):
67
74
self .descriptions [self .currentName ] = unicode (self .text .toPlainText ())
68
75
if self .alg .descriptionFile is not None :
69
76
try :
70
- f = open (self .alg .descriptionFile + '.help' , 'wb' )
71
- pickle .dump (self .descriptions , f )
72
- f .close ()
77
+ with open (self .alg .descriptionFile + '.help' , 'w' ) as f :
78
+ json .dump (self .descriptions , f )
73
79
except Exception , e :
74
80
QMessageBox .warning (self , 'Error saving help file' ,
75
- 'Help file could not be saved. Check that \
76
- you have permission to modify the help \
77
- file. You might not have permission if \
78
- you are editing an example model or \
79
- script, since they are stored on the \
80
- installation folder' )
81
+ 'Help file could not be saved.\n '
82
+ 'Check that you have permission to modify the help\n '
83
+ 'file. You might not have permission if you are \n '
84
+ 'editing an example model or script, since they \n '
85
+ 'are stored on the installation folder' )
81
86
82
87
QDialog .accept (self )
83
88
0 commit comments