Skip to content

Commit

Permalink
Some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 7, 2017
1 parent 1bc3b28 commit 5a6f11d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
10 changes: 6 additions & 4 deletions python/plugins/processing/core/Processing.py
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand Down
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/tests/GdalAlgorithmsTest.py
Expand Up @@ -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):
Expand Down
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions python/plugins/processing/tests/Grass7AlgorithmsRasterTest.py
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions python/plugins/processing/tests/QgisAlgorithmsTest.py
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions python/plugins/processing/tests/ScriptAlgorithmsTest.py
Expand Up @@ -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)

Expand Down

0 comments on commit 5a6f11d

Please sign in to comment.