+## Resource records
+class RR:
+ def __init__(self, path, recordType, data):
+ '''<path> can be relative or absolute.'''
+ assert re.match(r'^[A-Z]+$', recordType), "got invalid record type"
+ self.path = path
+ self.recordType = recordType
+ self.data = data
+ self.TTL = None
+
+ def mapPath(self, f):
+ '''Run the path through f. Returns self, for nicer chaining.'''
+ self.path = f(self.path)
+ return self
+
+ def relativize(self, root):
+ return self.mapPath(lambda path: concatenate(root, path))
+
+ def mapTTL(self, f):
+ '''Run the current TTL and the recordType through f.'''
+ self.TTL = f(self.TTL, self.recordType)
+ return self
+
+ def __str__(self):
+ return column_widths((self.path, time(self.TTL), self.recordType, self.data), (8*3, 8, 8))
+