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

Source Code for Module dns.rdtypes.ANY.RP

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