]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
The from_text_list() methods for Rdataset and RRset should allow the
authorBob Halley <halley@dnspython.org>
Sat, 8 Aug 2020 14:25:53 +0000 (07:25 -0700)
committerBob Halley <halley@dnspython.org>
Sat, 8 Aug 2020 14:25:53 +0000 (07:25 -0700)
full set of parameters that rdata's from_text() allows (i.e. origin,
relativize, and relativize_to).

These parameters were added though the order is slightly different
from dns.rdata.to_text() as in the the rdata version idna_codec is
after origin, relativize, and relativize_to.  We already had an
idna_codec for the Rdataset and RRset functions, so we added after it
to keep backwards compatibility.

dns/rdataset.py
dns/rrset.py

index b91d2886ed1db3da3a597dab30f5abc94e61a468..ba93ab4365619505af2cc75d82314365a2ead8f6 100644 (file)
@@ -306,7 +306,8 @@ class Rdataset(dns.set.Set):
         return False
 
 
-def from_text_list(rdclass, rdtype, ttl, text_rdatas, idna_codec=None):
+def from_text_list(rdclass, rdtype, ttl, text_rdatas, idna_codec=None,
+                   origin=None, relativize=True, relativize_to=None):
     """Create an rdataset with the specified class, type, and TTL, and with
     the specified list of rdatas in text format.
 
@@ -314,6 +315,14 @@ def from_text_list(rdclass, rdtype, ttl, text_rdatas, idna_codec=None):
     encoder/decoder to use; if ``None``, the default IDNA 2003
     encoder/decoder is used.
 
+    *origin*, a ``dns.name.Name`` (or ``None``), the
+    origin to use for relative names.
+
+    *relativize*, a ``bool``.  If true, name will be relativized.
+
+    *relativize_to*, a ``dns.name.Name`` (or ``None``), the origin to use
+    when relativizing names.  If not set, the *origin* value will be used.
+
     Returns a ``dns.rdataset.Rdataset`` object.
     """
 
@@ -322,7 +331,8 @@ def from_text_list(rdclass, rdtype, ttl, text_rdatas, idna_codec=None):
     r = Rdataset(rdclass, rdtype)
     r.update_ttl(ttl)
     for t in text_rdatas:
-        rd = dns.rdata.from_text(r.rdclass, r.rdtype, t, idna_codec=idna_codec)
+        rd = dns.rdata.from_text(r.rdclass, r.rdtype, t, origin, relativize,
+                                 relativize_to, idna_codec)
         r.add(rd)
     return r
 
index 13737d3d82fe79d597adc09cf33b74bebf354e99..5a09352e9a6e967b17bae4fc159c41ca2ab62c93 100644 (file)
@@ -135,7 +135,8 @@ class RRset(dns.rdataset.Rdataset):
 
 
 def from_text_list(name, ttl, rdclass, rdtype, text_rdatas,
-                   idna_codec=None):
+                   idna_codec=None, origin=None, relativize=True,
+                   relativize_to=None):
     """Create an RRset with the specified name, TTL, class, and type, and with
     the specified list of rdatas in text format.
 
@@ -143,6 +144,14 @@ def from_text_list(name, ttl, rdclass, rdtype, text_rdatas,
     encoder/decoder to use; if ``None``, the default IDNA 2003
     encoder/decoder is used.
 
+    *origin*, a ``dns.name.Name`` (or ``None``), the
+    origin to use for relative names.
+
+    *relativize*, a ``bool``.  If true, name will be relativized.
+
+    *relativize_to*, a ``dns.name.Name`` (or ``None``), the origin to use
+    when relativizing names.  If not set, the *origin* value will be used.
+
     Returns a ``dns.rrset.RRset`` object.
     """
 
@@ -153,7 +162,8 @@ def from_text_list(name, ttl, rdclass, rdtype, text_rdatas,
     r = RRset(name, rdclass, rdtype)
     r.update_ttl(ttl)
     for t in text_rdatas:
-        rd = dns.rdata.from_text(r.rdclass, r.rdtype, t, idna_codec=idna_codec)
+        rd = dns.rdata.from_text(r.rdclass, r.rdtype, t, origin, relativize,
+                                 relativize_to, idna_codec)
         r.add(rd)
     return r