Skip to content
Permalink
Browse files
Some cleanups
  • Loading branch information
nyalldawson committed Apr 7, 2017
1 parent 1bc3b28 commit 5a6f11d52e758072604965aea2b0c029366c8ffe
@@ -61,11 +61,11 @@
from processing.script.ScriptAlgorithmProvider import ScriptAlgorithmProvider # NOQA
from processing.preconfigured.PreconfiguredAlgorithmProvider import PreconfiguredAlgorithmProvider # NOQA

# workaround SIP bindings losing subclasses during transfer to QgsProcessingRegistry
PROVIDERS = []

class Processing(object):

BASIC_PROVIDERS = []

@staticmethod
def activateProvider(providerOrName, activate=True):
provider_id = providerOrName.id() if isinstance(providerOrName, QgsProcessingProvider) else providerOrName
@@ -85,7 +85,7 @@ def initialize():
# Add the basic providers
for c in QgsProcessingProvider.__subclasses__():
p = c()
PROVIDERS.append(p)
Processing.BASIC_PROVIDERS.append(p)
QgsApplication.processingRegistry().addProvider(p)
# And initialize
ProcessingConfig.initialize()
@@ -94,9 +94,11 @@ def initialize():

@staticmethod
def deinitialize():
for p in PROVIDERS:
for p in Processing.BASIC_PROVIDERS:
QgsApplication.processingRegistry().removeProvider(p)

Processing.BASIC_PROVIDERS = []

@staticmethod
def addScripts(folder):
Processing.initialize()
@@ -72,7 +72,7 @@ def load(self):
return True

def unload(self):
ProcessingConfig.addSetting(ScriptUtils.SCRIPTS_FOLDER)
ProcessingConfig.removeSetting(ScriptUtils.SCRIPTS_FOLDER)
ProviderActions.deregisterProviderActions(self)
ProviderContextMenuActions.deregisterProviderContextMenuActions(self.contextMenuActions)

@@ -100,7 +100,7 @@ def check_algorithm(self, name, defs):
filePath = os.path.join(processingTestDataPath(), 'scripts', '{}.py'.format(defs['algorithm'][len('script:'):]))
alg = ScriptAlgorithm(filePath)
else:
alg = QgsApplication.processingRegistry().algorithmById(defs['algorithm']).getCopy()
alg = QgsApplication.processingRegistry().algorithmById(defs['algorithm'])

if isinstance(params, list):
for param in zip(alg.parameters, params):
@@ -60,7 +60,8 @@ class TestGdalOgr2OgrToPostgis(unittest.TestCase):
@classmethod
def setUpClass(cls):
# start_app()
pass
from processing.core.Processing import Processing
Processing.initialize()

@classmethod
def tearDownClass(cls):
@@ -47,6 +47,8 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
from processing.core.Processing import Processing
Processing.deinitialize()
for path in cls.cleanup_paths:
shutil.rmtree(path)

@@ -47,6 +47,8 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
from processing.core.Processing import Processing
Processing.deinitialize()
for path in cls.cleanup_paths:
shutil.rmtree(path)

@@ -44,6 +44,8 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
from processing.core.Processing import Processing
Processing.deinitialize()
for path in cls.cleanup_paths:
shutil.rmtree(path)

@@ -44,6 +44,8 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
from processing.core.Processing import Processing
Processing.deinitialize()
for path in cls.cleanup_paths:
shutil.rmtree(path)

0 comments on commit 5a6f11d

Please sign in to comment.