From 5e42d51fce4cca4c0b97f9316d16ac8492acfd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Grenotton?= Date: Tue, 17 Mar 2026 21:24:53 +0100 Subject: [PATCH] Fix osm filename generation logic for no data sources --- pyhgtmap/output/factory.py | 6 +++--- tests/test_output_factory.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pyhgtmap/output/factory.py b/pyhgtmap/output/factory.py index 7003969..eed0ece 100644 --- a/pyhgtmap/output/factory.py +++ b/pyhgtmap/output/factory.py @@ -31,14 +31,14 @@ def make_osm_filename( for srcName in input_files_names ] for srcNameMiddle in set(srcNameMiddles): - if srcNameMiddle.lower()[:5] in ALL_SUPPORTED_SOURCES: - continue - elif not opts.dataSources: + if not opts.dataSources: # files from the command line, this could be something custom srcTag = ",".join(set(srcNameMiddles)) # osmName = hgt.makeBBoxString(borders).format(prefix) + "_{0:s}.osm".format(srcTag) osmName = hgt.makeBBoxString(borders).format(prefix) + "_local-source.osm" break + elif srcNameMiddle.lower()[:5] in ALL_SUPPORTED_SOURCES: + continue else: osmName = hgt.makeBBoxString(borders).format(prefix) + ".osm" break diff --git a/tests/test_output_factory.py b/tests/test_output_factory.py index e4820e5..8c142b0 100644 --- a/tests/test_output_factory.py +++ b/tests/test_output_factory.py @@ -324,3 +324,11 @@ def test_make_osm_filename_gzip_level_variations( assert result1 == result2 assert result1 == "lon0.00_1.00lat0.00_1.00_local-source.osm.gz" + + @staticmethod + def test_make_osm_filename_no_data_sources(sample_bbox, default_config) -> None: + """Test that function handles no dataSources with valid input files, matching usual data source patterns.""" + default_config.dataSources = [] + input_files = ["hgt/SRTM3/N00E000.hgt"] + result = make_osm_filename(sample_bbox, default_config, input_files) + assert result == "lon0.00_1.00lat0.00_1.00_local-source.osm"