<s> import dns . exception <EOL> import dns . rdata <EOL> import dns . tokenizer <EOL> def _validate_float_string ( what ) : <EOL> if what [ <NUM_LIT:0> ] == '<STR_LIT:->' or what [ <NUM_LIT:0> ] == '<STR_LIT:+>' : <EOL> what = what [ <NUM_LIT:1> : ] <EOL> if what . isdigit ( ) : <EOL> return <EOL> ( left , right ) = what . split ( '<STR_LIT:.>' ) <EOL> if left == '<STR_LIT>' and right == '<STR_LIT>' : <EOL> raise dns . exception . FormError <EOL> if not left == '<STR_LIT>' and not left . isdigit ( ) : <EOL> raise dns . exception . FormError <EOL> if not right == '<STR_LIT>' and not right . isdigit ( ) : <EOL> raise dns . exception . FormError <EOL> class GPOS ( dns . rdata . Rdata ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , rdclass , rdtype , latitude , longitude , altitude ) : <EOL> super ( GPOS , self ) . __init__ ( rdclass , rdtype ) <EOL> if isinstance ( latitude , float ) or isinstance ( latitude , int ) or isinstance ( latitude , long ) : <EOL> latitude = str ( latitude ) <EOL> if isinstance ( longitude , float ) or isinstance ( longitude , int ) or isinstance ( longitude , long ) : <EOL> longitude = str ( longitude ) <EOL> if isinstance ( altitude , float ) or isinstance ( altitude , int ) or isinstance ( altitude , long ) : <EOL> altitude = str ( altitude ) <EOL> _validate_float_string ( latitude ) <EOL> _validate_float_string ( longitude ) <EOL> _validate_float_string ( altitude ) <EOL> self . latitude = latitude <EOL> self . longitude = longitude <EOL> self . altitude = altitude <EOL> def to_text ( self , origin = None , relativize = True , ** kw ) : <EOL> return '<STR_LIT>' % ( self . latitude , self . longitude , self . altitude ) <EOL> def from_text ( cls , rdclass , rdtype , tok , origin = None , relativize = True ) : <EOL> latitude = tok . get_string ( ) <EOL> longitude = tok . get_string ( ) <EOL> altitude = tok . get_string ( ) <EOL> tok . get_eol ( ) <EOL> return cls ( rdclass , rdtype , latitude , longitude , altitude ) <EOL> from_text = classmethod ( from_text ) <EOL> def to_wire ( self , file , compress = None , origin = None ) : <EOL> l = len ( self . latitude ) <EOL> assert l < <NUM_LIT> <EOL> byte = chr ( l ) <EOL> file . write ( byte ) <EOL> file . write ( self . latitude ) <EOL> l = len ( self . longitude ) <EOL> assert l < <NUM_LIT> <EOL> byte = chr ( l ) <EOL> file . write ( byte ) <EOL> file . write ( self . longitude ) <EOL> l = len ( self . altitude ) <EOL> assert l < <NUM_LIT> <EOL> byte = chr ( l ) <EOL> file . write ( byte ) <EOL> file . write ( self . altitude ) <EOL> def from_wire ( cls , rdclass , rdtype , wire , current , rdlen , origin = None ) : <EOL> l = ord ( wire [ current ] ) <EOL> current += <NUM_LIT:1> <EOL> rdlen -= <NUM_LIT:1> <EOL> if l > rdlen : <EOL> raise dns . exception . FormError <EOL> latitude = wire [ current : current + l ] . unwrap ( ) <EOL> current += l <EOL> rdlen -= l <EOL> l = ord ( wire [ current ] ) <EOL> current += <NUM_LIT:1> <EOL> rdlen -= <NUM_LIT:1> <EOL> if l > rdlen : <EOL> raise dns . exception . FormError <EOL> longitude = wire [ current : current + l ] . unwrap ( ) <EOL> current += l <EOL> rdlen -= l <EOL> l = ord ( wire [ current ] ) <EOL> current += <NUM_LIT:1> <EOL> rdlen -= <NUM_LIT:1> <EOL> if l != rdlen : <EOL> raise dns . exception . FormError <EOL> altitude = wire [ current : current + l ] . unwrap ( ) <EOL> return cls ( rdclass , rdtype , latitude , longitude , altitude ) <EOL> from_wire = classmethod ( from_wire ) <EOL> def _get_float_latitude ( self ) : <EOL> return float ( self . latitude ) <EOL> def _set_float_latitude ( self , value ) : <EOL> self . latitude = str ( value ) <EOL> float_latitude = property ( _get_float_latitude , _set_float_latitude , <EOL> doc = "<STR_LIT>" ) <EOL> def _get_float_longitude ( self ) : <EOL> return float ( self . longitude ) <EOL> def _set_float_longitude ( self , value ) : <EOL> self . longitude = str ( value ) <EOL> float_longitude = property ( _get_float_longitude , _set_float_longitude , <EOL> doc = "<STR_LIT>" ) <EOL> def _get_float_altitude ( self ) : <EOL> return float ( self . altitude ) <EOL> def _set_float_altitude ( self , value ) : <EOL> self . altitude = str ( value ) <EOL> float_altitude = property ( _get_float_altitude , _set_float_altitude , <EOL> doc = "<STR_LIT>" ) </s>
