Skip to content

Commit 74152d4

Browse files
dd-jybjk7119
authored andcommitted
Fix to error about escape character
1 parent bb6772c commit 74152d4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/fosslight_prechecker/_result.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
import os
66
import io
77
import sys
8-
import platform
8+
import re
99
import yaml
1010
import fnmatch
1111
import xml.etree.ElementTree as ET
1212
import logging
1313
import fosslight_util.constant as constant
14-
import re
1514
from pathlib import Path
1615
from reuse.project import Project
1716
from fosslight_prechecker._result_html import result_for_html
@@ -25,7 +24,6 @@
2524
MSG_FOLLOW_LIC_TXT = "Follow the Copyright and License Writing Rules in Source Code. : " + RULE_LINK
2625
EX_IOERR = 74
2726
logger = logging.getLogger(constant.LOGGER_NAME)
28-
is_windows = platform.system() == 'Windows'
2927

3028

3129
class ResultItem:
@@ -211,8 +209,7 @@ def create_result_file(output_file_name, format='', _start_time=""):
211209

212210
def get_path_in_yaml(oss_item):
213211
path_in_yaml = [os.path.join(oss_item.relative_path, file) for file in oss_item.source_name_or_path]
214-
if is_windows:
215-
path_in_yaml = [path.replace(os.sep, '/') for path in path_in_yaml]
212+
path_in_yaml = [path.replace('\\', '/') for path in path_in_yaml]
216213
return path_in_yaml
217214

218215

@@ -228,10 +225,13 @@ def extract_files_in_path(remove_file_list, base_file_list, return_found=False):
228225
remained_file_to_remove = list(set(remove_file_list) - set(intersection_files))
229226

230227
for remove_pattern in remained_file_to_remove:
231-
for file in remained_base_files[:]:
232-
if fnmatch.fnmatch(file, remove_pattern) or re.search(remove_pattern, file):
233-
extract_files.append(file)
234-
remained_base_files.remove(file)
228+
try:
229+
for file in remained_base_files[:]:
230+
if fnmatch.fnmatch(file, remove_pattern) or re.search(remove_pattern, file):
231+
extract_files.append(file)
232+
remained_base_files.remove(file)
233+
except Exception as ex:
234+
logger.info(f"Error to match pattern. Need to check the pattern({remove_pattern}) in yaml: {ex}")
235235
return extract_files if return_found else remained_base_files
236236

237237

0 commit comments

Comments
 (0)