summaryrefslogtreecommitdiff
path: root/dns
diff options
context:
space:
mode:
Diffstat (limited to 'dns')
-rw-r--r--dns/zone.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/dns/zone.py b/dns/zone.py
index 04c1ecf..c1b0223 100644
--- a/dns/zone.py
+++ b/dns/zone.py
@@ -18,6 +18,7 @@
from __future__ import generators
import builtins
+import io
import re
import sys
@@ -491,6 +492,27 @@ class Zone(object):
if want_close:
f.close()
+ def to_text(self, sorted=True, relativize=True, nl=None):
+ """Return a zone's text as though it were written to a file.
+
+ @param sorted: if True, the file will be written with the
+ names sorted in DNSSEC order from least to greatest. Otherwise
+ the names will be written in whatever order they happen to have
+ in the zone's dictionary.
+ @param relativize: if True, domain names in the output will be
+ relativized to the zone's origin (if possible).
+ @type relativize: bool
+ @param nl: The end of line string. If not specified, the
+ output will use the platform's native end-of-line marker (i.e.
+ LF on POSIX, CRLF on Windows, CR on Macintosh).
+ @type nl: string or None
+ """
+ temp_buffer = io.StringIO()
+ self.to_file(temp_buffer, sorted, relativize, nl)
+ return_value = temp_buffer.getvalue()
+ temp_buffer.close()
+ return return_value
+
def check_origin(self):
"""Do some simple checking of the zone's origin.