8000 Added convenience function to extract SPDX elements by their Id by HarshvMahawar · Pull Request #531 · spdx/tools-python · GitHub
[go: up one dir, main page]

Skip to content

Added convenience function to extract SPDX elements by their Id #531

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

Conversation

HarshvMahawar
Copy link
Contributor

No description provided.

@HarshvMahawar HarshvMahawar force-pushed the refactor-python-tools branch from 2a18110 to bc60bc9 Compare March 23, 2023 08:33
@HarshvMahawar HarshvMahawar marked this pull request as draft March 23, 2023 08:35
@HarshvMahawar HarshvMahawar marked this pull request as ready for review March 23, 2023 08:36
Copy link
Collaborator
@armintaenzertng armintaenzertng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! :)
If you like, you can also include a unit test for this under tests/spdx/test_document_utils.py. If not, I'm happy to include it after this PR is merged.



def get_contained_spdx_element_ids(document: Document) -> List[str]:
element_ids = [file.spdx_id for file in document.files]
element_ids.extend([package.spdx_id for package in document.packages])
element_ids.extend([snippet.spdx_id for snippet in document.snippets])
return element_ids
def get_element_from_spdx_id(document: Document, spdx_id: str) -> Union[Package, File, Snippet, None]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 requires two blank lines between methods.
Which IDE are you using for your python development? There might be a plugin for your IDE to detect PEP8 violations.

@armintaenzertng armintaenzertng linked an issue Mar 23, 2023 that may be closed by this pull request
@HarshvMahawar HarshvMahawar force-pushed the refactor-python-tools branch 2 times, most recently from 34b8bc8 to ecca0da Compare March 23, 2023 18:36
Signed-off-by: HarshvMahawar <hv062727@gmail.com>
Copy link
Collaborator
@armintaenzertng armintaenzertng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good! :)

@armintaenzertng armintaenzertng merged commit ea92a1c into spdx:refactor-python-tools Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add convenience function to extract SPDX elements by their Id
2 participants
0