Skip to content

Commit

Permalink
Merge pull request fosslight#162 from SeongjunJo/amend_exclude
Browse files Browse the repository at this point in the history
Amend exclude option
  • Loading branch information
soimkim authored Jun 24, 2024
2 parents 1301aa5 + 91337ea commit 2a5cd7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/fosslight_source/run_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,23 @@ def run_scan(path_to_scan, output_file_name="",
pretty_params["path_to_exclude"] = path_to_exclude
pretty_params["output_file"] = output_file_name
total_files_to_excluded = []

if path_to_exclude:
target_path = os.path.basename(path_to_scan) if os.path.isabs(path_to_scan) else path_to_scan

for path in path_to_exclude:
path = os.path.join(path_to_scan, path)
if os.path.isdir(path):
for root, _, files in os.walk(path):
exclude_path = path
isabs_exclude = os.path.isabs(path)
if isabs_exclude:
exclude_path = os.path.relpath(path, os.path.abspath(path_to_scan))

exclude_path = os.path.join(target_path, exclude_path)
if os.path.isdir(exclude_path):
for root, _, files in os.walk(exclude_path):
total_files_to_excluded.extend([os.path.normpath(os.path.join(root, file)).replace("\\", "/")
for file in files])
elif os.path.isfile(path):
total_files_to_excluded.append(os.path.normpath(path).replace("\\", "/"))
elif os.path.isfile(exclude_path):
total_files_to_excluded.append(os.path.normpath(exclude_path).replace("\\", "/"))

rc, results = cli.run_scan(path_to_scan, max_depth=100,
strip_root=True, license=True,
Expand Down
3 changes: 2 additions & 1 deletion src/fosslight_source/run_scanoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def run_scanoss_py(path_to_scan, output_file_name="", format="", called_by_cli=F
total_files_to_excluded = []
if path_to_exclude:
for path in path_to_exclude:
path = os.path.join(path_to_scan, path)
path = os.path.join(path_to_scan, os.path.relpath(path, os.path.abspath(path_to_scan))) \
if not os.path.isabs(path_to_scan) and os.path.isabs(path) else os.path.join(path_to_scan, path)
if os.path.isdir(path):
for root, _, files in os.walk(path):
root = root[len(path_to_scan) + 1:]
Expand Down

0 comments on commit 2a5cd7e

Please sign in to comment.