# HG changeset patch # User Tero Marttila # Date 1332147530 -7200 # Node ID 4ccc31fdc047051de35dad1505e6b31bcf8b8d5b # Parent 91c073d5615af42270f71041644a9f64874859fd process-zone: generate TXT records for ZoneLine.timestamp, if available diff -r 91c073d5615a -r 4ccc31fdc047 bin/process-zone --- a/bin/process-zone Mon Mar 19 10:50:34 2012 +0200 +++ b/bin/process-zone Mon Mar 19 10:58:50 2012 +0200 @@ -286,6 +286,17 @@ def __str__ (self) : return ' '.join((self.name, self.type, ' '.join(self.data))) +class TXTRecord (ZoneRecord) : + """ + TXT record. + """ + + def __init__ (self, name, text, **opts) : + return super(TXTRecord, self).__init__(name, 'TXT', + [u'"{0}"'.format(text.replace('"', '\\"'))], + **opts + ) + def parse_record (path, lineno, line, **opts) : """ Parse (name, ttl, type, data, comment) from bind zonefile. @@ -357,12 +368,24 @@ Process zone data -> forward zone data. """ + TIMESTAMP_FORMAT='%Y/%m/%d' + for r in zone : yield r if r.type == 'A' : - if txt and r.line.comment : - yield ZoneRecord(None, 'TXT', [u'"{0}"'.format(r.line.comment)], ttl=r.ttl) + if txt : + # comment? + comment = r.line.comment + + if comment : + yield TXTRecord(None, comment, ttl=r.ttl) + + # timestamp? + timestamp = r.line.timestamp + + if timestamp : + yield TXTRecord(None, timestamp.strftime(TIMESTAMP_FORMAT), ttl=r.ttl) # XXX: RP, do we need it?