1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import dns.exception
17 import dns.rdata
18 import dns.name
19 import dns.util
20
21 -class RP(dns.rdata.Rdata):
22 """RP record
23
24 @ivar mbox: The responsible person's mailbox
25 @type mbox: dns.name.Name object
26 @ivar txt: The owner name of a node with TXT records, or the root name
27 if no TXT records are associated with this RP.
28 @type txt: dns.name.Name object
29 @see: RFC 1183"""
30
31 __slots__ = ['mbox', 'txt']
32
33 - def __init__(self, rdclass, rdtype, mbox, txt):
34 super(RP, self).__init__(rdclass, rdtype)
35 self.mbox = mbox
36 self.txt = txt
37
38 - def to_text(self, origin=None, relativize=True, **kw):
39 mbox = self.mbox.choose_relativity(origin, relativize)
40 txt = self.txt.choose_relativity(origin, relativize)
41 return "%s %s" % (str(mbox), str(txt))
42
43 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
44 mbox = tok.get_name()
45 txt = tok.get_name()
46 mbox = mbox.choose_relativity(origin, relativize)
47 txt = txt.choose_relativity(origin, relativize)
48 tok.get_eol()
49 return cls(rdclass, rdtype, mbox, txt)
50
51 from_text = classmethod(from_text)
52
53 - def to_wire(self, file, compress = None, origin = None):
54 self.mbox.to_wire(file, None, origin)
55 self.txt.to_wire(file, None, origin)
56
60
61 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
76
77 from_wire = classmethod(from_wire)
78
82
83 - def _cmp(self, other):
84 v = dns.util.cmp(self.mbox, other.mbox)
85 if v == 0:
86 v = dns.util.cmp(self.txt, other.txt)
87 return v
88