From: Bob Halley Date: Thu, 2 Apr 2020 15:58:48 +0000 (-0700) Subject: types with properties should be get-only X-Git-Tag: v2.0.0rc1~311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=830400c9bb1c3bc28a492b105b198574309308fb;p=thirdparty%2Fdnspython.git types with properties should be get-only --- diff --git a/dns/rdtypes/ANY/AFSDB.py b/dns/rdtypes/ANY/AFSDB.py index c6a700cf..10861e31 100644 --- a/dns/rdtypes/ANY/AFSDB.py +++ b/dns/rdtypes/ANY/AFSDB.py @@ -38,18 +38,12 @@ class AFSDB(dns.rdtypes.mxbase.UncompressedDowncasingMX): # implementation, but this way we don't copy code, and that's # good. - def get_subtype(self): + @property + def subtype(self): + "the AFSDB subtype" return self.preference - def set_subtype(self, subtype): - self.preference = subtype - - subtype = property(get_subtype, set_subtype) - - def get_hostname(self): + @property + def hostname(self): + "the AFSDB hostname" return self.exchange - - def set_hostname(self, hostname): - self.exchange = hostname - - hostname = property(get_hostname, set_hostname) diff --git a/dns/rdtypes/ANY/GPOS.py b/dns/rdtypes/ANY/GPOS.py index d64b1ee8..07be5d66 100644 --- a/dns/rdtypes/ANY/GPOS.py +++ b/dns/rdtypes/ANY/GPOS.py @@ -131,29 +131,17 @@ class GPOS(dns.rdata.Rdata): altitude = wire[current: current + l].unwrap() return cls(rdclass, rdtype, latitude, longitude, altitude) - def _get_float_latitude(self): + @property + def float_latitude(self): + "latitude as a floating point value" return float(self.latitude) - def _set_float_latitude(self, value): - self.latitude = str(value) - - float_latitude = property(_get_float_latitude, _set_float_latitude, - doc="latitude as a floating point value") - - def _get_float_longitude(self): + @property + def float_longitude(self): + "longitude as a floating point value" return float(self.longitude) - def _set_float_longitude(self, value): - self.longitude = str(value) - - float_longitude = property(_get_float_longitude, _set_float_longitude, - doc="longitude as a floating point value") - - def _get_float_altitude(self): + @property + def float_altitude(self): + "altitude as a floating point value" return float(self.altitude) - - def _set_float_altitude(self, value): - self.altitude = str(value) - - float_altitude = property(_get_float_altitude, _set_float_altitude, - doc="altitude as a floating point value") diff --git a/dns/rdtypes/ANY/LOC.py b/dns/rdtypes/ANY/LOC.py index f6f3efcf..fc02dfdd 100644 --- a/dns/rdtypes/ANY/LOC.py +++ b/dns/rdtypes/ANY/LOC.py @@ -308,20 +308,12 @@ class LOC(dns.rdata.Rdata): return cls(rdclass, rdtype, latitude, longitude, altitude, size, hprec, vprec) - def _get_float_latitude(self): + @property + def float_latitude(self): + "latitude as a floating point value" return _tuple_to_float(self.latitude) - def _set_float_latitude(self, value): - self.latitude = _float_to_tuple(value) - - float_latitude = property(_get_float_latitude, _set_float_latitude, - doc="latitude as a floating point value") - - def _get_float_longitude(self): + @property + def float_longitude(self): + "longitude as a floating point value" return _tuple_to_float(self.longitude) - - def _set_float_longitude(self, value): - self.longitude = _float_to_tuple(value) - - float_longitude = property(_get_float_longitude, _set_float_longitude, - doc="longitude as a floating point value")