Skip to content

Commit

Permalink
Merge pull request #155 from fosslight/develop
Browse files Browse the repository at this point in the history
Fix to error about escape character
  • Loading branch information
bjk7119 authored May 21, 2024
2 parents 60cca81 + 74152d4 commit 9820c32
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/fosslight_prechecker/_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
import os
import io
import sys
import platform
import re
import yaml
import fnmatch
import xml.etree.ElementTree as ET
import logging
import fosslight_util.constant as constant
import re
from pathlib import Path
from reuse.project import Project
from fosslight_prechecker._result_html import result_for_html
Expand All @@ -25,7 +24,6 @@
MSG_FOLLOW_LIC_TXT = "Follow the Copyright and License Writing Rules in Source Code. : " + RULE_LINK
EX_IOERR = 74
logger = logging.getLogger(constant.LOGGER_NAME)
is_windows = platform.system() == 'Windows'


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

def get_path_in_yaml(oss_item):
path_in_yaml = [os.path.join(oss_item.relative_path, file) for file in oss_item.source_name_or_path]
if is_windows:
path_in_yaml = [path.replace(os.sep, '/') for path in path_in_yaml]
path_in_yaml = [path.replace('\\', '/') for path in path_in_yaml]
return path_in_yaml


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

for remove_pattern in remained_file_to_remove:
for file in remained_base_files[:]:
if fnmatch.fnmatch(file, remove_pattern) or re.search(remove_pattern, file):
extract_files.append(file)
remained_base_files.remove(file)
try:
for file in remained_base_files[:]:
if fnmatch.fnmatch(file, remove_pattern) or re.search(remove_pattern, file):
extract_files.append(file)
remained_base_files.remove(file)
except Exception as ex:
logger.info(f"Error to match pattern. Need to check the pattern({remove_pattern}) in yaml: {ex}")
return extract_files if return_found else remained_base_files


Expand Down

0 comments on commit 9820c32

Please sign in to comment.