mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 17:22:56 -07:00
Bump dnspython from 2.2.1 to 2.3.0 (#1975)
* Bump dnspython from 2.2.1 to 2.3.0 Bumps [dnspython](https://github.com/rthalley/dnspython) from 2.2.1 to 2.3.0. - [Release notes](https://github.com/rthalley/dnspython/releases) - [Changelog](https://github.com/rthalley/dnspython/blob/master/doc/whatsnew.rst) - [Commits](https://github.com/rthalley/dnspython/compare/v2.2.1...v2.3.0) --- updated-dependencies: - dependency-name: dnspython dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update dnspython==2.3.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
6910079330
commit
32c06a8b72
137 changed files with 7699 additions and 4277 deletions
|
@ -17,11 +17,15 @@
|
|||
|
||||
"""DNS Rdata Types."""
|
||||
|
||||
from typing import Dict
|
||||
|
||||
import dns.enum
|
||||
import dns.exception
|
||||
|
||||
|
||||
class RdataType(dns.enum.IntEnum):
|
||||
"""DNS Rdata Type"""
|
||||
|
||||
TYPE0 = 0
|
||||
NONE = 0
|
||||
A = 1
|
||||
|
@ -116,24 +120,47 @@ class RdataType(dns.enum.IntEnum):
|
|||
def _prefix(cls):
|
||||
return "TYPE"
|
||||
|
||||
@classmethod
|
||||
def _extra_from_text(cls, text):
|
||||
if text.find("-") >= 0:
|
||||
try:
|
||||
return cls[text.replace("-", "_")]
|
||||
except KeyError:
|
||||
pass
|
||||
return _registered_by_text.get(text)
|
||||
|
||||
@classmethod
|
||||
def _extra_to_text(cls, value, current_text):
|
||||
if current_text is None:
|
||||
return _registered_by_value.get(value)
|
||||
if current_text.find("_") >= 0:
|
||||
return current_text.replace("_", "-")
|
||||
return current_text
|
||||
|
||||
@classmethod
|
||||
def _unknown_exception_class(cls):
|
||||
return UnknownRdatatype
|
||||
|
||||
_registered_by_text = {}
|
||||
_registered_by_value = {}
|
||||
|
||||
_registered_by_text: Dict[str, RdataType] = {}
|
||||
_registered_by_value: Dict[RdataType, str] = {}
|
||||
|
||||
_metatypes = {RdataType.OPT}
|
||||
|
||||
_singletons = {RdataType.SOA, RdataType.NXT, RdataType.DNAME,
|
||||
RdataType.NSEC, RdataType.CNAME}
|
||||
_singletons = {
|
||||
RdataType.SOA,
|
||||
RdataType.NXT,
|
||||
RdataType.DNAME,
|
||||
RdataType.NSEC,
|
||||
RdataType.CNAME,
|
||||
}
|
||||
|
||||
|
||||
class UnknownRdatatype(dns.exception.DNSException):
|
||||
"""DNS resource record type is unknown."""
|
||||
|
||||
|
||||
def from_text(text):
|
||||
def from_text(text: str) -> RdataType:
|
||||
"""Convert text into a DNS rdata type value.
|
||||
|
||||
The input text can be a defined DNS RR type mnemonic or
|
||||
|
@ -145,20 +172,13 @@ def from_text(text):
|
|||
|
||||
Raises ``ValueError`` if the rdata type value is not >= 0 and <= 65535.
|
||||
|
||||
Returns an ``int``.
|
||||
Returns a ``dns.rdatatype.RdataType``.
|
||||
"""
|
||||
|
||||
text = text.upper().replace('-', '_')
|
||||
try:
|
||||
return RdataType.from_text(text)
|
||||
except UnknownRdatatype:
|
||||
registered_type = _registered_by_text.get(text)
|
||||
if registered_type:
|
||||
return registered_type
|
||||
raise
|
||||
return RdataType.from_text(text)
|
||||
|
||||
|
||||
def to_text(value):
|
||||
def to_text(value: RdataType) -> str:
|
||||
"""Convert a DNS rdata type value to text.
|
||||
|
||||
If the value has a known mnemonic, it will be used, otherwise the
|
||||
|
@ -169,18 +189,13 @@ def to_text(value):
|
|||
Returns a ``str``.
|
||||
"""
|
||||
|
||||
text = RdataType.to_text(value)
|
||||
if text.startswith("TYPE"):
|
||||
registered_text = _registered_by_value.get(value)
|
||||
if registered_text:
|
||||
text = registered_text
|
||||
return text.replace('_', '-')
|
||||
return RdataType.to_text(value)
|
||||
|
||||
|
||||
def is_metatype(rdtype):
|
||||
def is_metatype(rdtype: RdataType) -> bool:
|
||||
"""True if the specified type is a metatype.
|
||||
|
||||
*rdtype* is an ``int``.
|
||||
*rdtype* is a ``dns.rdatatype.RdataType``.
|
||||
|
||||
The currently defined metatypes are TKEY, TSIG, IXFR, AXFR, MAILA,
|
||||
MAILB, ANY, and OPT.
|
||||
|
@ -191,7 +206,7 @@ def is_metatype(rdtype):
|
|||
return (256 > rdtype >= 128) or rdtype in _metatypes
|
||||
|
||||
|
||||
def is_singleton(rdtype):
|
||||
def is_singleton(rdtype: RdataType) -> bool:
|
||||
"""Is the specified type a singleton type?
|
||||
|
||||
Singleton types can only have a single rdata in an rdataset, or a single
|
||||
|
@ -209,11 +224,14 @@ def is_singleton(rdtype):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
def register_type(rdtype, rdtype_text, is_singleton=False):
|
||||
def register_type(
|
||||
rdtype: RdataType, rdtype_text: str, is_singleton: bool = False
|
||||
) -> None:
|
||||
"""Dynamically register an rdatatype.
|
||||
|
||||
*rdtype*, an ``int``, the rdatatype to register.
|
||||
*rdtype*, a ``dns.rdatatype.RdataType``, the rdatatype to register.
|
||||
|
||||
*rdtype_text*, a ``str``, the textual form of the rdatatype.
|
||||
|
||||
|
@ -226,6 +244,7 @@ def register_type(rdtype, rdtype_text, is_singleton=False):
|
|||
if is_singleton:
|
||||
_singletons.add(rdtype)
|
||||
|
||||
|
||||
### BEGIN generated RdataType constants
|
||||
|
||||
TYPE0 = RdataType.TYPE0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue