+def time(time: int) -> str:
+ if time == 0:
+ return "0"
+ elif time % week == 0:
+ return str(time//week)+"w"
+ elif time % day == 0:
+ return str(time//day)+"d"
+ elif time % hour == 0:
+ return str(time//hour)+"h"
+ elif time % minute == 0:
+ return str(time//minute)+"m"
+ else:
+ return str(time)
+
+def column_widths(datas: Sequence, widths: Sequence[int]):
+ assert len(datas) == len(widths)+1, "There must be as one more data points as widths"
+ result = ""
+ width_sum = 0
+ for data, width in zip(datas, widths): # will *not* cover the last point
+ result += str(data)+" " # add data point, and a minimal space
+ width_sum += width
+ if len(result) < width_sum: # add padding
+ result += (width_sum - len(result))*" "
+ # last data point
+ return result+str(datas[-1])
+
+
+## Record types
+class A:
+ def __init__(self, address: str) -> None:
+ self._address = IPv4Address(address)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> Any:
+ return zone.RR(owner, 'A', self._address)
+
+
+class AAAA:
+ def __init__(self, address: str) -> None:
+ self._address = IPv6Address(address)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> Any:
+ return zone.RR(owner, 'AAAA', self._address)
+
+
+class MX:
+ def __init__(self, name: str, prio: int = 10) -> None:
+ self._priority = int(prio)
+ self._name = check_hostname(name)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> Any:
+ return zone.RR(owner, 'MX', '{0} {1}'.format(self._priority, zone.abs_hostname(self._name)))
+
+
+class SRV:
+ def __init__(self, protocol: str, service: str, name: str, port: int, prio: int, weight: int) -> None:
+ self._service = str(service)
+ self._protocol = str(protocol)
+ self._priority = int(prio)
+ self._weight = int(weight)
+ self._port = int(port)
+ self._name = check_hostname(name)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> Any:
+ return zone.RR('_{0}._{1}.{2}'.format(self._service, self._protocol, owner), 'SRV',
+ '{0} {1} {2} {3}'.format(self._priority, self._weight, self._port, zone.abs_hostname(self._name)))
+
+
+class TLSA:
+ def __init__(self, protocol: str, port: int, key: str) -> None:
+ # TODO: fix key stuff
+ self._port = int(port)
+ self._protocol = str(protocol)
+ self._key = str(key)