Skip to content

Commit a703788

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 a703788

File tree

1 file changed

+55
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)