Upgraded vendored Python dependencies to the latest versions and removed the unused dependencies.

This commit is contained in:
morpheus65535 2022-01-23 23:07:52 -05:00
parent 36bf0d219d
commit 0c3c5a02a7
2108 changed files with 306789 additions and 151391 deletions

View file

@ -1,4 +1,6 @@
# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
# Copyright (C) 2003-2017 Nominum, Inc.
# Copyright (C) 2016 Coresec Systems AB
#
# Permission to use, copy, modify, and distribute this software and its
@ -25,26 +27,26 @@
"""DNS name dictionary"""
import collections
from collections.abc import MutableMapping
import dns.name
from ._compat import xrange
class NameDict(collections.MutableMapping):
class NameDict(MutableMapping):
"""A dictionary whose keys are dns.name.Name objects.
@ivar max_depth: the maximum depth of the keys that have ever been
added to the dictionary.
@type max_depth: int
@ivar max_depth_items: the number of items of maximum depth
@type max_depth_items: int
In addition to being like a regular Python dictionary, this
dictionary can also get the deepest match for a given key.
"""
__slots__ = ["max_depth", "max_depth_items", "__store"]
def __init__(self, *args, **kwargs):
super().__init__()
self.__store = dict()
#: the maximum depth of the keys that have ever been added
self.max_depth = 0
#: the number of items of maximum depth
self.max_depth_items = 0
self.update(dict(*args, **kwargs))
@ -65,8 +67,8 @@ class NameDict(collections.MutableMapping):
self.__update_max_depth(key)
def __delitem__(self, key):
value = self.__store.pop(key)
if len(value) == self.max_depth:
self.__store.pop(key)
if len(key) == self.max_depth:
self.max_depth_items = self.max_depth_items - 1
if self.max_depth_items == 0:
self.max_depth = 0
@ -83,20 +85,22 @@ class NameDict(collections.MutableMapping):
return key in self.__store
def get_deepest_match(self, name):
"""Find the deepest match to I{name} in the dictionary.
"""Find the deepest match to *name* in the dictionary.
The deepest match is the longest name in the dictionary which is
a superdomain of I{name}.
a superdomain of *name*. Note that *superdomain* includes matching
*name* itself.
@param name: the name
@type name: dns.name.Name object
@rtype: (key, value) tuple
*name*, a ``dns.name.Name``, the name to find.
Returns a ``(key, value)`` where *key* is the deepest
``dns.name.Name``, and *value* is the value associated with *key*.
"""
depth = len(name)
if depth > self.max_depth:
depth = self.max_depth
for i in xrange(-depth, 0):
for i in range(-depth, 0):
n = dns.name.Name(name[i:])
if n in self:
return (n, self[n])