|
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 sys
|
| 30 | +import os |
29 | 31 | import traceback
|
30 | 32 |
|
31 | 33 | from qgis.PyQt.QtCore import Qt, QCoreApplication, QObject, pyqtSignal
|
|
37 | 39 |
|
38 | 40 | import processing
|
39 | 41 | from processing.core.AlgorithmProvider import AlgorithmProvider
|
| 42 | +from processing.script.ScriptUtils import ScriptUtils |
| 43 | +from processing.gui import AlgorithmClassification |
| 44 | +from processing.modeler.ModelerUtils import ModelerUtils |
40 | 45 | from processing.core.ProcessingConfig import ProcessingConfig
|
41 | 46 | from processing.core.GeoAlgorithm import GeoAlgorithm
|
42 | 47 | from processing.core.ProcessingLog import ProcessingLog
|
@@ -73,7 +78,7 @@ class Processing:
|
73 | 78 | contextMenuActions = []
|
74 | 79 |
|
75 | 80 | @staticmethod
|
76 |
| - def addProvider(provider, update=True): |
| 81 | + def addProvider(provider, updateList=True): |
77 | 82 | """Use this method to add algorithms from external providers.
|
78 | 83 | """
|
79 | 84 |
|
@@ -122,13 +127,32 @@ def getProviderFromName(name):
|
122 | 127 |
|
123 | 128 | @staticmethod
|
124 | 129 | def initialize():
|
| 130 | + if Processing.providers: |
| 131 | + return |
125 | 132 | # Add the basic providers
|
126 | 133 | for c in AlgorithmProvider.__subclasses__():
|
127 | 134 | Processing.addProvider(c())
|
128 | 135 | # And initialize
|
129 | 136 | ProcessingConfig.initialize()
|
130 | 137 | ProcessingConfig.readSettings()
|
131 | 138 | RenderingStyles.loadStyles()
|
| 139 | + |
| 140 | + @staticmethod |
| 141 | + def addScripts(folder): |
| 142 | + Processing.initialize() |
| 143 | + provider = Processing.getProviderFromName("qgis") |
| 144 | + scripts = ScriptUtils.loadFromFolder(folder) |
| 145 | + print scripts |
| 146 | + for script in scripts: |
| 147 | + script.allowEdit = False |
| 148 | + script._icon = provider._icon |
| 149 | + script.provider = provider |
| 150 | + provider.externalAlgs.extend(scripts) |
| 151 | + Processing.reloadProvider("qgis") |
| 152 | + |
| 153 | + @staticmethod |
| 154 | + def removeScripts(folder): |
| 155 | + pass |
132 | 156 |
|
133 | 157 | @staticmethod
|
134 | 158 | def updateAlgsList():
|
|
0 commit comments