Source code for ntfy_api.__version__

  1"""Package information for this module.
  2
  3:copyright: (c) 2024 Tanner Corcoran
  4:license: Apache 2.0, see LICENSE for more details.
  5
  6"""
  7
  8import sys
  9from typing import Any, Final, final
 10
 11if sys.version_info >= (3, 11):  # pragma: no cover
 12    from typing import Self
 13else:  # pragma: no cover
 14    from typing_extensions import Self
 15
 16
 17__all__ = (
 18    "__author__",
 19    "__author_email__",
 20    "__cookie__",
 21    "__copyright__",
 22    "__description__",
 23    "__download_url__",
 24    "__email__",
 25    "__license__",
 26    "__title__",
 27    "__url__",
 28    "__version__",
 29    "__release__",
 30    "version_info",
 31)
 32
 33
 34__author__ = "Tanner Corcoran"
 35"""The package author.
 36
 37This value is imported into all modules within this package.
 38
 39"""
 40
 41
 42__author_email__ = "[email protected]"
 43"""The primary contact email of the package author.
 44
 45This value is imported into all modules within this package.
 46
 47"""
 48
 49
 50__cookie__ = "\u2728 \U0001f36a \u2728"
 51"""A cookie, just for you!
 52
 53This value is imported into all modules within this package.
 54
 55"""
 56
 57
 58__copyright__ = "Copyright (c) 2024 Tanner Corcoran"
 59"""The package copyright.
 60
 61This value is imported into all modules within this package.
 62
 63"""
 64
 65
 66__description__ = "A wrapper around the `ntfy <https://ntfy.sh>`_ API."
 67"""A short description of this project.
 68
 69This value is imported into all modules within this package.
 70
 71"""
 72
 73
 74__download_url__ = "https://pypi.org/project/ntfy-api"
 75"""The download URL for this package.
 76
 77This value is imported into all modules within this package.
 78
 79"""
 80
 81
 82__email__ = "[email protected]"
 83"""The primary contact email of the package author.
 84
 85This value is the same as :attr:`__author_email__` and is simply used
 86for compatability. It is imported into all modules within this package.
 87
 88"""
 89
 90
 91__license__ = "Apache 2.0 License"
 92"""The package copyright.
 93
 94This value is imported into all modules within this package.
 95
 96"""
 97
 98
 99__title__ = "ntfy-api"
100"""The package name/title.
101
102.. note::
103    This value may be different than the *module* name.
104
105This value is imported into all modules within this package.
106
107"""
108
109
110__url__ = "https://github.com/tanrbobanr/ntfy-api"
111"""The URL to the package source repository.
112
113This value is imported into all modules within this package.
114
115"""
116
117
[docs] 118@final 119class _version_info(tuple[int, int, int, int, int, int]): # pragma: no cover 120 """A version tuple implementation in many ways similar to 121 :py:obj:`sys.version_info`. Acts as a singleton. 122 123 Composed of :meth:`major`, :meth:`minor`, :meth:`micro`, 124 :meth:`pre`, :meth:`post`, and :meth:`dev` versions (in that order). 125 126 """ 127 128 __instance: Self 129 130 def __new__( 131 cls, major: int, minor: int, micro: int, pre: int, post: int, dev: int 132 ) -> Self: 133 if not hasattr(cls, "_version_info__instance"): 134 cls.__instance = super().__new__( 135 cls, (major, minor, micro, pre, post, dev) 136 ) 137 return cls.__instance 138 139 def __copy__(self) -> Self: 140 return self 141 142 def __deepcopy__(self, memo: Any) -> Self: 143 return self 144 145 if sys.version_info >= (3, 10): 146 __match_args__: Final = ( 147 "major", 148 "minor", 149 "micro", 150 "pre", 151 "post", 152 "dev", 153 ) 154
[docs] 155 @property 156 def major(self) -> int: 157 """The major version (compatability).""" 158 return self[0]
159
[docs] 160 @property 161 def minor(self) -> int: 162 """The minor version (features).""" 163 return self[1]
164
[docs] 165 @property 166 def micro(self) -> int: 167 """The micro version (patches).""" 168 return self[2]
169
[docs] 170 @property 171 def pre(self) -> int: 172 """The pre-release version.""" 173 return self[3]
174
[docs] 175 @property 176 def post(self) -> int: 177 """The post-release version.""" 178 return self[4]
179
[docs] 180 @property 181 def dev(self) -> int: 182 """The dev-release version.""" 183 return self[5]
184
[docs] 185 def version_str(self) -> str: 186 """The version str, e.g. ``0.4.2``.""" 187 return f"{self[0]}.{self[1]}.{self[2]}"
188
[docs] 189 def release_str(self) -> str: 190 """The release str, e.g. ``0.4.2.post3.dev1``.""" 191 optional_part = "".join( 192 f".{k}{v}" 193 for k, v in { 194 "pre": self[3], 195 "post": self[4], 196 "dev": self[5], 197 }.items() 198 if v 199 ) 200 return f"{self.version_str()}{optional_part}"
201 202 203version_info: _version_info = _version_info(1, 0, 0, 1, 0, 0) 204"""The version information. In many ways similar to 205:py:obj:`sys.version_info`. 206 207This value is imported into all modules within this package. 208 209""" 210 211 212__version__ = version_info.version_str() 213"""The package version. 214 215.. _version specifiers: https://packaging.python.org/en/latest/\ 216specifications/version-specifiers/#version-specifiers 217 218This corresponds to the package release segment (see 219`version specifiers`_ for more information). 220 221This value is imported into all modules within this package. 222 223""" 224 225 226__release__ = version_info.release_str() 227"""The package release. 228 229.. _version specifiers: https://packaging.python.org/en/latest/\ 230specifications/version-specifiers/#version-specifiers 231 232This corresponds to the package release, pre-release, post-release, and 233development release segments (see `version specifiers`_ for more 234information). 235 236.. note:: 237 This value *may* differ from :attr:`__version__`, as 238 :attr:`__version__` doesn't include the pre-, post-, or dev-release 239 segments. 240 241This value is imported into all modules within this package. 242 243"""