MCPcopy Create free account
hub / github.com/rthalley/dnspython / from_rdtypes

Method from_rdtypes

dns/rdtypes/util.py:170–194  ·  view source on GitHub ↗
(cls, rdtypes: List[dns.rdatatype.RdataType])

Source from the content-addressed store, hash-verified

168
169 @classmethod
170 def from_rdtypes(cls, rdtypes: List[dns.rdatatype.RdataType]) -> "Bitmap":
171 rdtypes = sorted(rdtypes)
172 window = 0
173 octets = 0
174 prior_rdtype = 0
175 bitmap = bytearray(b"\0" * 32)
176 windows = []
177 for rdtype in rdtypes:
178 if rdtype == prior_rdtype:
179 continue
180 prior_rdtype = rdtype
181 new_window = rdtype // 256
182 if new_window != window:
183 if octets != 0:
184 windows.append((window, bytes(bitmap[0:octets])))
185 bitmap = bytearray(b"\0" * 32)
186 window = new_window
187 offset = rdtype % 256
188 byte = offset // 8
189 bit = offset % 8
190 octets = byte + 1
191 bitmap[byte] = bitmap[byte] | (0x80 >> bit)
192 if octets != 0:
193 windows.append((window, bytes(bitmap[0:octets])))
194 return cls(windows)
195
196 def to_wire(self, file: Any) -> None:
197 for window, bitmap in self.windows:

Callers 2

_txn_add_nsecFunction · 0.80
from_textMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected