|
7 | 7 | import shutil |
8 | 8 | import logging |
9 | 9 | import locale |
| 10 | +import platform |
10 | 11 | import re |
11 | 12 | from datetime import datetime |
12 | 13 | from binaryornot.check import is_binary |
|
19 | 20 | from fosslight_prechecker._result import write_result_file, create_result_file, result_for_summary, ResultItem |
20 | 21 | from fosslight_prechecker._constant import DEFAULT_EXCLUDE_EXTENSION, OSS_PKG_INFO_FILES |
21 | 22 |
|
| 23 | +is_windows = platform.system() == 'Windows' |
22 | 24 | PKG_NAME = "fosslight_prechecker" |
23 | 25 | REUSE_CONFIG_FILE = ".reuse/dep5" |
24 | 26 | DEFAULT_EXCLUDE_EXTENSION_FILES = [] # Exclude files from reuse |
@@ -46,10 +48,14 @@ def find_oss_pkg_info(path): |
46 | 48 | or file_lower_case.startswith("module_license_"): |
47 | 49 | oss_pkg_info.append(file_rel_path) |
48 | 50 | elif is_binary(file_abs_path): |
| 51 | + if is_windows: |
| 52 | + file_rel_path = file_rel_path.replace(os.sep, '/') |
49 | 53 | DEFAULT_EXCLUDE_EXTENSION_FILES.append(file_rel_path) |
50 | 54 | else: |
51 | 55 | extension = file_lower_case.split(".")[-1] |
52 | 56 | if extension in DEFAULT_EXCLUDE_EXTENSION: |
| 57 | + if is_windows: |
| 58 | + file_rel_path = file_rel_path.replace(os.sep, '/') |
53 | 59 | DEFAULT_EXCLUDE_EXTENSION_FILES.append(file_rel_path) |
54 | 60 |
|
55 | 61 | except Exception as ex: |
@@ -122,10 +128,14 @@ def precheck_for_files(path, files): |
122 | 128 | try: |
123 | 129 | file_abs_path = os.path.join(path, file) |
124 | 130 | if not os.path.isfile(file_abs_path) or is_binary(file_abs_path): |
| 131 | + if is_windows: |
| 132 | + file = file.replace(os.sep, '/') |
125 | 133 | DEFAULT_EXCLUDE_EXTENSION_FILES.append(file) |
126 | 134 | else: |
127 | 135 | extension = file.split(".")[-1] |
128 | 136 | if extension in DEFAULT_EXCLUDE_EXTENSION: |
| 137 | + if is_windows: |
| 138 | + file = file.replace(os.sep, '/') |
129 | 139 | DEFAULT_EXCLUDE_EXTENSION_FILES.append(file) |
130 | 140 | else: |
131 | 141 | logger.info(f"# {file}") |
|
0 commit comments