generated from aboutcode-org/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to get resolved packages in a requirements.txt file. Fixes #135 #160
Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,20 @@ def write_output_in_file(output, location): | |
return output | ||
|
||
|
||
def write_resolved_packages(package_list, requirements_file): | ||
""" | ||
Write the resolved package names and versions into ``requirements_file_path`` | ||
""" | ||
dependencies = package_list[0]["package_data"][0]["dependencies"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have implemented the checks for empty or corrupt |
||
resolved_packages = [] | ||
for dependency in dependencies: | ||
if dependency["is_resolved"]: | ||
arijitde92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
package = dependency["extracted_requirement"] | ||
arijitde92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
resolved_packages.append(package) | ||
arijitde92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for package in resolved_packages: | ||
requirements_file.write(package + "\n") | ||
|
||
|
||
class Candidate(NamedTuple): | ||
""" | ||
A candidate is a package that can be installed. | ||
|
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,28 @@ | ||
aboutcode-toolkit==7.0.2 | ||
attrs==21.4.0 | ||
beautifulsoup4==4.11.1 | ||
certifi==2022.5.18.1 | ||
charset-normalizer==2.0.12 | ||
click==8.0.4 | ||
colorama==0.4.4 | ||
commoncode==30.2.0 | ||
dparse2==0.6.1 | ||
idna==3.3 | ||
importlib-metadata==4.8.3 | ||
intbitset==3.0.1 | ||
packageurl-python==0.9.9 | ||
packaging==21.3 | ||
pip-requirements-parser==31.2.0 | ||
pkginfo2==30.0.0 | ||
pyparsing==3.0.9 | ||
PyYAML==6.0 | ||
requests==2.27.1 | ||
resolvelib==0.8.1 | ||
saneyaml==0.5.2 | ||
soupsieve==2.3.2.post1 | ||
text-unidecode==1.3 | ||
toml==0.10.2 | ||
typing==3.6.6 | ||
typing_extensions==4.1.1 | ||
urllib3==1.26.9 | ||
zipp==3.6.0 |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arijitde92 please add a separate unit test for this function, separated from CLI logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TG1999 , I have written an unit test in test_cli.py (See here). Do I need to write another unit test elsewhere (maybe in test_utils.py?)?
Also could you please clarify what "separated from CLI logic" means?
I assume that you mean to test for a valid
package_list
. In that case do I need to create a dummypackage_list
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @TG1999 , could you please help in clarifying what kind of unit test you need? And in which while should I write the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arijitde92 yes, please write a test in
test_utils.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have written two unit tests in
test_utils.py
. Please check.