Skip to content

Commit

Permalink
Fix for filename sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
abodeuis committed Jun 6, 2024
1 parent 0fc58b1 commit 4b61114
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pipeline_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def save_output(data_id, map_data: CMAAS_Map, output_dir, feedback_dir, output_t
continue
feature_mask = np.zeros_like(map_data.poly_segmentation_mask, dtype=np.uint8)
feature_mask[map_data.poly_segmentation_mask == legend_index] = 1
filepath = os.path.join(output_dir, sanitize_filename(f'{map_data.name}_{feature.label}.tif'))
filepath = os.path.join(output_dir, sanitize_filename(f'{map_data.name}_{feature.label}_{feature.type}.tif'))
io.saveGeoTiff(filepath, feature_mask, map_data.georef.crs, map_data.georef.transform)
legend_index += 1
return map_data.name
Expand Down
2 changes: 1 addition & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ def boundingBox(array):
return [min_xy, max_xy]

def sanitize_filename(filename, repl='□'):
return re.sub('[^0-9a-zA-Z _-]+', repl, filename).strip().replace(' ', '_')
return re.sub('[^0-9a-zA-Z ._-]+', repl, filename).strip().replace(' ', '_')

0 comments on commit 4b61114

Please sign in to comment.