@@ -175,14 +175,15 @@ def process_file(self, base_file: Path, file_path: Path) -> None:
175175 base_file (Path): the `inputs`-relative `Path`
176176 file_path (Path): the filesystem input `Path`
177177 """
178- output_file = self .get_output_path (base_file , file_path )
179178 debug (f"Processing file '{ file_path } '" )
179+ output_file = self .get_output_path (base_file , file_path )
180+ os .makedirs (output_file .parent , exist_ok = True )
180181 if re .search (TEMPLATE_REGEX , file_path .name ):
181182 debug (f"Expanding '{ base_file } ' to '{ output_file } '" )
182183 text = file_path .read_bytes ()
183184 output = Expand (self , base_file , file_path , output_file ).expand_bytes (text )
184185 if not re .search (NO_COPY_REGEX , str (output_file )):
185- if output_file == Path ("-" ):
186+ if self . output_path == Path ("-" ):
186187 sys .stdout .buffer .write (output )
187188 else :
188189 with open (output_file , "wb" ) as fh :
@@ -204,11 +205,9 @@ def process_path(self, obj: Path) -> None:
204205 if dirent is None :
205206 raise ValueError (f"'{ obj } ' matches no path in the inputs" )
206207 if isinstance (dirent , list ):
207- output_dir = self .get_output_path (obj , obj )
208- if output_dir == Path ("-" ):
208+ if self .output_path == Path ("-" ):
209209 raise ValueError ("cannot output multiple files to stdout ('-')" )
210210 debug (f"Entering directory '{ obj } '" )
211- os .makedirs (output_dir , exist_ok = True )
212211 for child_dirent in dirent :
213212 if child_dirent .name [0 ] != "." :
214213 child_object = obj / child_dirent .name
0 commit comments