1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import struct
17
18 import dns.exception
19 import dns.rdata
20 import dns.tokenizer
21 from dns._compat import text_type
22
23
24 -class ISDN(dns.rdata.Rdata):
25
26 """ISDN record
27
28 @ivar address: the ISDN address
29 @type address: string
30 @ivar subaddress: the ISDN subaddress (or '' if not present)
31 @type subaddress: string
32 @see: RFC 1183"""
33
34 __slots__ = ['address', 'subaddress']
35
36 - def __init__(self, rdclass, rdtype, address, subaddress):
46
47 - def to_text(self, origin=None, relativize=True, **kw):
48 if self.subaddress:
49 return '"%s" "%s"' % (dns.rdata._escapify(self.address),
50 dns.rdata._escapify(self.subaddress))
51 else:
52 return '"%s"' % dns.rdata._escapify(self.address)
53
54 @classmethod
55 - def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
56 address = tok.get_string()
57 t = tok.get()
58 if not t.is_eol_or_eof():
59 tok.unget(t)
60 subaddress = tok.get_string()
61 else:
62 tok.unget(t)
63 subaddress = ''
64 tok.get_eol()
65 return cls(rdclass, rdtype, address, subaddress)
66
67 - def to_wire(self, file, compress=None, origin=None):
68 l = len(self.address)
69 assert l < 256
70 file.write(struct.pack('!B', l))
71 file.write(self.address)
72 l = len(self.subaddress)
73 if l > 0:
74 assert l < 256
75 file.write(struct.pack('!B', l))
76 file.write(self.subaddress)
77
78 @classmethod
79 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
98