Skip to content

Commit 62f1e81

Browse files
committed
Add getPorts API to steps to get the current steps ports. Tidy names from C++ to Python style.
1 parent db129f2 commit 62f1e81

4 files changed

Lines changed: 21 additions & 13 deletions

File tree

src/mapclient/core/workflow/workflowdependencygraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ def execute(self):
223223
# But don't use this as it is not what is documented.
224224
# source_step = connection.source()._step
225225
# destination_step = current_node._step
226-
# source_ports = [port for port in source_step._ports if port.hasProvides()]
227-
# destination_ports = [port for port in destination_step._ports if port.hasUses()]
226+
# source_ports = [port for port in source_step._ports if port.has_provides()]
227+
# destination_ports = [port for port in destination_step._ports if port.has_uses()]
228228
# source_data_index = source_ports.index(source_step._ports[connection.sourceIndex()])
229229
# destination_data_index = destination_ports.index(destination_step._ports[connection.destinationIndex()])
230230

src/mapclient/mountpoints/workflowstep.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ def getTriplesForObj(self, obj):
5959

6060
# return [triple[2] for triple in self.obj[obj]]
6161

62-
def hasUses(self):
62+
def has_uses(self):
6363
for uses_annotation in USES_ANNOTATIONS:
6464
if uses_annotation in self.pred:
6565
return True
6666

6767
return False
6868

69-
def hasProvides(self):
69+
def has_provides(self):
7070
for provides_annotation in PROVIDES_ANNOTATIONS:
7171
if provides_annotation in self.pred:
7272
return True
@@ -95,7 +95,7 @@ def _test_for_possible_connection(self, mineProvides, theirsUses):
9595

9696
return False
9797

98-
def canConnect(self, other):
98+
def can_connect(self, other):
9999
if PORT_ANNOTATION in self.subj and PORT_ANNOTATION in other.subj:
100100
myPorts = self.subj[PORT_ANNOTATION]
101101
theirPorts = other.subj[PORT_ANNOTATION]
@@ -237,6 +237,13 @@ def _workflow_step_addPort(self, triple):
237237
self._ports.append(port)
238238

239239

240+
def _workflow_step_getPorts(self):
241+
"""
242+
Returns a list of WorkflowStepPort objects that describe the ports of this step.
243+
"""
244+
return self._ports
245+
246+
240247
def _workflow_step_getName(self):
241248
if hasattr(self, '_name'):
242249
return self._name
@@ -300,6 +307,7 @@ def _workflow_step_relocate_configuration(self, to_location):
300307
'getIcon': _workflow_step_get_icon,
301308
'getLocation': _workflow_step_getLocation,
302309
'getPortData': _workflow_step_getPortData,
310+
'getPorts': _workflow_step_getPorts,
303311
'getSourceURI': _workflow_step_get_source_uri,
304312
'getName': _workflow_step_getName,
305313
'gitInclude': _workflow_step_git_include,

src/mapclient/view/workflow/workflowgraphicsitems.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def __init__(self, metastep):
302302

303303
self.updateDVCSIcon()
304304

305-
def update(self):
305+
def update(self, rect=None):
306306
self._update_configure_icon()
307307
self._update_ports()
308308
self._update_text_icon()
@@ -320,7 +320,7 @@ def _update_configure_icon(self):
320320
self._set_tool_tip()
321321

322322
def _set_tool_tip(self):
323-
self.setToolTip(self._metastep._step.getName() + ": " + self._metastep._step.getIdentifier())
323+
self.setToolTip(self._metastep.getName() + ": " + self._metastep.getIdentifier())
324324
self._text.setText(
325325
self._metastep.getStepIdentifier() if self._metastep.getStepIdentifier() != self._metastep.getUniqueIdentifier() else self._metastep.getName())
326326
self._update_text_icon()
@@ -333,8 +333,8 @@ def _update_ports(self):
333333

334334
self._step_port_items = []
335335
# Collect all ports that provide or use from the step
336-
uses_ports = [port for port in current_step_ports if port.hasUses()]
337-
provides_ports = [port for port in current_step_ports if port.hasProvides()]
336+
uses_ports = [port for port in current_step_ports if port.has_uses()]
337+
provides_ports = [port for port in current_step_ports if port.has_provides()]
338338

339339
uses_count = 0
340340
uses_total = len(uses_ports)
@@ -471,7 +471,7 @@ def showContextMenu(self, pos):
471471
self._contextMenu.popup(pos)
472472

473473
def _getStepLocation(self):
474-
return os.path.join(self._metastep._step._location, self._metastep._step.getIdentifier())
474+
return os.path.join(self._metastep._step._location, self._metastep.getIdentifier())
475475

476476

477477
class StepPort(QtWidgets.QGraphicsEllipseItem):
@@ -522,11 +522,11 @@ def width(self):
522522
def height(self):
523523
return self.boundingRect().height()
524524

525-
def canConnect(self, other):
525+
def can_connect(self, other):
526526
if other.hasConnections():
527527
return False
528528

529-
return self._port.canConnect(other._port)
529+
return self._port.can_connect(other.port())
530530

531531
def hasConnections(self):
532532
self._removeDeadwood()

src/mapclient/view/workflow/workflowgraphicsview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def showStepNames(self, show):
9999
def connectNodes(self, src_port, dest_port):
100100
# Check if nodes are already connected
101101
if not src_port.hasArcToDestination(dest_port):
102-
if src_port.canConnect(dest_port):
102+
if src_port.can_connect(dest_port):
103103
command = CommandAdd(self.scene(), Arc(src_port, dest_port))
104104
self._undoStack.push(command)
105105
else:

0 commit comments

Comments
 (0)