Package dns :: Package rdtypes :: Package ANY :: Module RP
[hide private]
[frames] | no frames]

Source Code for Module dns.rdtypes.ANY.RP

 1  # Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license 
 2   
 3  # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. 
 4  # 
 5  # Permission to use, copy, modify, and distribute this software and its 
 6  # documentation for any purpose with or without fee is hereby granted, 
 7  # provided that the above copyright notice and this permission notice 
 8  # appear in all copies. 
 9  # 
10  # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES 
11  # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 
12  # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR 
13  # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
14  # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
15  # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 
16  # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
17   
18  import dns.exception 
19  import dns.rdata 
20  import dns.name 
21 22 23 -class RP(dns.rdata.Rdata):
24 25 """RP record 26 27 @ivar mbox: The responsible person's mailbox 28 @type mbox: dns.name.Name object 29 @ivar txt: The owner name of a node with TXT records, or the root name 30 if no TXT records are associated with this RP. 31 @type txt: dns.name.Name object 32 @see: RFC 1183""" 33 34 __slots__ = ['mbox', 'txt'] 35
36 - def __init__(self, rdclass, rdtype, mbox, txt):
37 super(RP, self).__init__(rdclass, rdtype) 38 self.mbox = mbox 39 self.txt = txt
40
41 - def to_text(self, origin=None, relativize=True, **kw):
42 mbox = self.mbox.choose_relativity(origin, relativize) 43 txt = self.txt.choose_relativity(origin, relativize) 44 return "{} {}".format(str(mbox), str(txt))
45 46 @classmethod
47 - def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
54
55 - def to_wire(self, file, compress=None, origin=None):
56 self.mbox.to_wire(file, None, origin) 57 self.txt.to_wire(file, None, origin)
58
59 - def to_digestable(self, origin=None):
60 return self.mbox.to_digestable(origin) + \ 61 self.txt.to_digestable(origin)
62 63 @classmethod
64 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
65 (mbox, cused) = dns.name.from_wire(wire[: current + rdlen], 66 current) 67 current += cused 68 rdlen -= cused 69 if rdlen <= 0: 70 raise dns.exception.FormError 71 (txt, cused) = dns.name.from_wire(wire[: current + rdlen], 72 current) 73 if cused != rdlen: 74 raise dns.exception.FormError 75 if origin is not None: 76 mbox = mbox.relativize(origin) 77 txt = txt.relativize(origin) 78 return cls(rdclass, rdtype, mbox, txt)
79
80 - def choose_relativity(self, origin=None, relativize=True):
83