mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
[bin] meshroom_batch: factorize input parrsing code
This commit is contained in:
parent
49479b3183
commit
ef73d769f6
1 changed files with 20 additions and 28 deletions
|
@ -107,40 +107,32 @@ with multiview.GraphModification(graph):
|
||||||
# custom pipeline
|
# custom pipeline
|
||||||
graph.load(args.pipeline, setupProjectFile=False, publishOutputs=True if args.output else False)
|
graph.load(args.pipeline, setupProjectFile=False, publishOutputs=True if args.output else False)
|
||||||
|
|
||||||
|
def parseInputs(inputs, uniqueInitNode):
|
||||||
|
"""Utility method for parsing the input and inputRecursive arguments."""
|
||||||
|
mapInputs = {}
|
||||||
|
for inp in inputs:
|
||||||
|
inputGroup = inp.split(':')
|
||||||
|
nodeName = None
|
||||||
|
if len(inputGroup) == 1 and uniqueInitNode:
|
||||||
|
nodeName = uniqueInitNode.getName()
|
||||||
|
elif len(inputGroup) == 2:
|
||||||
|
nodeName = inputGroup[0]
|
||||||
|
else:
|
||||||
|
print('Syntax error in input argument')
|
||||||
|
sys.exit(1)
|
||||||
|
nodeInputs = inputGroup[-1].split(';')
|
||||||
|
mapInputs[nodeName] = nodeInputs
|
||||||
|
return mapInputs
|
||||||
|
|
||||||
# get init nodes
|
# get init nodes
|
||||||
initNodes = graph.findInitNodes()
|
initNodes = graph.findInitNodes()
|
||||||
uniqueInitNode = (len(initNodes) == 1)
|
uniqueInitNode = initNodes[0] if (len(initNodes) == 1) else None
|
||||||
|
|
||||||
# parse inputs for each init node
|
# parse inputs for each init node
|
||||||
mapInput = {}
|
mapInput = parseInputs(args.input, uniqueInitNode)
|
||||||
for inp in args.input:
|
|
||||||
inputGroup = inp.split(':')
|
|
||||||
nodeName = None
|
|
||||||
if len(inputGroup) == 1 and uniqueInitNode:
|
|
||||||
nodeName = initNodes[0].getName()
|
|
||||||
elif len(inputGroup) == 2:
|
|
||||||
nodeName = inputGroup[0]
|
|
||||||
else:
|
|
||||||
print('Syntax error in input argument')
|
|
||||||
sys.exit(1)
|
|
||||||
nodeInputs = inputGroup[-1].split(';')
|
|
||||||
mapInput[nodeName] = nodeInputs
|
|
||||||
|
|
||||||
# parse recursive inputs for each init node
|
# parse recursive inputs for each init node
|
||||||
mapInputRecursive = {}
|
mapInputRecursive = parseInputs(args.inputRecursive, uniqueInitNode)
|
||||||
for inp in args.inputRecursive:
|
|
||||||
inputGroup = inp.split(':')
|
|
||||||
nodeName = None
|
|
||||||
if len(inputGroup) == 1 and uniqueInitNode:
|
|
||||||
nodeName = initNodes[0].getName()
|
|
||||||
elif len(inputGroup) == 2:
|
|
||||||
nodeName = inputGroup[0]
|
|
||||||
else:
|
|
||||||
print('Syntax error in inputRecursive argument')
|
|
||||||
sys.exit(1)
|
|
||||||
nodeName = inputGroup[0]
|
|
||||||
nodeInputs = inputGroup[-1].split(';')
|
|
||||||
mapInputRecursive[nodeName] = nodeInputs
|
|
||||||
|
|
||||||
# feed inputs and recursive inputs to init nodes
|
# feed inputs and recursive inputs to init nodes
|
||||||
for initNode in initNodes:
|
for initNode in initNodes:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue