@@ -198,7 +198,7 @@ def process_path(self, obj: Path) -> None:
198198 debug (f"Entering directory '{ obj } '" )
199199 os .makedirs (
200200 self .output , exist_ok = True
201- ) # FIXME: `Trees.output` vs `Expand.output_file`
201+ ) # FIXME: `Trees.output` vs `Expand.output_file() `
202202 for child in self .scandir (obj ):
203203 if child [0 ] != "." or self .process_hidden :
204204 self .process_path (obj / child )
@@ -231,7 +231,10 @@ class Expand:
231231 trees : Trees
232232 path : Path
233233 file_path : Path
234- _output_file : Optional [Path ]
234+
235+ # The output file relative to `trees.output`.
236+ # `None` while the filename is being expanded.
237+ _output_path : Optional [Path ]
235238
236239 # _stack is a list of filesystem `Path`s which are currently being
237240 # `$include`d. This is used to avoid infinite loops.
@@ -246,29 +249,29 @@ def __init__(
246249 self .trees = trees
247250 self .path = path
248251 self .file_path = file_path
249- self ._output_file = None
252+ self ._output_path = None
250253 self ._stack = []
251254 self ._macros = Macros (self )
252255
253- # Recompute `output_file ` by expanding `path`.
254- output_file = self .path .relative_to (self .trees .build_path )
255- if output_file .name != "" :
256- output_file = output_file .with_name (
257- re .sub (TEMPLATE_REGEX , "" , output_file .name )
256+ # Recompute `_output_path ` by expanding `path`.
257+ output_path = self .path .relative_to (self .trees .build_path )
258+ if output_path .name != "" :
259+ output_path = output_path .with_name (
260+ re .sub (TEMPLATE_REGEX , "" , output_path .name )
258261 )
259- output_file = os .fsdecode (self .expand (bytes (output_file )))
260- self ._output_file = self . trees . output / output_file
262+ output_path = os .fsdecode (self .expand (bytes (output_path )))
263+ self ._output_path = Path ( output_path )
261264
262265 def output_file (self ):
263266 """Returns the (computed) filesystem output `Path`.
264267
265268 Raises an error if called while the filename is being expanded.
266269 """
267- if self ._output_file is None :
270+ if self ._output_path is None :
268271 raise ValueError (
269272 "$outputfile is not available while expanding the filename"
270273 )
271- return self ._output_file
274+ return self .trees . output / self . _output_path
272275
273276 def find_on_path (self , start_path : Path , file : Path ) -> Optional [Path ]:
274277 """Search for file starting at the given path.
0 commit comments