File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 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'." )
You can’t perform that action at this time.
0 commit comments