|
| 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 | +from abc import ABC, abstractmethod |
| 19 | +from typing import Literal |
| 20 | + |
| 21 | +from . import SchemaVersion |
| 22 | + |
| 23 | + |
| 24 | +class SchemaDeprecationWarning(DeprecationWarning, ABC): |
| 25 | + @property |
| 26 | + @abstractmethod |
| 27 | + def schema_version_enum(self) -> SchemaVersion: |
| 28 | + ... # pragma: no cover |
| 29 | + |
| 30 | + def get_schema_version(self) -> str: |
| 31 | + return self.schema_version_enum.to_version() |
| 32 | + |
| 33 | + |
| 34 | +class DeprecationWarning1Dot7(SchemaDeprecationWarning): |
| 35 | + @property |
| 36 | + def schema_version_enum(self) -> Literal[SchemaVersion.V1_7]: |
| 37 | + return SchemaVersion.V1_7 |
| 38 | + |
| 39 | + |
| 40 | +class DeprecationWarning1Dot6(SchemaDeprecationWarning): |
| 41 | + @property |
| 42 | + def schema_version_enum(self) -> Literal[SchemaVersion.V1_6]: |
| 43 | + return SchemaVersion.V1_6 |
| 44 | + |
| 45 | + |
| 46 | +class DeprecationWarning1Dot5(SchemaDeprecationWarning): |
| 47 | + @property |
| 48 | + def schema_version_enum(self) -> Literal[SchemaVersion.V1_5]: |
| 49 | + return SchemaVersion.V1_5 |
| 50 | + |
| 51 | + |
| 52 | +class DeprecationWarning1Dot4(SchemaDeprecationWarning): |
| 53 | + @property |
| 54 | + def schema_version_enum(self) -> Literal[SchemaVersion.V1_4]: |
| 55 | + return SchemaVersion.V1_4 |
| 56 | + |
| 57 | + |
| 58 | +class DeprecationWarning1Dot3(SchemaDeprecationWarning): |
| 59 | + @property |
| 60 | + def schema_version_enum(self) -> Literal[SchemaVersion.V1_3]: |
| 61 | + return SchemaVersion.V1_3 |
| 62 | + |
| 63 | + |
| 64 | +class DeprecationWarning1Dot2(SchemaDeprecationWarning): |
| 65 | + @property |
| 66 | + def schema_version_enum(self) -> Literal[SchemaVersion.V1_2]: |
| 67 | + return SchemaVersion.V1_2 |
| 68 | + |
| 69 | + |
| 70 | +class DeprecationWarning1Dot1(SchemaDeprecationWarning): |
| 71 | + @property |
| 72 | + def schema_version_enum(self) -> Literal[SchemaVersion.V1_1]: |
| 73 | + return SchemaVersion.V1_1 |
0 commit comments