]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
types with properties should be get-only
authorBob Halley <halley@dnspython.org>
Thu, 2 Apr 2020 15:58:48 +0000 (08:58 -0700)
committerBob Halley <halley@dnspython.org>
Thu, 2 Apr 2020 15:58:48 +0000 (08:58 -0700)
dns/rdtypes/ANY/AFSDB.py
dns/rdtypes/ANY/GPOS.py
dns/rdtypes/ANY/LOC.py

index c6a700cf56d0fa71b22602f7f94f741eeb70a453..10861e310124133cd0d7a7fa0b4ae1a92028bd35 100644 (file)
@@ -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)
index d64b1ee88ed732e93073d043655d48a7aa5f0aab..07be5d66940d4bcc1b4e85742af9932c45d3a690 100644 (file)
@@ -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")
index f6f3efcf73dfeab0254f3d9cd7e2baadb05a9549..fc02dfdd40aeafec2530b2b79c36d80fb56c671e 100644 (file)
@@ -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")