Skip to content

Commit 2069ec3

Browse files
author
Kolea Plesco
committed
Updated mapping_suite files hasher
1 parent da88262 commit 2069ec3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ted_sws/mapping_suite_processor/adapters/mapping_suite_hasher.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
""" """
99
import hashlib
1010
import pathlib
11+
import re
1112
from typing import Tuple, List, Union
1213

1314
from ted_sws.data_manager.adapters.mapping_suite_repository import MS_TRANSFORM_FOLDER_NAME, \
@@ -35,7 +36,10 @@ def _hash_a_file(file_path: pathlib.Path) -> Tuple[str, str]:
3536
"""
3637
Return a tuple of the relative file path and the file hash.
3738
"""
38-
hashed_line = hashlib.sha256(file_path.read_bytes()).hexdigest()
39+
# remove new-lines to align content generated on different operating systems
40+
new_line_pattern = re.compile(b'\r\n|\r|\n')
41+
file_content = re.sub(new_line_pattern, b'', file_path.read_bytes())
42+
hashed_line = hashlib.sha256(file_content).hexdigest()
3943
relative_path = str(file_path).replace(str(self.mapping_suite_path), "")
4044
return relative_path, hashed_line
4145

0 commit comments

Comments
 (0)