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

Method replace_rdataset

dns/node.py:265–289  ·  view source on GitHub ↗

Replace an rdataset. It is not an error if there is no rdataset matching *replacement*. Ownership of the *replacement* object is transferred to the node; in other words, this method does not store a copy of *replacement* at the node, it stores *replacement* itself.

(self, replacement: dns.rdataset.Rdataset)

Source from the content-addressed store, hash-verified

263 self.rdatasets.remove(rds)
264
265 def replace_rdataset(self, replacement: dns.rdataset.Rdataset) -> None:
266 """Replace an rdataset.
267
268 It is not an error if there is no rdataset matching *replacement*.
269
270 Ownership of the *replacement* object is transferred to the node;
271 in other words, this method does not store a copy of *replacement*
272 at the node, it stores *replacement* itself.
273
274 *replacement*, a ``dns.rdataset.Rdataset``.
275
276 Raises ``ValueError`` if *replacement* is not a
277 ``dns.rdataset.Rdataset``.
278 """
279
280 if not isinstance(replacement, dns.rdataset.Rdataset):
281 raise ValueError("replacement is not an rdataset")
282 if isinstance(replacement, dns.rrset.RRset):
283 # RRsets are not good replacements as the match() method
284 # is not compatible.
285 replacement = replacement.to_rdataset()
286 self.delete_rdataset(
287 replacement.rdclass, replacement.rdtype, replacement.covers
288 )
289 self._append_rdataset(replacement)
290
291 def classify(self) -> NodeKind:
292 """Classify a node.

Callers 10

testReplaceRdataset1Method · 0.45
testReplaceRdataset2Method · 0.45
testNodeGetSetDelMethod · 0.45
badMethod · 0.45
testUseTransactionMethod · 0.45
testImmutableNodesMethod · 0.45

Calls 3

delete_rdatasetMethod · 0.95
_append_rdatasetMethod · 0.95
to_rdatasetMethod · 0.80

Tested by 10

testReplaceRdataset1Method · 0.36
testReplaceRdataset2Method · 0.36
testNodeGetSetDelMethod · 0.36
badMethod · 0.36
testUseTransactionMethod · 0.36
testImmutableNodesMethod · 0.36