-
-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of --package-only
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
- Loading branch information
1 parent
66d7166
commit 44b2734
Showing
7 changed files
with
180 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,20 +248,21 @@ def get_licenses( | |
SCANCODE_DEBUG_PACKAGE_API = os.environ.get('SCANCODE_DEBUG_PACKAGE_API', False) | ||
|
||
|
||
def _get_package_data(location, application=True, system=False, **kwargs): | ||
def _get_package_data(location, application=True, system=False, package_only=False, **kwargs): | ||
""" | ||
Return a mapping of package manifest information detected in the file at ``location``. | ||
Include ``application`` packages (such as pypi) and/or ``system`` packages. | ||
Note that all exceptions are caught if there are any errors while parsing a | ||
package manifest. | ||
""" | ||
assert application or system | ||
assert application or system or package_only | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
AyanSinhaMahapatra
Author
Member
|
||
from packagedcode.recognize import recognize_package_data | ||
try: | ||
return recognize_package_data( | ||
location=location, | ||
application=application, | ||
system=system | ||
system=system, | ||
package_only=package_only, | ||
) or [] | ||
|
||
except Exception as e: | ||
|
@@ -291,7 +292,7 @@ def get_package_info(location, **kwargs): | |
return dict(packages=[p.to_dict() for p in packages]) | ||
|
||
|
||
def get_package_data(location, application=True, system=False, **kwargs): | ||
def get_package_data(location, application=True, system=False, package_only=False, **kwargs): | ||
""" | ||
Return a mapping of package manifest information detected in the file at | ||
`location`. | ||
|
@@ -304,6 +305,7 @@ def get_package_data(location, application=True, system=False, **kwargs): | |
location=location, | ||
application=application, | ||
system=system, | ||
package_only=package_only, | ||
**kwargs, | ||
) or [] | ||
|
||
|
113 changes: 113 additions & 0 deletions
113
tests/packagedcode/data/bower/scan-package-only-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"packages": [], | ||
"dependencies": [], | ||
"files": [ | ||
{ | ||
"path": "scan", | ||
"type": "directory", | ||
"package_data": [], | ||
"for_packages": [], | ||
"scan_errors": [] | ||
}, | ||
{ | ||
"path": "scan/bower.json", | ||
"type": "file", | ||
"package_data": [ | ||
{ | ||
"type": "bower", | ||
"namespace": null, | ||
"name": "John Doe", | ||
"version": null, | ||
"qualifiers": {}, | ||
"subpath": null, | ||
"primary_language": null, | ||
"description": "Physics-like animations for pretty particles", | ||
"release_date": null, | ||
"parties": [ | ||
{ | ||
"type": null, | ||
"role": "author", | ||
"name": "Betty Beta <[email protected]>", | ||
"email": null, | ||
"url": null | ||
}, | ||
{ | ||
"type": null, | ||
"role": "author", | ||
"name": "John Doe", | ||
"email": "[email protected]", | ||
"url": "http://johndoe.com" | ||
} | ||
], | ||
"keywords": [ | ||
"motion", | ||
"physics", | ||
"particles" | ||
], | ||
"homepage_url": null, | ||
"download_url": null, | ||
"size": null, | ||
"sha1": null, | ||
"md5": null, | ||
"sha256": null, | ||
"sha512": null, | ||
"bug_tracking_url": null, | ||
"code_view_url": null, | ||
"vcs_url": null, | ||
"copyright": null, | ||
"holder": null, | ||
"declared_license_expression": null, | ||
"declared_license_expression_spdx": null, | ||
"license_detections": [], | ||
"other_license_expression": null, | ||
"other_license_expression_spdx": null, | ||
"other_license_detections": [], | ||
"extracted_license_statement": "- MIT\n- Apache 2.0\n- BSD-3-Clause\n", | ||
"notice_text": null, | ||
"source_packages": [], | ||
"file_references": [], | ||
"extra_data": {}, | ||
"dependencies": [ | ||
{ | ||
"purl": "pkg:bower/get-size", | ||
"extracted_requirement": "~1.2.2", | ||
"scope": "dependencies", | ||
"is_runtime": true, | ||
"is_optional": false, | ||
"is_resolved": false, | ||
"resolved_package": {}, | ||
"extra_data": {} | ||
}, | ||
{ | ||
"purl": "pkg:bower/eventEmitter", | ||
"extracted_requirement": "~4.2.11", | ||
"scope": "dependencies", | ||
"is_runtime": true, | ||
"is_optional": false, | ||
"is_resolved": false, | ||
"resolved_package": {}, | ||
"extra_data": {} | ||
}, | ||
{ | ||
"purl": "pkg:bower/qunit", | ||
"extracted_requirement": "~1.16.0", | ||
"scope": "devDependencies", | ||
"is_runtime": false, | ||
"is_optional": true, | ||
"is_resolved": false, | ||
"resolved_package": {}, | ||
"extra_data": {} | ||
} | ||
], | ||
"repository_homepage_url": null, | ||
"repository_download_url": null, | ||
"api_data_url": null, | ||
"datasource_id": "bower_json", | ||
"purl": "pkg:bower/John%20Doe" | ||
} | ||
], | ||
"for_packages": [], | ||
"scan_errors": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These are not related at all IMHO, are they?