From: Bob Halley Date: Sat, 8 Aug 2020 14:25:53 +0000 (-0700) Subject: The from_text_list() methods for Rdataset and RRset should allow the X-Git-Tag: v2.1.0rc1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24d79492316b88c6b3082bf8d28dd13ca27e2465;p=thirdparty%2Fdnspython.git The from_text_list() methods for Rdataset and RRset should allow the 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. --- diff --git a/dns/rdataset.py b/dns/rdataset.py index b91d2886..ba93ab43 100644 --- a/dns/rdataset.py +++ b/dns/rdataset.py @@ -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 diff --git a/dns/rrset.py b/dns/rrset.py index 13737d3d..5a09352e 100644 --- a/dns/rrset.py +++ b/dns/rrset.py @@ -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