Skip to content

Commit 67bcf40

Browse files
committed
Improve output from plugin wizard generated plugins.
1 parent ff6d765 commit 67bcf40

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

src/mapclient/tools/pluginwizard/skeleton.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
CONFIGURE_METHOD_STRING,
3939
DESERIALIZE_DEFAULT_CONTENT_STRING,
4040
DESERIALIZE_IDENTIFIER_CONTENT_STRING,
41-
GETIDENTIFIER_DEFAULT_CONTENT_STRING,
42-
GETIDENTIFIER_IDENTIFER_CONTENT_STRING,
41+
GET_IDENTIFIER_DEFAULT_CONTENT_STRING,
42+
GET_IDENTIFIER_IDENTIFIER_CONTENT_STRING,
4343
IDENTIFIER_METHOD_STRING,
4444
IMPORT_STRING,
4545
INIT_METHOD_STRING,
@@ -49,8 +49,8 @@
4949
SERIALIZE_DEFAULT_CONTENT_STRING,
5050
SERIALIZE_IDENTIFIER_CONTENT_STRING,
5151
SERIALIZE_METHOD_STRING,
52-
SETIDENTIFIER_DEFAULT_CONTENT_STRING,
53-
SETIDENTIFIER_IDENTIFER_CONTENT_STRING,
52+
SET_IDENTIFIER_DEFAULT_CONTENT_STRING,
53+
SET_IDENTIFIER_IDENTIFIER_CONTENT_STRING,
5454
SETUP_PY_TEMPLATE,
5555
STEP_PACKAGE_INIT_STRING,
5656
)
@@ -277,11 +277,11 @@ def _writeStep(self, step_dir):
277277
init_string += ' self._portData{0} = None # {1}\n'.format(index, current_port[1])
278278

279279
if self._options.hasIdentifierConfig():
280-
id_method_string = IDENTIFIER_METHOD_STRING.format(getidentifiercontent=GETIDENTIFIER_IDENTIFER_CONTENT_STRING,
281-
setidentifiercontent=SETIDENTIFIER_IDENTIFER_CONTENT_STRING)
280+
id_method_string = IDENTIFIER_METHOD_STRING.format(getidentifiercontent=GET_IDENTIFIER_IDENTIFIER_CONTENT_STRING,
281+
setidentifiercontent=SET_IDENTIFIER_IDENTIFIER_CONTENT_STRING)
282282
else:
283-
id_method_string = IDENTIFIER_METHOD_STRING.format(getidentifiercontent=GETIDENTIFIER_DEFAULT_CONTENT_STRING.format(step_object_name=object_name),
284-
setidentifiercontent=SETIDENTIFIER_DEFAULT_CONTENT_STRING)
283+
id_method_string = IDENTIFIER_METHOD_STRING.format(getidentifiercontent=GET_IDENTIFIER_DEFAULT_CONTENT_STRING.format(step_object_name=object_name),
284+
setidentifiercontent=SET_IDENTIFIER_DEFAULT_CONTENT_STRING)
285285

286286
if self._options.configCount() > 0:
287287
init_string += ' # Config:\n'
@@ -394,14 +394,13 @@ def getConfig(self):
394394
\"\"\"
395395
Get the current value of the configuration from the dialog.{additional_comment}
396396
\"\"\"{previous_identifier}
397-
config = {{}}
398397
"""
399398
if self._options.hasIdentifierConfig():
400399
set_config_string = set_config_string.format(
401400
additional_comment=' Also\n'
402401
' set the _previousIdentifier value so that we can check uniqueness of the\n'
403402
' identifier over the whole of the workflow.',
404-
previous_identifier='\n self._previousIdentifier = config[\'identifier\']')
403+
previous_identifier='\n self._previousIdentifier = config[\'Identifier\']')
405404
get_config_string = get_config_string.format(
406405
additional_comment=' Also\n'
407406
' set the _previousIdentifier value so that we can check uniqueness of the\n'
@@ -412,16 +411,16 @@ def getConfig(self):
412411
get_config_string = get_config_string.format(additional_comment='', previous_identifier='')
413412

414413
row_index = 0
414+
config_key_item_string = ''
415415
while row_index < self._options.configCount():
416416
label = self._options.getConfig(row_index)[0]
417417
widgets_string += CONFIGURE_DIALOG_LINE.format(row=row_index, label=label + ': ')
418418
config = self._options.getConfig(row_index)
419419
set_config_string += ' self._ui.lineEdit{0}.setText(config[\'{1}\'])\n'.format(row_index, config[0])
420-
get_config_string += ' config[\'{1}\'] = self._ui.lineEdit{0}.text()\n'.format(row_index, config[0])
420+
config_key_item_string += ' \'{1}\': self._ui.lineEdit{0}.text(),\n'.format(row_index, config[0])
421421
row_index += 1
422422

423-
set_config_string += '\n'
424-
get_config_string += ' return config\n'
423+
get_config_string += ' return {\n' + config_key_item_string + ' }\n' if config_key_item_string else ' return {}\n'
425424

426425
ui_file = os.path.join(qt_dir, QT_CONFDIALOG_UI_FILENAME)
427426
with open(ui_file, 'w') as fui:

src/mapclient/tools/pluginwizard/skeletonstrings.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
You should have received a copy of the GNU General Public License
1818
along with MAP Client. If not, see <http://www.gnu.org/licenses/>..
1919
"""
20+
from src.setup_map_client import SETUP_SETS
2021

2122
IMPORT_STRING = """
2223
\"\"\"
@@ -67,10 +68,10 @@ def setIdentifier(self, identifier):
6768
{setidentifiercontent}
6869
"""
6970

70-
GETIDENTIFIER_DEFAULT_CONTENT_STRING = 'return \'{step_object_name}\' # TODO: The string must be replaced with the step\'s unique identifier'
71-
SETIDENTIFIER_DEFAULT_CONTENT_STRING = 'pass # TODO: Must actually set the step\'s identifier here'
72-
GETIDENTIFIER_IDENTIFER_CONTENT_STRING = 'return self._config[\'identifier\']'
73-
SETIDENTIFIER_IDENTIFER_CONTENT_STRING = 'self._config[\'identifier\'] = identifier'
71+
GET_IDENTIFIER_DEFAULT_CONTENT_STRING = 'return \'{step_object_name}\' # TODO: The string must be replaced with the step\'s unique identifier'
72+
SET_IDENTIFIER_DEFAULT_CONTENT_STRING = 'pass # TODO: Must actually set the step\'s identifier here'
73+
GET_IDENTIFIER_IDENTIFIER_CONTENT_STRING = 'return self._config[\'Identifier\']'
74+
SET_IDENTIFIER_IDENTIFIER_CONTENT_STRING = 'self._config[\'Identifier\'] = identifier'
7475

7576
SERIALIZE_METHOD_STRING = """
7677
def serialize(self):
@@ -88,7 +89,6 @@ def deserialize(self, string):
8889
:param string: JSON representation of the configuration in a string.
8990
\"\"\"
9091
{deserializecontent}
91-
9292
"""
9393

9494
SERIALIZE_DEFAULT_CONTENT_STRING = 'pass'
@@ -100,8 +100,7 @@ def deserialize(self, string):
100100
d = ConfigureDialog()
101101
d.identifierOccursCount = self._identifierOccursCount
102102
d.setConfig(self._config)
103-
self._configured = d.validate()
104-
"""
103+
self._configured = d.validate()"""
105104

106105
CONFIGURE_DIALOG_STRING = """
107106

0 commit comments

Comments
 (0)