Skip to content

Commit 4f5a6e3

Browse files
committed
[nodes] Add new InputFile input node
The node receives a file or directory as the input, and can be used as the entry point of a graph for `meshroom_batch`
1 parent 17b411c commit 4f5a6e3

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
__version__ = "1.0"
2+
3+
import logging
4+
import os
5+
6+
from meshroom.core import desc
7+
8+
class InputFile(desc.InputNode, desc.InitNode):
9+
"""
10+
This node is an input node that receives a File.
11+
"""
12+
category = "Other"
13+
14+
inputs = [
15+
desc.File(
16+
name="inputFile",
17+
label="Input File",
18+
description="A file or folder to use as the input.",
19+
value="",
20+
)
21+
]
22+
23+
def initialize(self, node, inputs, recursiveInputs):
24+
self.resetAttributes(node, ["inputFile"])
25+
26+
attributeSet = False
27+
if len(inputs) >= 1:
28+
for i in inputs:
29+
if os.path.isfile(i) or os.path.isdir(i):
30+
self.setAttributes(node, {"inputFile": i})
31+
attributeSet = True
32+
33+
if len(inputs) > 1:
34+
logging.warning(f"Several inputs were provided ({inputs}).")
35+
logging.warning(f"Only the first valid one ({i}) will be used.")
36+
37+
break
38+
else:
39+
logging.warning(f"{i} is not a valid file or directory.")
40+
41+
if not attributeSet and len(recursiveInputs) >= 1:
42+
for i in recursiveInputs:
43+
if os.path.isfile(i) or os.path.isdir(i):
44+
self.setAttributes(node, {"inputFile": i})
45+
attributeSet = True
46+
47+
if len(recursiveInputs) > 1:
48+
logging.warning(f"Several recursive inputs were provided ({recursiveInputs}).")
49+
logging.warning(f"Only the first valid one ({i}) will be used.")
50+
51+
break
52+
else:
53+
logging.warning(f"{i} is not a valid file or directory.")
54+
55+
if not attributeSet:
56+
logging.warning("No file has been set for 'inputFile'.")

0 commit comments

Comments
 (0)