dnspython  1.16.0
About: dnspython is a DNS toolkit (for Python 2.x) that supports almost all record types.
  Fossies Dox: dnspython-1.16.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

RP.py
Go to the documentation of this file.
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 
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):
48  mbox = tok.get_name()
49  txt = tok.get_name()
50  mbox = mbox.choose_relativity(origin, relativize)
51  txt = txt.choose_relativity(origin, relativize)
52  tok.get_eol()
53  return cls(rdclass, rdtype, mbox, txt)
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:
71  (txt, cused) = dns.name.from_wire(wire[: current + rdlen],
72  current)
73  if cused != rdlen:
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):
81  self.mbox = self.mbox.choose_relativity(origin, relativize)
82  self.txt = self.txt.choose_relativity(origin, relativize)
dns.exception.FormError
Definition: exception.py:109
dns.rdtypes.ANY.RP.RP.mbox
mbox
Definition: RP.py:38
dns.rdtypes.ANY.RP.RP.to_text
def to_text(self, origin=None, relativize=True, **kw)
Definition: RP.py:41
dns.rdtypes.ANY.RP.RP.choose_relativity
def choose_relativity(self, origin=None, relativize=True)
Definition: RP.py:80
dns.rdtypes.ANY.RP.RP.from_text
def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True)
Definition: RP.py:47
dns.name.from_wire
def from_wire(message, current)
Definition: name.py:945
dns.name
Definition: name.py:1
dns.rdtypes.ANY.RP.RP.from_wire
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None)
Definition: RP.py:64
dns.rdtypes.ANY.RP.RP.to_digestable
def to_digestable(self, origin=None)
Definition: RP.py:59
dns.rdtypes.ANY.RP.RP.to_wire
def to_wire(self, file, compress=None, origin=None)
Definition: RP.py:55
dns.rdata
Definition: rdata.py:1
dns.rdtypes.ANY.RP.RP.txt
txt
Definition: RP.py:39
dns.rdtypes.ANY.RP.RP
Definition: RP.py:23
dns.exception
Definition: exception.py:1
dns.rdtypes.ANY.RP.RP.__init__
def __init__(self, rdclass, rdtype, mbox, txt)
Definition: RP.py:36
dns.rdata.Rdata
Definition: rdata.py:95