Skip to content

Commit 562049c

Browse files
committed
feat: prepare "contrib" area
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 119690d commit 562049c

4 files changed

Lines changed: 115 additions & 27 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This file is part of CycloneDX Python Library
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
18+
19+
"""
20+
Exceptions relating to specific conditions that occur when factoring a model.
21+
"""
22+
23+
from ...exception import CycloneDxException
24+
25+
__all__ = ['FactoryException', 'LicenseChoiceFactoryException', 'InvalidSpdxLicenseException',
26+
'LicenseFactoryException', 'InvalidLicenseExpressionException']
27+
28+
29+
class FactoryException(CycloneDxException):
30+
"""
31+
Base exception that covers all exceptions that may be thrown during model factoring.
32+
"""
33+
pass
34+
35+
36+
class LicenseChoiceFactoryException(FactoryException):
37+
"""
38+
Base exception that covers all LicenseChoiceFactory exceptions.
39+
"""
40+
pass
41+
42+
43+
class InvalidSpdxLicenseException(LicenseChoiceFactoryException):
44+
"""
45+
Thrown when an invalid SPDX License is provided.
46+
"""
47+
pass
48+
49+
50+
class LicenseFactoryException(FactoryException):
51+
"""
52+
Base exception that covers all LicenseFactory exceptions.
53+
"""
54+
pass
55+
56+
57+
class InvalidLicenseExpressionException(LicenseFactoryException):
58+
"""
59+
Thrown when an invalid License expressions is provided.
60+
"""
61+
pass

cyclonedx/contrib/license/factories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
from typing import TYPE_CHECKING, Optional
2121

22-
from ...exception.factory import InvalidLicenseExpressionException, InvalidSpdxLicenseException
2322
from ...model.license import DisjunctiveLicense, LicenseExpression
2423
from ...spdx import fixup_id as spdx_fixup, is_expression as is_spdx_expression
24+
from .exceptions import InvalidLicenseExpressionException, InvalidSpdxLicenseException
2525

2626
if TYPE_CHECKING: # pragma: no cover
2727
from ...model import AttachedText, XsUri

cyclonedx/exception/factory.py

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,65 @@
2020
Exceptions relating to specific conditions that occur when factoring a model.
2121
"""
2222

23-
from . import CycloneDxException
23+
__all__ = ['CycloneDxFactoryException', 'LicenseChoiceFactoryException',
24+
'InvalidSpdxLicenseException', 'LicenseFactoryException', 'InvalidLicenseExpressionException']
2425

26+
from ..contrib.license.exceptions import (
27+
FactoryException as _FactoryException,
28+
InvalidLicenseExpressionException as _InvalidLicenseExpressionException,
29+
InvalidSpdxLicenseException as _InvalidSpdxLicenseException,
30+
LicenseChoiceFactoryException as _LicenseChoiceFactoryException,
31+
LicenseFactoryException as _LicenseFactoryException,
32+
)
2533

26-
class CycloneDxFactoryException(CycloneDxException):
27-
"""
28-
Base exception that covers all exceptions that may be thrown during model factoring..
29-
"""
30-
pass
34+
# region deprecated re-export
3135

36+
# re-export NOT as inherited class with @deprecated, to keep the original subclassing intact!!1
3237

33-
class LicenseChoiceFactoryException(CycloneDxFactoryException):
34-
"""
35-
Base exception that covers all LicenseChoiceFactory exceptions.
36-
"""
37-
pass
3838

39+
CycloneDxFactoryException = _FactoryException
40+
"""Deprecated — Alias of :class:`cyclonedx.contrib.license.exceptions.FactoryException`.
3941
40-
class InvalidSpdxLicenseException(LicenseChoiceFactoryException):
41-
"""
42-
Thrown when an invalid SPDX License is provided.
43-
"""
44-
pass
42+
.. deprecated:: next
43+
This re-export location is deprecated.
44+
Use ``from cyclonedx.contrib.license.exceptions import FactoryException`` instead.
45+
The exported symbol itself is NOT deprecated - only this import path.
46+
"""
47+
48+
LicenseChoiceFactoryException = _LicenseChoiceFactoryException
49+
"""Deprecated — Alias of :class:`cyclonedx.contrib.license.exceptions.LicenseChoiceFactoryException`.
50+
51+
.. deprecated:: next
52+
This re-export location is deprecated.
53+
Use ``from cyclonedx.contrib.license.exceptions import LicenseChoiceFactoryException`` instead.
54+
The exported symbol itself is NOT deprecated - only this import path.
55+
"""
56+
57+
InvalidSpdxLicenseException = _InvalidSpdxLicenseException
58+
"""Deprecated — Alias of :class:`cyclonedx.contrib.license.exceptions.InvalidSpdxLicenseException`.
4559
60+
.. deprecated:: next
61+
This re-export location is deprecated.
62+
Use ``from cyclonedx.contrib.license.exceptions import InvalidSpdxLicenseException`` instead.
63+
The exported symbol itself is NOT deprecated - only this import path.
64+
"""
65+
66+
LicenseFactoryException = _LicenseFactoryException
67+
"""Deprecated — Alias of :class:`cyclonedx.contrib.license.exceptions.LicenseFactoryException`.
4668
47-
class LicenseFactoryException(CycloneDxFactoryException):
48-
"""
49-
Base exception that covers all LicenseFactory exceptions.
50-
"""
51-
pass
69+
.. deprecated:: next
70+
This re-export location is deprecated.
71+
Use ``from cyclonedx.contrib.license.exceptions import LicenseFactoryException`` instead.
72+
The exported symbol itself is NOT deprecated - only this import path.
73+
"""
5274

75+
InvalidLicenseExpressionException = _InvalidLicenseExpressionException
76+
"""Deprecated — Alias of :class:`cyclonedx.contrib.license.exceptions.InvalidLicenseExpressionException`.
77+
78+
.. deprecated:: next
79+
This re-export location is deprecated.
80+
Use ``from cyclonedx.contrib.license.exceptions import InvalidLicenseExpressionException`` instead.
81+
The exported symbol itself is NOT deprecated - only this import path.
82+
"""
5383

54-
class InvalidLicenseExpressionException(LicenseFactoryException):
55-
"""
56-
Thrown when an invalid License expressions is provided.
57-
"""
58-
pass
84+
# endregion deprecated re-export

cyclonedx/factory/license.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ class LicenseFactory(_LicenseFactory):
3838
Use ``from cyclonedx.contrib.license.factories import LicenseFactory`` instead.
3939
The exported symbol itself is NOT deprecated - only this import path.
4040
"""
41+
pass
4142

4243
# endregion deprecated re-export

0 commit comments

Comments
 (0)