16
16
* *
17
17
***************************************************************************
18
18
"""
19
+ from __future__ import print_function
19
20
from builtins import str
20
21
from builtins import range
21
22
33
34
from processing .core .GeoAlgorithm import GeoAlgorithm
34
35
from processing .core .GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
35
36
from processing .core .parameters import ParameterTable
37
+ from processing .core .parameters import Parameter
36
38
from processing .core .outputs import OutputVector
37
39
from processing .tools import dataobjects , vector
38
40
39
- from .fieldsmapping import ParameterFieldsMapping
40
-
41
41
42
42
class FieldsMapper (GeoAlgorithm ):
43
43
@@ -55,6 +55,38 @@ def defineCharacteristics(self):
55
55
self .addParameter (ParameterTable (self .INPUT_LAYER ,
56
56
self .tr ('Input layer' ),
57
57
False ))
58
+
59
+ class ParameterFieldsMapping (Parameter ):
60
+
61
+ default_metadata = {
62
+ 'widget_wrapper' : 'processing.algs.qgis.ui.FieldsMappingPanel.FieldsMappingWidgetWrapper'
63
+ }
64
+
65
+ def __init__ (self , name = '' , description = '' , parent = None ):
66
+ Parameter .__init__ (self , name , description )
67
+ self .parent = parent
68
+ self .value = []
69
+
70
+ def getValueAsCommandLineParameter (self ):
71
+ return '"' + str (self .value ) + '"'
72
+
73
+ def setValue (self , value ):
74
+ if value is None :
75
+ return False
76
+ if isinstance (value , list ):
77
+ self .value = value
78
+ return True
79
+ if isinstance (value , str ):
80
+ try :
81
+ self .value = eval (value )
82
+ return True
83
+ except Exception as e :
84
+ # fix_print_with_import
85
+ print (str (e )) # display error in console
86
+ return False
87
+ return False
88
+
89
+
58
90
self .addParameter (ParameterFieldsMapping (self .FIELDS_MAPPING ,
59
91
self .tr ('Fields mapping' ),
60
92
self .INPUT_LAYER ))
0 commit comments