antsibull-nox 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
antsibull_nox/utils.py ADDED
@@ -0,0 +1,85 @@
1
+ # Author: Felix Fontein <felix@fontein.de>
2
+ # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or
3
+ # https://www.gnu.org/licenses/gpl-3.0.txt)
4
+ # SPDX-License-Identifier: GPL-3.0-or-later
5
+ # SPDX-FileCopyrightText: 2025, Ansible Project
6
+
7
+ """
8
+ General utilities.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import typing as t
14
+ from dataclasses import dataclass
15
+
16
+
17
+ @dataclass(order=True, frozen=True)
18
+ class Version:
19
+ """
20
+ Models a two-part version (major and minor).
21
+ """
22
+
23
+ major: int
24
+ minor: int
25
+
26
+ @classmethod
27
+ def parse(cls, version_string: str) -> Version:
28
+ """
29
+ Given a version string, parses it into a Version object.
30
+ Other components than major and minor version are ignored.
31
+ """
32
+ try:
33
+ major, minor = [int(v) for v in version_string.split(".")[:2]]
34
+ except (AttributeError, ValueError) as exc:
35
+ raise ValueError(
36
+ f"Cannot parse {version_string!r} as version string."
37
+ ) from exc
38
+ return Version(major=major, minor=minor)
39
+
40
+ def __str__(self) -> str:
41
+ return f"{self.major}.{self.minor}"
42
+
43
+ def next_minor_version(self) -> Version:
44
+ """
45
+ Returns the next minor version.
46
+
47
+ The major version stays the same, and the minor version is increased by 1.
48
+ """
49
+ return Version(self.major, self.minor + 1)
50
+
51
+ def previous_minor_version(self) -> Version:
52
+ """
53
+ Returns the previous minor version.
54
+ Raises a ValueError if there is none.
55
+
56
+ The major version stays the same, and the minor version is decreased by 1.
57
+ """
58
+ if self.minor == 0:
59
+ raise ValueError("No previous minor version exists")
60
+ return Version(self.major, self.minor - 1)
61
+
62
+
63
+ def version_range(
64
+ start: Version, end: Version, *, inclusive: bool
65
+ ) -> t.Generator[Version]:
66
+ """
67
+ Enumerate all versions starting at ``start`` until ``end``.
68
+
69
+ Whether ``end`` is included in the range depends on ``inclusive``.
70
+ """
71
+ if start.major != end.major:
72
+ raise ValueError(
73
+ f"Cannot list all versions from {start} to {end}"
74
+ " since they have different major versions"
75
+ )
76
+ version = start
77
+ while (version <= end) if inclusive else (version < end):
78
+ yield version
79
+ version = Version(major=version.major, minor=version.minor + 1)
80
+
81
+
82
+ __all__ = [
83
+ "Version",
84
+ "version_range",
85
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: antsibull-nox
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Changelog tool for Ansible-core and Ansible collections
5
5
  Project-URL: Documentation, https://ansible.readthedocs.io/projects/antsibull-nox/
6
6
  Project-URL: Source code, https://github.com/ansible-community/antsibull-nox/
@@ -25,8 +25,10 @@ Requires-Python: >=3.9.0
25
25
  Requires-Dist: antsibull-fileutils<2.0.0,>=1.2.0
26
26
  Requires-Dist: nox>=2025.2.9
27
27
  Requires-Dist: packaging
28
+ Requires-Dist: pydantic~=2.0
28
29
  Requires-Dist: pyyaml
29
30
  Requires-Dist: semantic-version
31
+ Requires-Dist: tomli; python_version < '3.11'
30
32
  Provides-Extra: codeqa
31
33
  Requires-Dist: antsibull-changelog; extra == 'codeqa'
32
34
  Requires-Dist: flake8>=3.8.0; extra == 'codeqa'
@@ -0,0 +1,25 @@
1
+ antsibull_nox/__init__.py,sha256=GpVc0V0RONI7CXHDrGoyvTvL7Syl6UDKZWL_N_z6zGg,2145
2
+ antsibull_nox/ansible.py,sha256=_PugP3a6JXijptFwuUki5nq_66VA8e9gVZUpA5HewVg,8891
3
+ antsibull_nox/config.py,sha256=W1u-lL0x5o2XyGo7FiQY766Pr9bP9DAi0LDfO2O7FTQ,9412
4
+ antsibull_nox/data_util.py,sha256=7FVoqESEc-_QdqrQ16K1AHRVHEglNbRCH_mNaYDJ7a4,953
5
+ antsibull_nox/interpret_config.py,sha256=a7Zwm7k0t8rETOehxqpidigegcroJACS-4IsbIujW30,9703
6
+ antsibull_nox/paths.py,sha256=86HOynhCMTVop3ml_77JI06vM9nyK7PHMzLP_4M0V88,6317
7
+ antsibull_nox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ antsibull_nox/python.py,sha256=0pyGqgwsuyc0BhzoXNZLTLbjaFA4kAYEHrFD6A1o1-o,2113
9
+ antsibull_nox/sessions.py,sha256=fYhSLOqA1YKskaxPAAudlnWGHpV5T0TVzB5APeNc1qI,57251
10
+ antsibull_nox/utils.py,sha256=lgBNuJ67Agl9YpFNWCjr6TBUcbC1LroZrJkv6S5VuxA,2437
11
+ antsibull_nox/collection/__init__.py,sha256=0zsFKqAZYw6Y5wdhddsbMAmx7dKvihS9bh6CstJ5b2A,1484
12
+ antsibull_nox/collection/data.py,sha256=sacVZF517x54B3G6F0hW8fTpEF7zyB8exSQJO9mvhLk,2609
13
+ antsibull_nox/collection/extract.py,sha256=qNVknQRtRrCt10aawuU1Z6NTs16CA1bUEX3WDGBw68g,684
14
+ antsibull_nox/collection/install.py,sha256=DbnXUBzQlzW6TzU_TAszuApix2F2n7w1AcUcPZ4Q4G4,17082
15
+ antsibull_nox/collection/search.py,sha256=cNe6zyR3l-5iSOX5kBRAeHgubkUKFJhwDtN7j0rn7w0,15477
16
+ antsibull_nox/data/action-groups.py,sha256=24l3583jcVRmCm5t8VZuMx68Del0s4iReACsvg4ijnU,6913
17
+ antsibull_nox/data/antsibull_nox_data_util.py,sha256=D4i_sKxjAeZuDV-z9Ibow0YYIqhXo2V_YC0LONLcEXM,2931
18
+ antsibull_nox/data/license-check.py,sha256=uXC2aP2EDxLfAEpAe6nG4pOldp3N6NX6uc-k9jdXDpU,5575
19
+ antsibull_nox/data/license-check.py.license,sha256=iPdFtdkeE3E2nCB-M5KHevbz4d5I-6ymOnKNTc954Dw,218
20
+ antsibull_nox/data/no-unwanted-files.py,sha256=_B3m-XWvWpdzGN-XAP8rLIS_5RMJGntFWL-Jy0WY9Mc,2959
21
+ antsibull_nox/data/plugin-yamllint.py,sha256=ELK1pTLwDFwGfGgwRSGUU0hvOgk4P6oF_4P-y0DQIqc,7368
22
+ antsibull_nox-0.2.0.dist-info/METADATA,sha256=izOXagec2VtPCMSGtQYWmw_68UfA5nfVyx3E0gwIb5g,7671
23
+ antsibull_nox-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
+ antsibull_nox-0.2.0.dist-info/licenses/LICENSES/GPL-3.0-or-later.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
25
+ antsibull_nox-0.2.0.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- antsibull_nox/__init__.py,sha256=_Wif6qsqOwabzfn0BoGzc7xNpD9ee4zOCLfwNY5UMtI,713
2
- antsibull_nox/collection.py,sha256=6pKZVKfyWROfoAXsxRGcRhn9bV_1oHKgIcN5pgQ3fpQ,18201
3
- antsibull_nox/data_util.py,sha256=nRFNtrmUjXzHBcxeuut5sCBNb6iABtwxMBOcRjfY4Ik,3521
4
- antsibull_nox/paths.py,sha256=fqcC4BM20RfdsM0UVRm-_PlRskN2qVzo50dYBL5RTb0,5670
5
- antsibull_nox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- antsibull_nox/sessions.py,sha256=IG1viMLudrXOwSMYqA_uTub2u6ztqAGuasyxCRLsx5Y,27631
7
- antsibull_nox/data/action-groups.py,sha256=qwovnhsX1ojR9jSsr7ofw5vyD2arBnSWriOwgi0bIpA,6894
8
- antsibull_nox/data/license-check.py,sha256=Lwf_bDdiDDQwr5e2mF0kXYrEr6sD4lCcqHaGnx1S__k,5556
9
- antsibull_nox/data/license-check.py.license,sha256=iPdFtdkeE3E2nCB-M5KHevbz4d5I-6ymOnKNTc954Dw,218
10
- antsibull_nox/data/no-unwanted-files.py,sha256=9BcqC-2-L16vRhPxWZAfoIgO8GevdTINEPBpMvBkPLg,2923
11
- antsibull_nox-0.1.0.dist-info/METADATA,sha256=atuTna_HzXHG-6yUSfXU053pdb1erGnmdABDYCuA5YM,7596
12
- antsibull_nox-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- antsibull_nox-0.1.0.dist-info/licenses/LICENSES/GPL-3.0-or-later.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
- antsibull_nox-0.1.0.dist-info/RECORD,,