summaryrefslogtreecommitdiff
path: root/dns
diff options
context:
space:
mode:
authorPetr Spacek <pspacek@redhat.com>2014-01-21 13:49:21 +0100
committerBob Halley <halley@dnspython.org>2014-08-31 16:17:23 -0700
commit8e0eb71d93205af64cd08d877bfae177f287c197 (patch)
treedc857f968c8e9f58347f311f0227001ba70b18ff /dns
parent16c12d48d1a2b6a14e6b63597e916533470ecc58 (diff)
downloaddnspython-8e0eb71d93205af64cd08d877bfae177f287c197.tar.gz
Fix default size, horizontal and vertical precition values for LOC records.
Default values in RFC 1876 are in meters but the old code used the numerical value as centimeters.
Diffstat (limited to 'dns')
-rw-r--r--dns/rdtypes/ANY/LOC.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/dns/rdtypes/ANY/LOC.py b/dns/rdtypes/ANY/LOC.py
index 55662e0..41c8f7a 100644
--- a/dns/rdtypes/ANY/LOC.py
+++ b/dns/rdtypes/ANY/LOC.py
@@ -23,6 +23,11 @@ import dns.util
_pows = (1, 10, 100, 1000, 10000, 100000, 1000000, 10000000,
100000000, 1000000000, 10000000000)
+# default values are in centimeters
+_default_size = 100.0
+_default_hprec = 1000000.0
+_default_vprec = 1000.0
+
def _exponent_of(what, desc):
if what == 0:
return 0
@@ -100,13 +105,14 @@ class LOC(dns.rdata.Rdata):
'horizontal_precision', 'vertical_precision']
def __init__(self, rdclass, rdtype, latitude, longitude, altitude,
- size=1.0, hprec=10000.0, vprec=10.0):
+ size=_default_size, hprec=_default_hprec, vprec=_default_vprec):
"""Initialize a LOC record instance.
The parameters I{latitude} and I{longitude} may be either a 4-tuple
of integers specifying (degrees, minutes, seconds, milliseconds),
or they may be floating point values specifying the number of
- degrees. The other parameters are floats."""
+ degrees. The other parameters are floats. Size, horizontal precision,
+ and vertical precision are specified in centimeters."""
super(LOC, self).__init__(rdclass, rdtype)
if isinstance(latitude, int):
@@ -143,8 +149,10 @@ class LOC(dns.rdata.Rdata):
self.longitude[3], long_hemisphere, self.altitude / 100.0
)
- if self.size != 1.0 or self.horizontal_precision != 10000.0 or \
- self.vertical_precision != 10.0:
+ # do not print default values
+ if self.size != _default_size or \
+ self.horizontal_precision != _default_hprec or \
+ self.vertical_precision != _default_vprec:
text += " %0.2fm %0.2fm %0.2fm" % (
self.size / 100.0, self.horizontal_precision / 100.0,
self.vertical_precision / 100.0
@@ -154,9 +162,9 @@ class LOC(dns.rdata.Rdata):
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
latitude = [0, 0, 0, 0]
longitude = [0, 0, 0, 0]
- size = 1.0
- hprec = 10000.0
- vprec = 10.0
+ size = _default_size
+ hprec = _default_hprec
+ vprec = _default_vprec
latitude[0] = tok.get_int()
t = tok.get_string()