41
41
from processing .gui .Postprocessing import handleAlgorithmResults
42
42
43
43
44
- def alglist (text = None ):
44
+ def algorithmsList (text = None ):
45
+ """Returns list of all available Processing algorithms or list
46
+ of algorithms which names contains given text.
47
+ Returned list contains algorithm command-line names.
48
+ """
49
+ lst = []
50
+ for provider in list (algList .algs .values ()):
51
+ sortedlist = sorted (list (provider .values ()), key = lambda alg : alg .name )
52
+ for alg in sortedlist :
53
+ if text is None or text .lower () in alg .name .lower ():
54
+ lst .append (alg .commandLineName ())
55
+ return lst
56
+
57
+
58
+ def printAlgorithms (text = None ):
59
+ """Print list of all available Processing algorithms or list
60
+ of algorithms which names contains given text.
61
+ Prints algorithms user-friendly names as well as command-line
62
+ names.
63
+ """
45
64
s = ''
46
65
for provider in list (algList .algs .values ()):
47
66
sortedlist = sorted (list (provider .values ()), key = lambda alg : alg .name )
48
67
for alg in sortedlist :
49
68
if text is None or text .lower () in alg .name .lower ():
50
- s += alg .name .ljust (50 , '-' ) + '--->' + alg .commandLineName () \
51
- + '\n '
69
+ s += '{}--->{}\n ' .format (alg .name .ljust (50 , '-' ), alg .commandLineName ())
52
70
print (s )
53
71
54
72
55
73
def algorithmOptions (name ):
74
+ """Prints all algorithm options with their values.
75
+ """
56
76
alg = Processing .getAlgorithm (name )
57
77
if alg is not None :
58
78
opts = ''
@@ -67,6 +87,9 @@ def algorithmOptions(name):
67
87
68
88
69
89
def algorithmHelp (name ):
90
+ """Prints algorithm parameters with their types. Also
91
+ provides information about options if any.
92
+ """
70
93
alg = Processing .getAlgorithm (name )
71
94
if alg is not None :
72
95
alg = alg .getCopy ()
@@ -77,12 +100,18 @@ def algorithmHelp(name):
77
100
78
101
79
102
def runalg (algOrName , * args , ** kwargs ):
103
+ """Executes given algorithm and returns its outputs as dictionary
104
+ object.
105
+ """
80
106
alg = Processing .runAlgorithm (algOrName , None , * args , ** kwargs )
81
107
if alg is not None :
82
108
return alg .getOutputValuesAsDictionary ()
83
109
84
110
85
111
def runandload (name , * args , ** kwargs ):
112
+ """Executes given algorithm and load its results into QGIS project
113
+ when possible.
114
+ """
86
115
return Processing .runAlgorithm (name , handleAlgorithmResults , * args , ** kwargs )
87
116
88
117
0 commit comments