|
15 | 15 | # SPDX-License-Identifier: Apache-2.0 |
16 | 16 | # Copyright (c) OWASP Foundation. All Rights Reserved. |
17 | 17 |
|
18 | | -"""Representation of this very python library.""" |
| 18 | +"""Representation of this very python library. |
19 | 19 |
|
20 | | -__all__ = ['this_component', 'this_tool', ] |
| 20 | +.. deprecated:: next |
| 21 | +""" |
21 | 22 |
|
22 | | -from .. import __version__ as __ThisVersion # noqa: N812 |
23 | | -from ..model import ExternalReference, ExternalReferenceType, XsUri |
24 | | -from ..model.component import Component, ComponentType |
25 | | -from ..model.license import DisjunctiveLicense, LicenseAcknowledgement |
26 | | -from ..model.tool import Tool |
| 23 | +__all__ = ['this_component', 'this_tool'] |
27 | 24 |
|
28 | | -# !!! keep this file in sync with `pyproject.toml` |
| 25 | +import sys |
| 26 | +from typing import TYPE_CHECKING |
29 | 27 |
|
| 28 | +if sys.version_info >= (3, 13): |
| 29 | + from warnings import deprecated |
| 30 | +else: |
| 31 | + from typing_extensions import deprecated |
30 | 32 |
|
31 | | -def this_component() -> Component: |
32 | | - """Representation of this very python library as a :class:`Component`.""" |
33 | | - return Component( |
34 | | - type=ComponentType.LIBRARY, |
35 | | - group='CycloneDX', |
36 | | - name='cyclonedx-python-lib', |
37 | | - version=__ThisVersion or 'UNKNOWN', |
38 | | - description='Python library for CycloneDX', |
39 | | - licenses=(DisjunctiveLicense(id='Apache-2.0', |
40 | | - acknowledgement=LicenseAcknowledgement.DECLARED),), |
41 | | - external_references=( |
42 | | - # let's assume this is not a fork |
43 | | - ExternalReference( |
44 | | - type=ExternalReferenceType.WEBSITE, |
45 | | - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/#readme') |
46 | | - ), |
47 | | - ExternalReference( |
48 | | - type=ExternalReferenceType.DOCUMENTATION, |
49 | | - url=XsUri('https://cyclonedx-python-library.readthedocs.io/') |
50 | | - ), |
51 | | - ExternalReference( |
52 | | - type=ExternalReferenceType.VCS, |
53 | | - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib') |
54 | | - ), |
55 | | - ExternalReference( |
56 | | - type=ExternalReferenceType.BUILD_SYSTEM, |
57 | | - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/actions') |
58 | | - ), |
59 | | - ExternalReference( |
60 | | - type=ExternalReferenceType.ISSUE_TRACKER, |
61 | | - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/issues') |
62 | | - ), |
63 | | - ExternalReference( |
64 | | - type=ExternalReferenceType.LICENSE, |
65 | | - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE') |
66 | | - ), |
67 | | - ExternalReference( |
68 | | - type=ExternalReferenceType.RELEASE_NOTES, |
69 | | - url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md') |
70 | | - ), |
71 | | - # we cannot assert where the lib was fetched from, but we can give a hint |
72 | | - ExternalReference( |
73 | | - type=ExternalReferenceType.DISTRIBUTION, |
74 | | - url=XsUri('https://pypi.org/project/cyclonedx-python-lib/') |
75 | | - ), |
76 | | - ), |
77 | | - # to be extended... |
78 | | - ) |
| 33 | +from ..contrib.this.builders import this_component as _this_component, this_tool as _this_tool |
79 | 34 |
|
| 35 | +# region deprecated re-export |
80 | 36 |
|
81 | | -def this_tool() -> Tool: |
82 | | - """Representation of this very python library as a :class:`Tool`.""" |
83 | | - return Tool.from_component(this_component()) |
| 37 | +if TYPE_CHECKING: |
| 38 | + from ..model.component import Component |
| 39 | + from ..model.tool import Tool |
| 40 | + |
| 41 | + |
| 42 | +@deprecated('Deprecated re-export location - see docstring of "this_component" for details.') |
| 43 | +def this_component() -> 'Component': |
| 44 | + """Deprecated — Alias of :func:`cyclonedx.contrib.this.builders.this_component`. |
| 45 | +
|
| 46 | + .. deprecated:: next |
| 47 | + This re-export location is deprecated. |
| 48 | + Use ``from cyclonedx.contrib.this.builders import this_component`` instead. |
| 49 | + The exported symbol itself is NOT deprecated — only this import path. |
| 50 | + """ |
| 51 | + return _this_component() |
| 52 | + |
| 53 | + |
| 54 | +@deprecated('Deprecated re-export location - see docstring of "this_tool" for details.') |
| 55 | +def this_tool() -> 'Tool': |
| 56 | + """Deprecated — Alias of :func:`cyclonedx.contrib.this.builders.this_tool`. |
| 57 | +
|
| 58 | + .. deprecated:: next |
| 59 | + This re-export location is deprecated. |
| 60 | + Use ``from cyclonedx.contrib.this.builders import this_tool`` instead. |
| 61 | + The exported symbol itself is NOT deprecated — only this import path. |
| 62 | + """ |
| 63 | + return _this_tool() |
| 64 | + |
| 65 | +# endregion deprecated re-export |
0 commit comments