Clean-up: PEP8 linting and quotes harmonization

This commit is contained in:
Candice Bentéjac 2025-05-22 12:02:16 +02:00
parent 777ed4207e
commit c16b56c7e3
4 changed files with 37 additions and 21 deletions

View file

@ -257,7 +257,8 @@ class Version:
status = '' status = ''
# If there is a status, it is placed after a "-" # If there is a status, it is placed after a "-"
splitComponents = versionName.split("-", maxsplit=1) splitComponents = versionName.split("-", maxsplit=1)
if (len(splitComponents) > 1): # If there is no status, splitComponents is equal to [versionName] # If there is no status, splitComponents is equal to [versionName]
if len(splitComponents) > 1:
status = splitComponents[-1] status = splitComponents[-1]
return tuple([int(v) for v in splitComponents[0].split(".")]), status return tuple([int(v) for v in splitComponents[0].split(".")]), status
@ -354,6 +355,7 @@ def loadPluginFolder(folder):
pluginManager.addPlugin(plugin) pluginManager.addPlugin(plugin)
pluginManager.registerPlugin(plugin.name) pluginManager.registerPlugin(plugin.name)
pipelineTemplates.update(plugin.templates) pipelineTemplates.update(plugin.templates)
return plugins return plugins
@ -404,7 +406,7 @@ def initSubmitters():
additionalPaths = EnvVar.getList(EnvVar.MESHROOM_SUBMITTERS_PATH) additionalPaths = EnvVar.getList(EnvVar.MESHROOM_SUBMITTERS_PATH)
allSubmittersFolders = [meshroomFolder] + additionalPaths allSubmittersFolders = [meshroomFolder] + additionalPaths
for folder in allSubmittersFolders: for folder in allSubmittersFolders:
subs = loadSubmitters(folder, 'submitters') subs = loadSubmitters(folder, "submitters")
for sub in subs: for sub in subs:
registerSubmitter(sub()) registerSubmitter(sub())
@ -413,7 +415,7 @@ def initPipelines():
# Load pipeline templates: check in the default folder and any folder the user might have # Load pipeline templates: check in the default folder and any folder the user might have
# added to the environment variable # added to the environment variable
additionalPipelinesPath = EnvVar.getList(EnvVar.MESHROOM_PIPELINE_TEMPLATES_PATH) additionalPipelinesPath = EnvVar.getList(EnvVar.MESHROOM_PIPELINE_TEMPLATES_PATH)
pipelineTemplatesFolders = [os.path.join(meshroomFolder, 'pipelines')] + additionalPipelinesPath pipelineTemplatesFolders = [os.path.join(meshroomFolder, "pipelines")] + additionalPipelinesPath
for f in pipelineTemplatesFolders: for f in pipelineTemplatesFolders:
loadPipelineTemplates(f) loadPipelineTemplates(f)
for plugin in pluginManager.getPlugins().values(): for plugin in pluginManager.getPlugins().values():
@ -422,6 +424,6 @@ def initPipelines():
def initPlugins(): def initPlugins():
additionalpluginsPath = EnvVar.getList(EnvVar.MESHROOM_PLUGINS_PATH) additionalpluginsPath = EnvVar.getList(EnvVar.MESHROOM_PLUGINS_PATH)
nodesFolders = [os.path.join(meshroomFolder, 'plugins')] + additionalpluginsPath nodesFolders = [os.path.join(meshroomFolder, "plugins")] + additionalpluginsPath
for f in nodesFolders: for f in nodesFolders:
loadPluginFolder(folder=f) loadPluginFolder(folder=f)

View file

@ -39,8 +39,10 @@ class BaseNode(object):
name="invalidation", name="invalidation",
label="Invalidation Message", label="Invalidation Message",
description="A message that will invalidate the node's output folder.\n" description="A message that will invalidate the node's output folder.\n"
"This is useful for development, we can invalidate the output of the node when we modify the code.\n" "This is useful for development, we can invalidate the output of the node "
"It is displayed in bold font in the invalidation/comment messages tooltip.", "when we modify the code.\n"
"It is displayed in bold font in the invalidation/comment messages "
"tooltip.",
value="", value="",
semantic="multiline", semantic="multiline",
advanced=True, advanced=True,
@ -50,7 +52,8 @@ class BaseNode(object):
name="comment", name="comment",
label="Comments", label="Comments",
description="User comments describing this specific node instance.\n" description="User comments describing this specific node instance.\n"
"It is displayed in regular font in the invalidation/comment messages tooltip.", "It is displayed in regular font in the invalidation/comment messages "
"tooltip.",
value="", value="",
semantic="multiline", semantic="multiline",
invalidate=False, invalidate=False,
@ -58,7 +61,8 @@ class BaseNode(object):
StringParam( StringParam(
name="label", name="label",
label="Node's Label", label="Node's Label",
description="Customize the default label (to replace the technical name of the node instance).", description="Customize the default label (to replace the technical name of the node "
"instance).",
value="", value="",
invalidate=False, invalidate=False,
), ),

View file

@ -123,13 +123,14 @@ class _NodeCreator:
def _checkAttributesAreCompatibleWithDescription(self) -> bool: def _checkAttributesAreCompatibleWithDescription(self) -> bool:
return ( return (
self._checkAttributesCompatibility(self.nodeDesc.inputs, self.inputs) self._checkAttributesCompatibility(self.nodeDesc.inputs, self.inputs)
and self._checkAttributesCompatibility(self.nodeDesc.internalInputs, self.internalInputs) and self._checkAttributesCompatibility(self.nodeDesc.internalInputs,
self.internalInputs)
and self._checkAttributesCompatibility(self.nodeDesc.outputs, self.outputs) and self._checkAttributesCompatibility(self.nodeDesc.outputs, self.outputs)
) )
def _checkInputAttributesNames(self) -> bool: def _checkInputAttributesNames(self) -> bool:
def serializedInput(attr: desc.Attribute) -> bool: def serializedInput(attr: desc.Attribute) -> bool:
"""Filter that excludes not-serialized desc input attributes.""" """ Filter that excludes not-serialized desc input attributes. """
if isinstance(attr, desc.PushButtonParam): if isinstance(attr, desc.PushButtonParam):
# PushButtonParam are not serialized has they do not hold a value. # PushButtonParam are not serialized has they do not hold a value.
return False return False
@ -140,7 +141,7 @@ class _NodeCreator:
def _checkOutputAttributesNames(self) -> bool: def _checkOutputAttributesNames(self) -> bool:
def serializedOutput(attr: desc.Attribute) -> bool: def serializedOutput(attr: desc.Attribute) -> bool:
"""Filter that excludes not-serialized desc output attributes.""" """ Filter that excludes not-serialized desc output attributes. """
if attr.isDynamicValue: if attr.isDynamicValue:
# Dynamic outputs values are not serialized with the node, # Dynamic outputs values are not serialized with the node,
# as their value is written in the computed output data. # as their value is written in the computed output data.

View file

@ -736,14 +736,16 @@ class Reconstruction(UIGraph):
""" """
if not startNode: if not startNode:
return None return None
nodes = self._graph.dfsOnDiscover(startNodes=[startNode], filterTypes=nodeTypes, reverse=True)[0] nodes = self._graph.dfsOnDiscover(startNodes=[startNode],
filterTypes=nodeTypes, reverse=True)[0]
if not nodes: if not nodes:
return None return None
# order the nodes according to their depth in the graph, then according to their name # order the nodes according to their depth in the graph, then according to their name
nodes.sort(key=lambda n: (n.depth, n.name)) nodes.sort(key=lambda n: (n.depth, n.name))
node = nodes[-1] node = nodes[-1]
if preferredStatus: if preferredStatus:
node = next((n for n in reversed(nodes) if n.getGlobalStatus() == preferredStatus), node) node = next((n for n in reversed(nodes)
if n.getGlobalStatus() == preferredStatus), node)
return node return node
def addSfmAugmentation(self, withMVS=False): def addSfmAugmentation(self, withMVS=False):
@ -800,7 +802,8 @@ class Reconstruction(UIGraph):
This method allows to reduce process time by doing it on Python side. This method allows to reduce process time by doing it on Python side.
Args: Args:
{images, videos, panoramaInfo, meshroomScenes, otherFiles}: Map containing the lists of paths for recognized images, videos, Meshroom scenes and other files. {images, videos, panoramaInfo, meshroomScenes, otherFiles}: Map containing the
lists of paths for recognized images, videos, Meshroom scenes and other files.
Node: cameraInit node used to add new images to it Node: cameraInit node used to add new images to it
QPoint: position to locate the node (usually the mouse position) QPoint: position to locate the node (usually the mouse position)
""" """
@ -821,7 +824,8 @@ class Reconstruction(UIGraph):
else: else:
p = position p = position
cameraInit = self.addNewNode("CameraInit", position=p) cameraInit = self.addNewNode("CameraInit", position=p)
self._workerThreads.apply_async(func=self.importImagesSync, args=(filesByType["images"], cameraInit,)) self._workerThreads.apply_async(func=self.importImagesSync,
args=(filesByType["images"], cameraInit,))
if filesByType["videos"]: if filesByType["videos"]:
if self.nodes: if self.nodes:
boundingBox = self.layout.boundingBox() boundingBox = self.layout.boundingBox()
@ -840,7 +844,8 @@ class Reconstruction(UIGraph):
newVideoNodeMessage, newVideoNodeMessage,
"Warning: You need to manually compute the KeyframeSelection node \n" "Warning: You need to manually compute the KeyframeSelection node \n"
"and then reimport the created images into Meshroom for the reconstruction.\n\n" "and then reimport the created images into Meshroom for the reconstruction.\n\n"
"If you know the Camera Make/Model, it is highly recommended to declare them in the Node." "If you know the Camera Make/Model, it is highly recommended to declare "
"them in the Node."
)) ))
if filesByType["panoramaInfo"]: if filesByType["panoramaInfo"]:
@ -848,15 +853,15 @@ class Reconstruction(UIGraph):
self.error.emit( self.error.emit(
Message( Message(
"Multiple XML files in input", "Multiple XML files in input",
"Ignore the xml Panorama files:\n\n'{}'.".format(',\n'.join(filesByType["panoramaInfo"])), "Ignore the XML Panorama files:\n\n'{}'.".format(',\n'.join(filesByType["panoramaInfo"])),
"", "",
)) ))
else: else:
panoramaInitNodes = self.graph.nodesOfType('PanoramaInit') panoramaInitNodes = self.graph.nodesOfType("PanoramaInit")
for panoramaInfoFile in filesByType["panoramaInfo"]: for panoramaInfoFile in filesByType["panoramaInfo"]:
for panoramaInitNode in panoramaInitNodes: for panoramaInitNode in panoramaInitNodes:
panoramaInitNode.attribute('initializeCameras').value = 'File' panoramaInitNode.attribute("initializeCameras").value = "File"
panoramaInitNode.attribute('config').value = panoramaInfoFile panoramaInitNode.attribute("config").value = panoramaInfoFile
if panoramaInitNodes: if panoramaInitNodes:
self.info.emit( self.info.emit(
Message( Message(
@ -918,7 +923,11 @@ class Reconstruction(UIGraph):
filesByType.extend(multiview.findFilesByTypeInFolder(localFile)) filesByType.extend(multiview.findFilesByTypeInFolder(localFile))
else: else:
filesByType.addFile(localFile) filesByType.addFile(localFile)
return {"images": filesByType.images, "videos": filesByType.videos, "panoramaInfo": filesByType.panoramaInfo, "meshroomScenes": filesByType.meshroomScenes, "other": filesByType.other} return {"images": filesByType.images,
"videos": filesByType.videos,
"panoramaInfo": filesByType.panoramaInfo,
"meshroomScenes": filesByType.meshroomScenes,
"other": filesByType.other}
def importImagesFromFolder(self, path, recursive=False): def importImagesFromFolder(self, path, recursive=False):
""" """