Skip to content

Commit fff57a8

Browse files
authored
Merge pull request #109 from fosslight/develop
Fix bug in lint and add error for Windows
2 parents 086a273 + c29baad commit fff57a8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/fosslight_prechecker/_precheck.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import shutil
88
import logging
99
import locale
10+
import platform
1011
import re
1112
from datetime import datetime
1213
from binaryornot.check import is_binary
@@ -19,6 +20,7 @@
1920
from fosslight_prechecker._result import write_result_file, create_result_file, result_for_summary, ResultItem
2021
from fosslight_prechecker._constant import DEFAULT_EXCLUDE_EXTENSION, OSS_PKG_INFO_FILES
2122

23+
is_windows = platform.system() == 'Windows'
2224
PKG_NAME = "fosslight_prechecker"
2325
REUSE_CONFIG_FILE = ".reuse/dep5"
2426
DEFAULT_EXCLUDE_EXTENSION_FILES = [] # Exclude files from reuse
@@ -46,10 +48,14 @@ def find_oss_pkg_info(path):
4648
or file_lower_case.startswith("module_license_"):
4749
oss_pkg_info.append(file_rel_path)
4850
elif is_binary(file_abs_path):
51+
if is_windows:
52+
file_rel_path = file_rel_path.replace(os.sep, '/')
4953
DEFAULT_EXCLUDE_EXTENSION_FILES.append(file_rel_path)
5054
else:
5155
extension = file_lower_case.split(".")[-1]
5256
if extension in DEFAULT_EXCLUDE_EXTENSION:
57+
if is_windows:
58+
file_rel_path = file_rel_path.replace(os.sep, '/')
5359
DEFAULT_EXCLUDE_EXTENSION_FILES.append(file_rel_path)
5460

5561
except Exception as ex:
@@ -122,10 +128,14 @@ def precheck_for_files(path, files):
122128
try:
123129
file_abs_path = os.path.join(path, file)
124130
if not os.path.isfile(file_abs_path) or is_binary(file_abs_path):
131+
if is_windows:
132+
file = file.replace(os.sep, '/')
125133
DEFAULT_EXCLUDE_EXTENSION_FILES.append(file)
126134
else:
127135
extension = file.split(".")[-1]
128136
if extension in DEFAULT_EXCLUDE_EXTENSION:
137+
if is_windows:
138+
file = file.replace(os.sep, '/')
129139
DEFAULT_EXCLUDE_EXTENSION_FILES.append(file)
130140
else:
131141
logger.info(f"# {file}")

0 commit comments

Comments
 (0)