Skip to content

Commit 9940cf9

Browse files
committed
refactor: simplify .builder.this.this_tool
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent cf5d2c7 commit 9940cf9

File tree

1 file changed

+41
-59
lines changed

1 file changed

+41
-59
lines changed

cyclonedx/builder/this.py

Lines changed: 41 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515

1616
"""Representation of this very python library."""
1717

18-
__all__ = ['this_tool', 'this_component']
19-
20-
from typing import Iterable
18+
__all__ = ['this_component', 'this_tool', ]
2119

2220
from .. import __version__ as __ThisVersion # noqa: N812
2321
from ..model import ExternalReference, ExternalReferenceType, XsUri
@@ -27,63 +25,9 @@
2725

2826
# !!! keep this file in sync with `pyproject.toml`
2927

30-
# !!!
31-
# things in here are built on demand, rather than using prepared frozen constants.
32-
# this is currently a draft and may change in the future.
33-
# !!!
34-
35-
36-
def __ext_refs() -> Iterable[ExternalReference]:
37-
return (
38-
ExternalReference(
39-
type=ExternalReferenceType.BUILD_SYSTEM,
40-
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/actions')
41-
),
42-
ExternalReference(
43-
type=ExternalReferenceType.DISTRIBUTION,
44-
url=XsUri('https://pypi.org/project/cyclonedx-python-lib/')
45-
),
46-
ExternalReference(
47-
type=ExternalReferenceType.DOCUMENTATION,
48-
url=XsUri('https://cyclonedx-python-library.readthedocs.io/')
49-
),
50-
ExternalReference(
51-
type=ExternalReferenceType.ISSUE_TRACKER,
52-
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/issues')
53-
),
54-
ExternalReference(
55-
type=ExternalReferenceType.LICENSE,
56-
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE')
57-
),
58-
ExternalReference(
59-
type=ExternalReferenceType.RELEASE_NOTES,
60-
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md')
61-
),
62-
ExternalReference(
63-
type=ExternalReferenceType.VCS,
64-
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib')
65-
),
66-
ExternalReference(
67-
type=ExternalReferenceType.WEBSITE,
68-
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/#readme')
69-
),
70-
)
71-
72-
73-
def this_tool() -> Tool:
74-
"""Representation of this very python library as a :class:`Tool`."""
75-
76-
return Tool(
77-
vendor='CycloneDX',
78-
name='cyclonedx-python-lib',
79-
version=__ThisVersion or 'UNKNOWN',
80-
external_references=__ext_refs(),
81-
)
82-
8328

8429
def this_component() -> Component:
8530
"""Representation of this very python library as a :class:`Component`."""
86-
8731
return Component(
8832
type=ComponentType.LIBRARY,
8933
group='CycloneDX',
@@ -92,6 +36,44 @@ def this_component() -> Component:
9236
description='Python library for CycloneDX',
9337
licenses=(DisjunctiveLicense(id='Apache-2.0',
9438
acknowledgement=LicenseAcknowledgement.DECLARED),),
95-
external_references=__ext_refs(),
96-
# to be expanded ...
39+
external_references=(
40+
ExternalReference(
41+
type=ExternalReferenceType.BUILD_SYSTEM,
42+
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/actions')
43+
),
44+
ExternalReference(
45+
type=ExternalReferenceType.DISTRIBUTION,
46+
url=XsUri('https://pypi.org/project/cyclonedx-python-lib/')
47+
),
48+
ExternalReference(
49+
type=ExternalReferenceType.DOCUMENTATION,
50+
url=XsUri('https://cyclonedx-python-library.readthedocs.io/')
51+
),
52+
ExternalReference(
53+
type=ExternalReferenceType.ISSUE_TRACKER,
54+
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/issues')
55+
),
56+
ExternalReference(
57+
type=ExternalReferenceType.LICENSE,
58+
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE')
59+
),
60+
ExternalReference(
61+
type=ExternalReferenceType.RELEASE_NOTES,
62+
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md')
63+
),
64+
ExternalReference(
65+
type=ExternalReferenceType.VCS,
66+
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib')
67+
),
68+
ExternalReference(
69+
type=ExternalReferenceType.WEBSITE,
70+
url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/#readme')
71+
),
72+
),
73+
# to be extended...
9774
)
75+
76+
77+
def this_tool() -> Tool:
78+
"""Representation of this very python library as a :class:`Tool`."""
79+
return Tool.from_component(this_component())

0 commit comments

Comments
 (0)