mirror of https://github.com/django/django.git
Converted property syntax of WKBWriter
This commit is contained in:
parent
393811c67a
commit
d419b0c9bd
|
@ -233,29 +233,29 @@ class WKBWriter(IOBase):
|
||||||
byteorder = property(_get_byteorder, _set_byteorder)
|
byteorder = property(_get_byteorder, _set_byteorder)
|
||||||
|
|
||||||
# Property for getting/setting the output dimension.
|
# Property for getting/setting the output dimension.
|
||||||
def _get_outdim(self):
|
@property
|
||||||
|
def outdim(self):
|
||||||
return wkb_writer_get_outdim(self.ptr)
|
return wkb_writer_get_outdim(self.ptr)
|
||||||
|
|
||||||
def _set_outdim(self, new_dim):
|
@outdim.setter
|
||||||
|
def outdim(self, new_dim):
|
||||||
if new_dim not in (2, 3):
|
if new_dim not in (2, 3):
|
||||||
raise ValueError('WKB output dimension must be 2 or 3')
|
raise ValueError('WKB output dimension must be 2 or 3')
|
||||||
wkb_writer_set_outdim(self.ptr, new_dim)
|
wkb_writer_set_outdim(self.ptr, new_dim)
|
||||||
|
|
||||||
outdim = property(_get_outdim, _set_outdim)
|
|
||||||
|
|
||||||
# Property for getting/setting the include srid flag.
|
# Property for getting/setting the include srid flag.
|
||||||
def _get_include_srid(self):
|
@property
|
||||||
|
def srid(self):
|
||||||
return bool(ord(wkb_writer_get_include_srid(self.ptr)))
|
return bool(ord(wkb_writer_get_include_srid(self.ptr)))
|
||||||
|
|
||||||
def _set_include_srid(self, include):
|
@srid.setter
|
||||||
|
def srid(self, include):
|
||||||
if include:
|
if include:
|
||||||
flag = b'\x01'
|
flag = b'\x01'
|
||||||
else:
|
else:
|
||||||
flag = b'\x00'
|
flag = b'\x00'
|
||||||
wkb_writer_set_include_srid(self.ptr, flag)
|
wkb_writer_set_include_srid(self.ptr, flag)
|
||||||
|
|
||||||
srid = property(_get_include_srid, _set_include_srid)
|
|
||||||
|
|
||||||
|
|
||||||
# `ThreadLocalIO` object holds instances of the WKT and WKB reader/writer
|
# `ThreadLocalIO` object holds instances of the WKT and WKB reader/writer
|
||||||
# objects that are local to the thread. The `GEOSGeometry` internals
|
# objects that are local to the thread. The `GEOSGeometry` internals
|
||||||
|
|
|
@ -101,9 +101,8 @@ class GEOSIOTest(SimpleTestCase):
|
||||||
|
|
||||||
# Ensuring bad output dimensions are not accepted
|
# Ensuring bad output dimensions are not accepted
|
||||||
for bad_outdim in (-1, 0, 1, 4, 423, 'foo', None):
|
for bad_outdim in (-1, 0, 1, 4, 423, 'foo', None):
|
||||||
# Equivalent of `wkb_w.outdim = bad_outdim`
|
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
wkb_w._set_outdim(bad_outdim)
|
wkb_w.outdim = bad_outdim
|
||||||
|
|
||||||
# Now setting the output dimensions to be 3
|
# Now setting the output dimensions to be 3
|
||||||
wkb_w.outdim = 3
|
wkb_w.outdim = 3
|
||||||
|
|
Loading…
Reference in New Issue