mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-31 15:28:35 +02:00
[nodes] Publish: move filepaths resolution into a method
This commit is contained in:
parent
7631a824f1
commit
cdcc8df33e
1 changed files with 12 additions and 9 deletions
|
@ -30,6 +30,13 @@ class Publish(desc.Node):
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def resolvedPaths(self, inputFiles, outDir):
|
||||||
|
paths = {}
|
||||||
|
for inputFile in inputFiles:
|
||||||
|
for f in glob.glob(inputFile.value):
|
||||||
|
paths[f] = os.path.join(outDir, os.path.basename(f))
|
||||||
|
return paths
|
||||||
|
|
||||||
def processChunk(self, chunk):
|
def processChunk(self, chunk):
|
||||||
print("Publish")
|
print("Publish")
|
||||||
if not chunk.node.inputFiles:
|
if not chunk.node.inputFiles:
|
||||||
|
@ -38,19 +45,15 @@ class Publish(desc.Node):
|
||||||
if not chunk.node.output.value:
|
if not chunk.node.output.value:
|
||||||
return
|
return
|
||||||
|
|
||||||
inputFiles = []
|
outFiles = self.resolvedPaths(chunk.node.inputFiles, chunk.node.output.value)
|
||||||
for inputFile in chunk.node.inputFiles:
|
|
||||||
iFiles = glob.glob(inputFile.value)
|
if not outFiles:
|
||||||
inputFiles.extend(iFiles)
|
raise RuntimeError("Publish: input files listed, but nothing to publish. Listed input files: {}".format(chunk.node.inputFiles))
|
||||||
if not inputFiles:
|
|
||||||
raise RuntimeError("Publish: input files listed, but nothing to publish. Listed input files: {}".format(node.inputFiles))
|
|
||||||
|
|
||||||
if not os.path.exists(chunk.node.output.value):
|
if not os.path.exists(chunk.node.output.value):
|
||||||
os.mkdir(chunk.node.output.value)
|
os.mkdir(chunk.node.output.value)
|
||||||
|
|
||||||
for iFile in inputFiles:
|
for iFile, oFile in outFiles:
|
||||||
filename = os.path.basename(iFile)
|
|
||||||
oFile = os.path.join(chunk.node.output.value, filename)
|
|
||||||
print('Publish file', iFile, 'into', oFile)
|
print('Publish file', iFile, 'into', oFile)
|
||||||
shutil.copyfile(iFile, oFile)
|
shutil.copyfile(iFile, oFile)
|
||||||
print('Publish end')
|
print('Publish end')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue