Skip to content

Commit

Permalink
Use packages attribute throughout aboutcode-org#1237
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne authored and viragumathe5 committed Mar 12, 2020
1 parent 40f0c9d commit aa4550a
Show file tree
Hide file tree
Showing 1,252 changed files with 73,914 additions and 81,277 deletions.
2 changes: 1 addition & 1 deletion src/packagedcode/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_package_root(cls, manifest_resource, codebase):
if manifest_resource.name.endswith(('pom.xml', '.pom',)):
# the root is either the parent or further up for poms stored under
# a META-INF dir
package_data = manifest_resource.package_manifests
package_data = manifest_resource.packages
if not package_data:
return manifest_resource
package_data = package_data[0]
Expand Down
8 changes: 4 additions & 4 deletions src/packagedcode/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,10 @@ class Package(BasePackage):
label='notice text',
help='A notice text for this package.')

manifest_path = String(
label='manifest path',
help='A relative path to the manifest file if any, such as a '
'Maven .pom or a npm package.json.')
root_path = String(
label='package root path',
help='The path to the root of the package documented in this manifest '
'if any, such as a Maven .pom or a npm package.json parent directory.')

dependencies = List(
item_type=DependentPackage,
Expand Down
5 changes: 3 additions & 2 deletions src/scancode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,13 @@ def get_package_info(location, **kwargs):
try:
manifest = recognize_package(location)
if manifest:
return dict(package_manifests=[manifest.to_dict()])
# TODO: what if we have more than one package in a manifest?
return dict(packages=[manifest.to_dict()])
except Exception as e:
if TRACE:
logger.error('get_package_info: {}: Exception: {}'.format(location, e))
pass
return dict(package_manifests=[])
return dict(packages=[])


def get_file_info(location, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion tests/formattedcode/data/csv/livescan/expected.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Resource,type,name,base_name,extension,size,date,sha1,md5,mime_type,file_type,programming_language,is_binary,is_text,is_archive,is_media,is_source,is_script,files_count,dirs_count,size_count,scan_errors,license_expression,license__key,license__score,license__name,license__short_name,license__category,license__is_exception,license__owner,license__homepage_url,license__text_url,license__reference_url,license__spdx_license_key,license__spdx_url,start_line,end_line,matched_rule__identifier,matched_rule__license_expression,matched_rule__licenses,matched_rule__is_license_text,matched_rule__is_license_notice,matched_rule__is_license_reference,matched_rule__is_license_tag,matched_rule__matcher,matched_rule__rule_length,matched_rule__matched_length,matched_rule__match_coverage,matched_rule__rule_relevance,copyright,copyright_holder,email,url,package__type,package__namespace,package__name,package__version,package__qualifiers,package__subpath,package__primary_language,package__description,package__release_date,package__homepage_url,package__download_url,package__size,package__sha1,package__md5,package__sha256,package__sha512,package__bug_tracking_url,package__code_view_url,package__vcs_url,package__copyright,package__license_expression,package__declared_license,package__notice_text,package__manifest_path,package__contains_source_code
Resource,type,name,base_name,extension,size,date,sha1,md5,mime_type,file_type,programming_language,is_binary,is_text,is_archive,is_media,is_source,is_script,files_count,dirs_count,size_count,scan_errors,license_expression,license__key,license__score,license__name,license__short_name,license__category,license__is_exception,license__owner,license__homepage_url,license__text_url,license__reference_url,license__spdx_license_key,license__spdx_url,start_line,end_line,matched_rule__identifier,matched_rule__license_expression,matched_rule__licenses,matched_rule__is_license_text,matched_rule__is_license_notice,matched_rule__is_license_reference,matched_rule__is_license_tag,matched_rule__matcher,matched_rule__rule_length,matched_rule__matched_length,matched_rule__match_coverage,matched_rule__rule_relevance,copyright,copyright_holder,email,url,package__type,package__namespace,package__name,package__version,package__qualifiers,package__subpath,package__primary_language,package__description,package__release_date,package__homepage_url,package__download_url,package__size,package__sha1,package__md5,package__sha256,package__sha512,package__bug_tracking_url,package__code_view_url,package__vcs_url,package__copyright,package__license_expression,package__declared_license,package__notice_text,package__root_path,package__contains_source_code
json2csv.rb,file,json2csv.rb,json2csv,.rb,912,2018-11-15,1236469a06a2bacbdd8e172ad718482af5b0a936,1307c281e0b153202e291b217eab85d5,text/x-python,"Python script, ASCII text executable",Ruby,False,True,False,False,True,True,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
json2csv.rb,,,,,,,,,,,,,,,,,,,,,,apache-2.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
json2csv.rb,,,,,,,,,,,,,,,,,,,,,,,apache-2.0,100.00,Apache License 2.0,Apache 2.0,Permissive,False,Apache Software Foundation,http://www.apache.org/licenses/,http://www.apache.org/licenses/LICENSE-2.0,https://enterprise.dejacode.com/urn/urn:dje:license:apache-2.0,Apache-2.0,https://spdx.org/licenses/Apache-2.0,5,13,apache-2.0_7.RULE,apache-2.0,apache-2.0,,True,,,2-aho,85,85,100.00,100.00,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Expand Down
2 changes: 1 addition & 1 deletion tests/formattedcode/data/csv/packages/expected-no-root.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Resource,type,scan_errors,package__type,package__namespace,package__name,package__version,package__qualifiers,package__subpath,package__primary_language,package__description,package__release_date,package__homepage_url,package__download_url,package__size,package__sha1,package__md5,package__sha256,package__sha512,package__bug_tracking_url,package__code_view_url,package__vcs_url,package__copyright,package__license_expression,package__declared_license,package__notice_text,package__manifest_path,package__contains_source_code
Resource,type,scan_errors,package__type,package__namespace,package__name,package__version,package__qualifiers,package__subpath,package__primary_language,package__description,package__release_date,package__homepage_url,package__download_url,package__size,package__sha1,package__md5,package__sha256,package__sha512,package__bug_tracking_url,package__code_view_url,package__vcs_url,package__copyright,package__license_expression,package__declared_license,package__notice_text,package__root_path,package__contains_source_code
package.json,file,,,,,,,,,,,,,,,,,,,,,,,,,,
package.json,,,npm,,npm,v 2.13.5,,,JavaScript,a package manager for JavaScript,,https://docs.npmjs.com/,https://registry.npmjs.org/npm/-/npm-2.13.5.tgz,,a124386bce4a90506f28ad4b1d1a804a17baaf32,,,,http://github.com/npm/npm/issues,,git+https://github.com/npm/npm.git@fc7bbf03e39cc48a8924b90696d28345a6a90f3c,,artistic-2.0,Artistic-2.0,,,
2 changes: 0 additions & 2 deletions tests/formattedcode/data/json/simple-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"copyrights": [],
"holders": [],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 1,
"dirs_count": 0,
Expand Down Expand Up @@ -84,7 +83,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down
2 changes: 0 additions & 2 deletions tests/formattedcode/data/json/simple-expected.jsonpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"copyrights": [],
"holders": [],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 1,
"dirs_count": 0,
Expand Down Expand Up @@ -84,7 +83,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down
8 changes: 0 additions & 8 deletions tests/formattedcode/data/json/tree/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down Expand Up @@ -97,7 +96,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down Expand Up @@ -139,7 +137,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down Expand Up @@ -169,7 +166,6 @@
"copyrights": [],
"holders": [],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 4,
"dirs_count": 0,
Expand Down Expand Up @@ -211,7 +207,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down Expand Up @@ -253,7 +248,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down Expand Up @@ -295,7 +289,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down Expand Up @@ -337,7 +330,6 @@
}
],
"authors": [],
"package_manifests": [],
"packages": [],
"files_count": 0,
"dirs_count": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"license_expressions": [
"mit"
],
"package_manifests": [
"packages": [
{
"type": "npm",
"namespace": null,
Expand Down Expand Up @@ -102,7 +102,7 @@
}
],
"notice_text": null,
"manifest_path": null,
"root_path": null,
"dependencies": [
{
"purl": "pkg:npm/dicer",
Expand All @@ -129,7 +129,6 @@
"api_data_url": "https://registry.npmjs.org/busboy/0.2.14"
}
],
"packages": [],
"scan_errors": []
}
]
Expand Down
2 changes: 1 addition & 1 deletion tests/packagedcode/data/about/apipkg.ABOUT-expected
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"license_expression": "mit",
"declared_license": "mit",
"notice_text": null,
"manifest_path": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
Expand Down
2 changes: 1 addition & 1 deletion tests/packagedcode/data/about/appdirs.ABOUT-expected
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"license_expression": "mit",
"declared_license": "mit",
"notice_text": null,
"manifest_path": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
Expand Down
2 changes: 1 addition & 1 deletion tests/packagedcode/data/bower/author-objects/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"BSD-3-Clause"
],
"notice_text": null,
"manifest_path": null,
"root_path": null,
"dependencies": [
{
"purl": "pkg:bower/get-size",
Expand Down
2 changes: 1 addition & 1 deletion tests/packagedcode/data/bower/basic/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"MIT"
],
"notice_text": null,
"manifest_path": null,
"root_path": null,
"dependencies": [
{
"purl": "pkg:bower/get-size",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"BSD-3-Clause"
],
"notice_text": null,
"manifest_path": null,
"root_path": null,
"dependencies": [
{
"purl": "pkg:bower/get-size",
Expand Down
Loading

0 comments on commit aa4550a

Please sign in to comment.