Home | Trees | Indices | Help |
|
---|
|
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 2022 if what[0] == '-' or what[0] == '+': 23 what = what[1:] 24 if what.isdigit(): 25 return 26 (left, right) = what.split('.') 27 if left == '' and right == '': 28 raise dns.exception.FormError 29 if not left == '' and not left.isdigit(): 30 raise dns.exception.FormError 31 if not right == '' and not right.isdigit(): 32 raise dns.exception.FormError3335 """GPOS record 36 37 @ivar latitude: latitude 38 @type latitude: string 39 @ivar longitude: longitude 40 @type longitude: string 41 @ivar altitude: altitude 42 @type altitude: string 43 @see: RFC 1712""" 44 45 __slots__ = ['latitude', 'longitude', 'altitude'] 4615248 super(GPOS, self).__init__(rdclass, rdtype) 49 if isinstance(latitude, float) or \ 50 isinstance(latitude, int): 51 latitude = str(latitude) 52 if isinstance(longitude, float) or \ 53 isinstance(longitude, int): 54 longitude = str(longitude) 55 if isinstance(altitude, float) or \ 56 isinstance(altitude, int): 57 altitude = str(altitude) 58 _validate_float_string(latitude) 59 _validate_float_string(longitude) 60 _validate_float_string(altitude) 61 self.latitude = latitude 62 self.longitude = longitude 63 self.altitude = altitude64 6769 latitude = tok.get_string() 70 longitude = tok.get_string() 71 altitude = tok.get_string() 72 tok.get_eol() 73 return cls(rdclass, rdtype, latitude, longitude, altitude)74 75 from_text = classmethod(from_text) 7678 l = len(self.latitude) 79 assert l < 256 80 dns.util.write_uint8(file, l) 81 file.write(self.latitude.encode('latin_1')) 82 l = len(self.longitude) 83 assert l < 256 84 dns.util.write_uint8(file, l) 85 file.write(self.longitude.encode('latin_1')) 86 l = len(self.altitude) 87 assert l < 256 88 dns.util.write_uint8(file, l) 89 file.write(self.altitude.encode('latin_1'))9092 l = wire[current] 93 current += 1 94 rdlen -= 1 95 if l > rdlen: 96 raise dns.exception.FormError 97 latitude = wire[current : current + l].decode('latin_1') 98 current += l 99 rdlen -= l 100 l = wire[current] 101 current += 1 102 rdlen -= 1 103 if l > rdlen: 104 raise dns.exception.FormError 105 longitude = wire[current : current + l].decode('latin_1') 106 current += l 107 rdlen -= l 108 l = wire[current] 109 current += 1 110 rdlen -= 1 111 if l != rdlen: 112 raise dns.exception.FormError 113 altitude = wire[current : current + l].decode('latin_1') 114 return cls(rdclass, rdtype, latitude, longitude, altitude)115 116 from_wire = classmethod(from_wire) 117119 v = dns.util.cmp(self.latitude, other.latitude) 120 if v == 0: 121 v = dns.util.cmp(self.longitude, other.longitude) 122 if v == 0: 123 v = dns.util.cmp(self.altitude, other.altitude) 124 return v125127 return float(self.latitude)128130 self.latitude = str(value)131 132 float_latitude = property(_get_float_latitude, _set_float_latitude, 133 doc="latitude as a floating point value") 134136 return float(self.longitude)137139 self.longitude = str(value)140 141 float_longitude = property(_get_float_longitude, _set_float_longitude, 142 doc="longitude as a floating point value") 143145 return float(self.altitude)146148 self.altitude = str(value)149 150 float_altitude = property(_get_float_altitude, _set_float_altitude, 151 doc="altitude as a floating point value")
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 31 05:21:21 2013 | http://epydoc.sourceforge.net |