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

Source Code for Module dns.rdtypes.ANY.X25

 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.tokenizer 
19  import dns.util 
20   
21 -class X25(dns.rdata.Rdata):
22 """X25 record 23 24 @ivar address: the PSDN address 25 @type address: string 26 @see: RFC 1183""" 27 28 __slots__ = ['address'] 29
30 - def __init__(self, rdclass, rdtype, address):
31 super(X25, self).__init__(rdclass, rdtype) 32 self.address = address
33
34 - def to_text(self, origin=None, relativize=True, **kw):
35 return '"%s"' % dns.rdata._escapify(self.address)
36
37 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
38 address = tok.get_string() 39 tok.get_eol() 40 return cls(rdclass, rdtype, address)
41 42 from_text = classmethod(from_text) 43
44 - def to_wire(self, file, compress = None, origin = None):
45 l = len(self.address) 46 assert l < 256 47 dns.util.write_uint8(file, l) 48 file.write(self.address.encode('latin_1'))
49
50 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
51 l = wire[current] 52 current += 1 53 rdlen -= 1 54 if l != rdlen: 55 raise dns.exception.FormError 56 address = wire[current : current + l].decode('latin_1') 57 return cls(rdclass, rdtype, address)
58 59 from_wire = classmethod(from_wire) 60
61 - def _cmp(self, other):
62 return dns.util.cmp(self.address, other.address)
63