Skip to content

Commit f233a7f

Browse files
authored
Merge pull request #154 from hsorby/wizard
Tweak files generated by plugin. wizard
2 parents 3aa848d + 562dbc3 commit f233a7f

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

src/mapclient/tools/pluginfinder/pluginfinderdialog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _download_selected(self):
9090
if overwrite == QMessageBox.No:
9191
continue
9292

93-
url = self._ui.stepTreeView.selectionModel().model().data(index, QtCore.Qt.UserRole + 1).get_url()
93+
url = self._ui.stepTreeView.selectionModel().model().data(index, QtCore.Qt.ItemDataRole.UserRole + 1).get_url()
9494
url_list.append(url)
9595
self._download_to_directory_dialog(url_list)
9696

@@ -106,7 +106,7 @@ def _tree_button_clicked(self, name, url):
106106
if name in installed_versions.keys():
107107
if version.parse(self._database_versions[name]) > version.parse(installed_versions[name]):
108108
overwrite = self._confirm_overwrite(name)
109-
if overwrite == QMessageBox.No:
109+
if overwrite == QMessageBox.StandardButton.No:
110110
return
111111

112112
self._download_to_directory_dialog([url])

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: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
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-
2120
IMPORT_STRING = """
2221
\"\"\"
2322
MAP Client Plugin Step
@@ -67,10 +66,10 @@ def setIdentifier(self, identifier):
6766
{setidentifiercontent}
6867
"""
6968

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'
69+
GET_IDENTIFIER_DEFAULT_CONTENT_STRING = 'return \'{step_object_name}\' # TODO: The string must be replaced with the step\'s unique identifier'
70+
SET_IDENTIFIER_DEFAULT_CONTENT_STRING = 'pass # TODO: Must actually set the step\'s identifier here'
71+
GET_IDENTIFIER_IDENTIFIER_CONTENT_STRING = 'return self._config[\'Identifier\']'
72+
SET_IDENTIFIER_IDENTIFIER_CONTENT_STRING = 'self._config[\'Identifier\'] = identifier'
7473

7574
SERIALIZE_METHOD_STRING = """
7675
def serialize(self):
@@ -88,7 +87,6 @@ def deserialize(self, string):
8887
:param string: JSON representation of the configuration in a string.
8988
\"\"\"
9089
{deserializecontent}
91-
9290
"""
9391

9492
SERIALIZE_DEFAULT_CONTENT_STRING = 'pass'
@@ -100,8 +98,7 @@ def deserialize(self, string):
10098
d = ConfigureDialog()
10199
d.identifierOccursCount = self._identifierOccursCount
102100
d.setConfig(self._config)
103-
self._configured = d.validate()
104-
"""
101+
self._configured = d.validate()"""
105102

106103
CONFIGURE_DIALOG_STRING = """
107104

0 commit comments

Comments
 (0)