-
-
Notifications
You must be signed in to change notification settings - Fork 86
feat: add unified tags mapping across environment builders #991
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ | |
| from .cli_common import add_argument_mc_type, add_argument_pyproject | ||
| from .utils.args import arparse_split | ||
| from .utils.cdx import make_bom | ||
| from .utils.packaging import normalize_packagename | ||
| from .utils.packaging import normalize_packagename, to_tags | ||
| from .utils.pyproject import pyproject_file2component | ||
| from .utils.secret import redact_auth_from_url | ||
|
|
||
|
|
@@ -175,6 +175,8 @@ def _make_bom(self, root_c: Optional['Component'], | |
| version=package_data['version'][2:] if 'version' in package_data else None, | ||
| external_references=self.__make_extrefs(package_name, package_data, source_urls), | ||
| ) | ||
| if hasattr(component, 'tags'): | ||
| component.tags.update(to_tags(package_data.get('keywords'))) | ||
|
||
| component.purl = PackageURL( | ||
| type=PurlTypePypi, | ||
| name=component.name, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,7 +34,7 @@ | |||||
| from . import BomBuilder, PropertyName, PurlTypePypi | ||||||
| from .cli_common import add_argument_mc_type | ||||||
| from .utils.cdx import make_bom | ||||||
| from .utils.packaging import normalize_packagename | ||||||
| from .utils.packaging import normalize_packagename, to_tags | ||||||
|
||||||
| from .utils.packaging import normalize_packagename, to_tags | |
| from .utils.packaging import normalize_packagename, metadata2tags |
Copilot
AI
Nov 7, 2025
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.
The function to_tags does not exist. Based on the implementation in utils/packaging.py, this should call metadata2tags. However, metadata2tags expects a PackageMetadata object, not a raw keywords value. A separate function needs to be created that accepts keywords as a string or list, or this code needs to be adjusted to match the actual function signature.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,22 @@ | |
| from ..py_interop.packagemetadata import PackageMetadata | ||
|
|
||
|
|
||
| _KEYWORDS_SPLIT_MATCHER = re_compile(r'[;, ]+') | ||
|
Member
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. let's discuss: why did you use a regular expression, instead of just splitting on comma( |
||
|
|
||
|
|
||
| def metadata2tags(metadata: 'PackageMetadata') -> Generator[str, None, None]: | ||
|
Member
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. |
||
| """ | ||
| Generate tags from metadata keywords. | ||
| """ | ||
| keywords_string = metadata.get('Keywords', '') | ||
| if keywords_string: | ||
| yield from ( | ||
|
Member
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. can this me simplified? filter(None, map(str.strip,
_KEYWORDS_SPLIT_MATCHER.split(keywords_string)
)) |
||
| tag | ||
| for tag in (s.strip() for s in _KEYWORDS_SPLIT_MATCHER.split(keywords_string)) | ||
| if tag | ||
| ) | ||
|
|
||
|
|
||
| def metadata2licenses(metadata: 'PackageMetadata', lfac: 'LicenseFactory', | ||
| gather_texts: bool | ||
| ) -> Generator['License', None, None]: | ||
|
|
||
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.
The imported function
to_tagsdoes not exist inutils.packaging. The actual function defined in that module ismetadata2tags. This will cause an ImportError at runtime.