[clean] fix variable names and typos

* node_factory & attribute_factory to camelCase
* fix depths variable in updateNodesTopologicalData
This commit is contained in:
Yann Lanthony 2018-07-26 12:02:47 +02:00
parent 3615f641fd
commit 93dd055f72
6 changed files with 22 additions and 22 deletions

View file

@ -8,7 +8,7 @@ from meshroom.common import BaseObject, Property, Variant, Signal, ListModel, Di
from meshroom.core import desc, pyCompatibility, hashValue
def attribute_factory(description, value, isOutput, node, root=None, parent=None):
def attributeFactory(description, value, isOutput, node, root=None, parent=None):
"""
Create an Attribute based on description type.
@ -269,7 +269,7 @@ class ListAttribute(Attribute):
@raiseIfLink
def insert(self, index, value):
values = value if isinstance(value, list) else [value]
attrs = [attribute_factory(self.attributeDesc.elementDesc, v, self.isOutput, self.node, self) for v in values]
attrs = [attributeFactory(self.attributeDesc.elementDesc, v, self.isOutput, self.node, self) for v in values]
self._value.insert(index, attrs)
self.valueChanged.emit()
self._applyExpr()
@ -347,7 +347,7 @@ class GroupAttribute(Attribute):
subAttributes = []
for subAttrDesc in self.attributeDesc.groupDesc:
childAttr = attribute_factory(subAttrDesc, None, self.isOutput, self.node, self)
childAttr = attributeFactory(subAttrDesc, None, self.isOutput, self.node, self)
subAttributes.append(childAttr)
childAttr.valueChanged.connect(self.valueChanged)

View file

@ -15,7 +15,7 @@ import meshroom.core
from meshroom.common import BaseObject, DictModel, Slot, Signal, Property
from meshroom.core.attribute import Attribute, ListAttribute
from meshroom.core.exception import StopGraphVisit, StopBranchVisit
from meshroom.core.node import node_factory, Status, Node, CompatibilityNode
from meshroom.core.node import nodeFactory, Status, Node, CompatibilityNode
# Replace default encoder to support Enums
@ -219,7 +219,7 @@ class Graph(BaseObject):
# 3. fallback to no version "0.0": retro-compatibility
if "version" not in nodeData:
nodeData["version"] = nodesVersions.get(nodeData["nodeType"], "0.0")
n = node_factory(nodeData, nodeName)
n = nodeFactory(nodeData, nodeName)
# Add node to the graph with raw attributes values
self._addNode(n, nodeName)
@ -285,7 +285,7 @@ class Graph(BaseObject):
# create a new node of the same type and with the same attributes values
# keep links as-is so that CompatibilityNodes attributes can be created with correct automatic description
# (File params for link expressions)
node = node_factory(srcNode.toDict())
node = nodeFactory(srcNode.toDict(), srcNode.nodeType) # use nodeType as name
# skip edges: filter out attributes which are links by resetting default values
skippedEdges = {}
if not withEdges:
@ -740,14 +740,14 @@ class Graph(BaseObject):
currentVertex, inputVertex = edge
# update depths
du = self._nodesMinMaxDepths[currentVertex]
dv = self._nodesMinMaxDepths[inputVertex]
if du[0] == 0:
currentDepths = self._nodesMinMaxDepths[currentVertex]
inputDepths = self._nodesMinMaxDepths[inputVertex]
if currentDepths[0] == 0:
# if not initialized, set the depth of the first child
depthMin = dv[0] + 1
depthMin = inputDepths[0] + 1
else:
depthMin = min(du[0], dv[0] + 1)
self._nodesMinMaxDepths[currentVertex] = (depthMin, max(du[1], dv[1] + 1))
depthMin = min(currentDepths[0], inputDepths[0] + 1)
self._nodesMinMaxDepths[currentVertex] = (depthMin, max(currentDepths[1], inputDepths[1] + 1))
# update computability
if currentVertex.hasStatus(Status.SUCCESS):

View file

@ -16,7 +16,7 @@ from enum import Enum
import meshroom
from meshroom.common import Signal, Variant, Property, BaseObject, Slot, ListModel, DictModel
from meshroom.core import desc, stats, hashValue, pyCompatibility, nodeVersion, Version
from meshroom.core.attribute import attribute_factory, ListAttribute, GroupAttribute, Attribute
from meshroom.core.attribute import attributeFactory, ListAttribute, GroupAttribute, Attribute
from meshroom.core.exception import NodeUpgradeError, UnknownNodeTypeError
@ -600,10 +600,10 @@ class Node(BaseNode):
self._internalFolder = self.nodeDesc.internalFolder
for attrDesc in self.nodeDesc.inputs:
self._attributes.add(attribute_factory(attrDesc, None, False, self))
self._attributes.add(attributeFactory(attrDesc, None, False, self))
for attrDesc in self.nodeDesc.outputs:
self._attributes.add(attribute_factory(attrDesc, None, True, self))
self._attributes.add(attributeFactory(attrDesc, None, True, self))
# List attributes per uid
for attr in self._attributes:
@ -801,7 +801,7 @@ class CompatibilityNode(BaseNode):
matchDesc = attrDesc is not None
if not matchDesc:
attrDesc = CompatibilityNode.attributeDescFromValue(name, val, isOutput)
attribute = attribute_factory(attrDesc, val, isOutput, self)
attribute = attributeFactory(attrDesc, val, isOutput, self)
self._attributes.add(attribute)
return matchDesc
@ -858,7 +858,7 @@ class CompatibilityNode(BaseNode):
issueDetails = Property(str, issueDetails.fget, constant=True)
def node_factory(nodeDict, name=None):
def nodeFactory(nodeDict, name=None):
"""
Create a node instance by deserializing the given node data.
If the serialized data matches the corresponding node type description, a Node instance is created.

View file

@ -7,7 +7,7 @@ from PySide2.QtCore import Property, Signal
from meshroom.core.attribute import ListAttribute, Attribute
from meshroom.core.graph import GraphModification
from meshroom.core.node import node_factory
from meshroom.core.node import nodeFactory
class UndoCommand(QUndoCommand):
@ -126,7 +126,7 @@ class RemoveNodeCommand(GraphCommand):
def undoImpl(self):
with GraphModification(self.graph):
node = node_factory(self.nodeDict, self.nodeName)
node = nodeFactory(self.nodeDict, self.nodeName)
self.graph.addNode(node, self.nodeName)
assert (node.getName() == self.nodeName)
# recreate out edges deleted on node removal
@ -280,7 +280,7 @@ class UpgradeNodeCommand(GraphCommand):
self.graph.removeNode(self.nodeName)
# recreate compatibility node
with GraphModification(self.graph):
node = node_factory(self.nodeDict)
node = nodeFactory(self.nodeDict)
self.graph.addNode(node, self.nodeName)
# recreate out edges
for dstAttr, srcAttr in self.outEdges.items():

View file

@ -363,7 +363,7 @@ ApplicationWindow {
&& !_reconstruction.computing // computation is not started
&& _reconstruction.graph.canComputeLeaves // graph has no uncomputable nodes
// evalute if graph computation can be submitted externally
// evaluate if graph computation can be submitted externally
property bool canSubmit: canStartComputation // can be computed
&& _reconstruction.graph.filepath // graph is saved on disk

View file

@ -7,7 +7,7 @@ from PySide2.QtCore import QObject, Slot, Property, Signal
from meshroom import multiview
from meshroom.common.qt import QObjectListModel
from meshroom.core import Version
from meshroom.core.node import Node, node_factory, Status
from meshroom.core.node import Node, Status
from meshroom.ui.graph import UIGraph