File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1010from ogc .bblocks import mimetypes
1111from ogc .bblocks .models import BuildingBlock , TransformMetadata , BuildingBlockError
1212from ogc .bblocks .transformers import transformers
13+ from ogc .bblocks .util import sanitize_filename
1314
1415
1516def apply_transforms (bblock : BuildingBlock ,
@@ -78,8 +79,12 @@ def apply_transforms(bblock: BuildingBlock,
7879 if snippet_mime_type not in supported_input_media_types :
7980 continue
8081
81- output_fn = output_dir / (f"example_{ example_id + 1 } _{ snippet_id + 1 } "
82- f".{ transform ['id' ]} { default_suffix } " )
82+ if base_output_filename := example .get ('base-output-filename' ):
83+ output_fn = output_dir / sanitize_filename (base_output_filename )
84+ output_fn = output_fn .with_name (f"{ output_fn .stem } .{ transform ['id' ]} { default_suffix } " )
85+ else :
86+ output_fn = output_dir / (f"example_{ example_id + 1 } _{ snippet_id + 1 } "
87+ f".{ transform ['id' ]} { default_suffix } " )
8388
8489 metadata = transform .get ('metadata' , {})
8590 metadata ['_prefixes' ] = example_prefixes
Original file line number Diff line number Diff line change @@ -316,10 +316,10 @@ def validate_test_resources(bblock: BuildingBlock,
316316 add_snippets_formats = []
317317
318318 extension = FORMAT_ALIASES .get (snippet ['language' ], snippet ['language' ]).replace ('/' , '.' )
319- fn = bblock .files_path / (f"example_{ example_id + 1 } _{ snippet_id + 1 } "
320- f".{ extension } " )
319+ fn = bblock .files_path / f"example_{ example_id + 1 } _{ snippet_id + 1 } "
321320
322- output_fn = output_dir / sanitize_filename (example .get ('base-output-filename' , fn .name ))
321+ output_fn = (output_dir .joinpath (sanitize_filename (example .get ('base-output-filename' , fn .name )))
322+ .with_suffix (f'.{ extension } ' ))
323323 i = 0
324324 while output_fn .stem in output_base_filenames :
325325 i += 1
You can’t perform that action at this time.
0 commit comments