mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] helpfiles for scripts/models are now stored as json
This commit is contained in:
parent
ff2435300f
commit
6c9f7d77ee
@ -25,11 +25,9 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import re
|
||||
import codecs
|
||||
import datetime
|
||||
from PyQt4 import QtGui
|
||||
from processing.tools.system import *
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* *
|
||||
***************************************************************************
|
||||
"""
|
||||
import re
|
||||
|
||||
|
||||
__author__ = 'Victor Olaya'
|
||||
__date__ = 'August 2012'
|
||||
@ -26,10 +26,9 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import pickle
|
||||
from processing.tools.system import *
|
||||
import os
|
||||
import codecs
|
||||
import re
|
||||
import json
|
||||
|
||||
ALG_DESC = 'ALG_DESC'
|
||||
ALG_CREATOR = 'ALG_CREATOR'
|
||||
@ -58,8 +57,8 @@ def getHtmlFromHelpFile(alg, helpFile):
|
||||
if not os.path.exists(helpFile):
|
||||
return None
|
||||
alg = alg
|
||||
f = open(helpFile, 'rb')
|
||||
descriptions = pickle.load(f)
|
||||
with open(helpFile) as f:
|
||||
descriptions = json.load(f)
|
||||
s = '<html><body><h2>Algorithm description</h2>\n'
|
||||
s += '<p>' + getDescription(ALG_DESC, descriptions) + '</p>\n'
|
||||
s += '<h2>Input parameters</h2>\n'
|
||||
|
@ -17,6 +17,7 @@
|
||||
***************************************************************************
|
||||
"""
|
||||
|
||||
|
||||
__author__ = 'Victor Olaya'
|
||||
__date__ = 'August 2012'
|
||||
__copyright__ = '(C) 2012, Victor Olaya'
|
||||
@ -26,11 +27,12 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import pickle
|
||||
import json
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from qgis.core import *
|
||||
from processing.ui.ui_DlgHelpEdition import Ui_DlgHelpEdition
|
||||
from processing.core.ProcessingLog import ProcessingLog
|
||||
|
||||
|
||||
class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):
|
||||
@ -49,8 +51,13 @@ class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):
|
||||
if self.alg.descriptionFile is not None:
|
||||
helpfile = alg.descriptionFile + '.help'
|
||||
if os.path.exists(helpfile):
|
||||
f = open(helpfile, 'rb')
|
||||
self.descriptions = pickle.load(f)
|
||||
try:
|
||||
with open(helpfile) as f:
|
||||
self.descriptions = json.load(f)
|
||||
except Exception, e:
|
||||
print e
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, "Cannot open gelp file: " + helpfile)
|
||||
|
||||
self.currentName = self.ALG_DESC
|
||||
if self.ALG_DESC in self.descriptions:
|
||||
self.text.setText(self.descriptions[self.ALG_DESC])
|
||||
@ -67,17 +74,15 @@ class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):
|
||||
self.descriptions[self.currentName] = unicode(self.text.toPlainText())
|
||||
if self.alg.descriptionFile is not None:
|
||||
try:
|
||||
f = open(self.alg.descriptionFile + '.help', 'wb')
|
||||
pickle.dump(self.descriptions, f)
|
||||
f.close()
|
||||
with open(self.alg.descriptionFile + '.help', 'w') as f:
|
||||
json.dump(self.descriptions, f)
|
||||
except Exception, e:
|
||||
QMessageBox.warning(self, 'Error saving help file',
|
||||
'Help file could not be saved. Check that \
|
||||
you have permission to modify the help \
|
||||
file. You might not have permission if \
|
||||
you are editing an example model or \
|
||||
script, since they are stored on the \
|
||||
installation folder')
|
||||
'Help file could not be saved.\n'
|
||||
'Check that you have permission to modify the help\n'
|
||||
'file. You might not have permission if you are \n'
|
||||
'editing an example model or script, since they \n'
|
||||
'are stored on the installation folder')
|
||||
|
||||
QDialog.accept(self)
|
||||
|
||||
|
@ -25,9 +25,9 @@ __copyright__ = '(C) 2012, Alexander Bruy'
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import pickle
|
||||
import codecs
|
||||
import sys
|
||||
import json
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
@ -166,9 +166,8 @@ class ScriptEditorDialog(QDialog, Ui_DlgScriptEditor):
|
||||
# If help strings were defined before saving the script for
|
||||
# the first time, we do it here
|
||||
if self.help:
|
||||
f = open(self.filename + '.help', 'wb')
|
||||
pickle.dump(self.help, f)
|
||||
f.close()
|
||||
with open(self.filename + '.help', 'w') as f:
|
||||
json.dump(self.help, f)
|
||||
self.help = None
|
||||
self.setHasChanged(False)
|
||||
else:
|
||||
|
@ -16,6 +16,7 @@
|
||||
* *
|
||||
***************************************************************************
|
||||
"""
|
||||
import json
|
||||
|
||||
__author__ = 'Victor Olaya'
|
||||
__date__ = 'August 2012'
|
||||
@ -26,7 +27,6 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import codecs
|
||||
import pickle
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
@ -308,9 +308,8 @@ class ModelerDialog(QDialog, Ui_DlgModeler):
|
||||
# If help strings were defined before saving the model
|
||||
# for the first time, we do it here.
|
||||
if self.help:
|
||||
f = open(self.alg.descriptionFile + '.help', 'wb')
|
||||
pickle.dump(self.help, f)
|
||||
f.close()
|
||||
with open(self.descriptionFile + '.help', 'w') as f:
|
||||
json.dump(self.help, f)
|
||||
self.help = None
|
||||
QMessageBox.information(self, self.tr('Model saved'),
|
||||
self.tr('Model was correctly saved.'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user