Skip to content

Commit d75e86d

Browse files
committed
add header and code cleanup
Signed-off-by: NucleonGodX <[email protected]>
1 parent 14ba0ae commit d75e86d

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/packagedcode/componentjs.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/scancode-toolkit for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
110
import json
211
from packagedcode import models
312
from packageurl import PackageURL
@@ -7,7 +16,7 @@ class ComponentJSONMetadataHandler(models.NonAssemblableDatafileHandler):
716
"""
817
Handle component JSON metadata files for package analysis.
918
"""
10-
datasource_id = "json_metadata"
19+
datasource_id = "component_json_metadata"
1120
path_patterns = ("*component.json",)
1221
default_package_type = "library"
1322
description = "component JSON package metadata file"
@@ -43,15 +52,13 @@ def parse(cls, location, package_only=False):
4352
)
4453

4554
if namespace and name:
46-
try:
47-
package_data['purl'] = PackageURL(
48-
type='generic',
49-
namespace=namespace,
50-
name=name,
51-
version=package_data.get('version')
52-
).to_string()
53-
except Exception:
54-
pass
55+
package_data['purl'] = PackageURL(
56+
type='generic',
57+
namespace=namespace,
58+
name=name,
59+
version=package_data.get('version')
60+
).to_string()
61+
5562

5663
yield models.PackageData.from_data(package_data, package_only)
5764

tests/packagedcode/test_componentjs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/scancode-toolkit for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
110
import os
211
from packagedcode import models
312
from commoncode.testcase import FileBasedTesting
4-
from packageurl import PackageURL
513
from packages_test_utils import compare_package_results
614
from scancode.cli_test_utils import check_json_scan
715
from scancode.cli_test_utils import run_scan_click

0 commit comments

Comments
 (0)