From 7faab9b88637500158ba253a19fb86c6ca1956a7 Mon Sep 17 00:00:00 2001 From: Jiyeong Seok <50347670+dd-jy@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:08:22 +0900 Subject: [PATCH] Normalize pypi package name (PEP 0503) (#181) Signed-off-by: Jiyeong Seok --- src/fosslight_dependency/package_manager/Npm.py | 2 +- src/fosslight_dependency/package_manager/Pypi.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fosslight_dependency/package_manager/Npm.py b/src/fosslight_dependency/package_manager/Npm.py index 0bb04639..92bbf9a4 100644 --- a/src/fosslight_dependency/package_manager/Npm.py +++ b/src/fosslight_dependency/package_manager/Npm.py @@ -103,7 +103,7 @@ def parse_transitive_relationship(self): err_msg = '' cmd = 'npm ls -a --omit=dev --json -s' - result = subprocess.run(cmd, shell=True, capture_output=True, text=True) + result = subprocess.run(cmd, shell=True, capture_output=True, text=True, encoidng='utf-8') rel_tree = result.stdout if rel_tree is None: logger.error(f"It returns the error: {cmd}") diff --git a/src/fosslight_dependency/package_manager/Pypi.py b/src/fosslight_dependency/package_manager/Pypi.py index 6e865332..20a82e38 100644 --- a/src/fosslight_dependency/package_manager/Pypi.py +++ b/src/fosslight_dependency/package_manager/Pypi.py @@ -9,6 +9,7 @@ import json import shutil import copy +import re import fosslight_util.constant as constant import fosslight_dependency.constant as const from fosslight_dependency._package_manager import PackageManager @@ -267,6 +268,7 @@ def parse_oss_information(self, f_name): for d in json_data: oss_init_name = d['Name'] + oss_init_name = re.sub(r"[-_.]+", "-", oss_init_name).lower() oss_name = f"{self.package_manager_name}:{oss_init_name}" license_name = check_UNKNOWN(d['License']) homepage = check_UNKNOWN(d['URL'])