55import os
66import io
77import sys
8- import platform
8+ import re
99import yaml
1010import fnmatch
1111import xml .etree .ElementTree as ET
1212import logging
1313import fosslight_util .constant as constant
14- import re
1514from pathlib import Path
1615from reuse .project import Project
1716from fosslight_prechecker ._result_html import result_for_html
2524MSG_FOLLOW_LIC_TXT = "Follow the Copyright and License Writing Rules in Source Code. : " + RULE_LINK
2625EX_IOERR = 74
2726logger = logging .getLogger (constant .LOGGER_NAME )
28- is_windows = platform .system () == 'Windows'
2927
3028
3129class ResultItem :
@@ -211,8 +209,7 @@ def create_result_file(output_file_name, format='', _start_time=""):
211209
212210def 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