+class TXT:
+ def __init__(self, name: str, text: str) -> None:
+ # test for bad characters
+ for c in ('\n', '\r', '\t'):
+ if c in text:
+ raise Exception("TXT record {0} containts invalid character")
+ # escape text
+ for c in ('\\', '\"'):
+ text = text.replace(c, '\\'+c)
+ self._text = text
+
+ def generate_rr(self, owner:str, zone: 'Zone') -> 'Any':
+ return zone.RR(owner, 'TXT', '"{0}"'.format(self._text))
+
+