diff --git a/src/harvesters/core.py b/src/harvesters/core.py index 2643caa..c36ee4b 100644 --- a/src/harvesters/core.py +++ b/src/harvesters/core.py @@ -64,6 +64,7 @@ # Local application/library specific imports from harvesters._private.core.port import ConcretePort from harvesters._private.core.statistics import Statistics +from harvesters._private.core.helper.system import is_running_on_windows from harvesters.util.logging import get_logger from harvesters.util.pfnc import dict_by_names, dict_by_ints from harvesters.util.pfnc import Dictionary, _PixelFormat @@ -1889,6 +1890,8 @@ def _retrieve_file_path( elif location == 'file': file_path_to_load = urlparse(url).path + if is_running_on_windows(): + file_path_to_load = re.sub(r'^/+', '', file_path_to_load) elif location == 'http' or location == 'https': raise NotImplementedError( diff --git a/src/harvesters/test/test_harvester_core.py b/src/harvesters/test/test_harvester_core.py index ed7e5a7..43f4480 100644 --- a/src/harvesters/test/test_harvester_core.py +++ b/src/harvesters/test/test_harvester_core.py @@ -36,6 +36,7 @@ import numpy as np # Local application/library specific imports +from harvesters._private.core.helper.system import is_running_on_windows from harvesters.test.base_harvester import TestHarvester, \ TestHarvesterNoCleanUp from harvesters.test.base_harvester import get_cti_file_path @@ -1045,6 +1046,16 @@ def test_issue_207(self): ) self.assertEqual(data, result) + def test_issue_277(self): + if not is_running_on_windows(): + return + + prefix = 'file:///' + path = 'C:/ProgramData/GenICam/xml/cache/Optronis_Cyclone_V1_7_8.xml' + url = prefix + path + result = ImageAcquirer._retrieve_file_path(url=url) + self.assertEqual(path, result) + if __name__ == '__main__': unittest.main()