Skip to content

Commit

Permalink
[needs-docs][processing] Monkey patch stable external Processing API …
Browse files Browse the repository at this point in the history
…into qgis.processing

Instead of encouraging use of the internal Processing modules
(e.g. from processing.tools.general import run , import processing, ...)
instead expose all Python specific STABLE processing additions
to the qgis.processing module.

Instead, scripts and plugins should now use

from qgis.processing import run, algorithmHelp,...

This makes a clear distinction between internal Processing python
modules (i.e., everything else!) and the parts of Processing
which are stable and designed to be used by plugins and scripts.

TODO: QGIS 4.0 -- move the internal Processing plugin modules
to __processing, to clearer indicate that this is all internal
stuff.
  • Loading branch information
nyalldawson committed Mar 28, 2019
1 parent bf7d9cb commit 64387a2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions python/plugins/processing/__init__.py
Expand Up @@ -31,6 +31,17 @@
from processing.tools.raster import * # NOQA
from processing.tools.system import * # NOQA

# monkey patch Python specific Processing API into stable qgis.processing module
import qgis.processing
qgis.processing.algorithmHelp = algorithmHelp
qgis.processing.run = run
qgis.processing.runAndLoadResults = runAndLoadResults
qgis.processing.createAlgorithmDialog = createAlgorithmDialog
qgis.processing.execAlgorithmDialog = execAlgorithmDialog
qgis.processing.createContext = createContext
qgis.processing.isWindows = isWindows
qgis.processing.isMac = isMac


def classFactory(iface):
from processing.ProcessingPlugin import ProcessingPlugin
Expand Down

2 comments on commit 64387a2

@3nids
Copy link
Member

@3nids 3nids commented on 64387a2 Oct 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson does this need an app to run?
I am asking because I would like to get these in the API docs, but they are not around if you don't start the app I guess.
On way would be to monkey patch them in python/processing/init.py instead.
Is it possible to move them?

@Gustry
Copy link
Contributor

@Gustry Gustry commented on 64387a2 Apr 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just got the issue on windows, OSGEO4W, 3.10 and 3.12.
Doing qgis.processing is not calling this file but https://github.com/qgis/QGIS/blob/master/python/processing/__init__.py instead.
So it leads to an ImportError.
Should I open a ticket?

Please sign in to comment.