Skip to content

Commit

Permalink
Rewrote tests for Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
John David Reaver committed May 1, 2014
1 parent 6bc4eaf commit a4f2e39
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 310 deletions.
2 changes: 1 addition & 1 deletion python/liblas/guid.py
Expand Up @@ -89,7 +89,7 @@ def __del__(self):

def __str__(self):
"""String representation of the GUID"""
return core.las.LASGuid_AsString(self.handle)
return core.las.LASGuid_AsString(self.handle).decode()

def __eq__(self, other):
"""Test GUID for equality against another :obj:`liblas.guid.GUID`
Expand Down
16 changes: 8 additions & 8 deletions python/liblas/header.py
Expand Up @@ -237,12 +237,12 @@ def get_version(self):

def get_systemid(self):
"""Returns the system identifier specified in the file"""
return core.las.LASHeader_GetSystemId(self.handle)
return str(core.las.LASHeader_GetSystemId(self.handle).decode())

def set_systemid(self, value):
"""Sets the system identifier. The value is truncated to 31
characters"""
return core.las.LASHeader_SetSystemId(self.handle, value[0:31])
return core.las.LASHeader_SetSystemId(self.handle, value[0:31].encode())
doc = """The system identifier. The value is truncated to 31 characters and
defaults to 'libLAS'
Expand Down Expand Up @@ -275,12 +275,12 @@ def set_systemid(self, value):

def get_softwareid(self):
"""Returns the software identifier specified in the file"""
return core.las.LASHeader_GetSoftwareId(self.handle)
return str(core.las.LASHeader_GetSoftwareId(self.handle).decode())

def set_softwareid(self, value):
"""Sets the software identifier.
"""
return core.las.LASHeader_SetSoftwareId(self.handle, value[0:31])
return core.las.LASHeader_SetSoftwareId(self.handle, value[0:31].encode())
doc = """The software identifier. The value is truncated to 31 characters
and defaults to 'libLAS 1.LASVERSION' (ie, libLAS 1.6 for the 1.6
release)
Expand Down Expand Up @@ -389,7 +389,7 @@ def set_dataoffset(self, value):
data_offset = property(get_dataoffset, set_dataoffset, None, doc)

def get_padding(self):
"""Returns number of bytes between the end of the VLRs and the
"""Returns number of bytes between the end of the VLRs and the
beginning of the point data."""
return core.las.LASHeader_GetHeaderPadding(self.handle)

Expand All @@ -398,7 +398,7 @@ def set_padding(self, value):
"""
return core.las.LASHeader_SetHeaderPadding(self.handle, value)
doc = """The number of bytes between the end of the VLRs and the
doc = """The number of bytes between the end of the VLRs and the
beginning of the point data.
"""
padding = property(get_padding, set_padding, None, doc)
Expand Down Expand Up @@ -794,5 +794,5 @@ def set_srs(self, value):

def get_xml(self):
return core.las.LASHeader_GetXML(self.handle)
xml = property(get_xml, None, None, None)

xml = property(get_xml, None, None, None)
62 changes: 31 additions & 31 deletions python/liblas/point.py
Expand Up @@ -94,10 +94,10 @@ def get_x(self):

def set_x(self, value):
"""Sets the X coordinate of the LAS point to a floating point
value.
..note::
The point will be descaled according to the :obj:`liblas.point.Point.header`'s
value.
..note::
The point will be descaled according to the :obj:`liblas.point.Point.header`'s
scale value for the X dimension.
"""

Expand All @@ -114,10 +114,10 @@ def get_raw_x(self):

def set_raw_x(self, value):
"""Sets the X coordinate of the LAS point to an integer value
value.
..note::
The point will be scaled according to the obj:`liblas.point.Point.header`'s
value.
..note::
The point will be scaled according to the obj:`liblas.point.Point.header`'s
scale value for the X dimension when returned as a double obj:`liblas.point.Point.x`.
"""
return core.las.LASPoint_SetRawX(self.handle, value)
Expand All @@ -137,10 +137,10 @@ def get_y(self):

def set_y(self, value):
"""Sets the Y coordinate of the LAS point to a floating point
value.
..note::
The point will be descaled according to the :obj:`liblas.point.Point.header`'s
value.
..note::
The point will be descaled according to the :obj:`liblas.point.Point.header`'s
scale value for the Y dimension.
"""
return core.las.LASPoint_SetY(self.handle, value)
Expand All @@ -158,10 +158,10 @@ def get_raw_y(self):

def set_raw_y(self, value):
"""Sets the Y coordinate of the LAS point to an integer value
value.
..note::
The point will be scaled according to the obj:`liblas.point.Point.header`'s
value.
..note::
The point will be scaled according to the obj:`liblas.point.Point.header`'s
scale value for the Y dimension when returned as a double obj:`liblas.point.Point.y`.
"""
return core.las.LASPoint_SetRawY(self.handle, value)
Expand All @@ -179,10 +179,10 @@ def get_z(self):

def set_z(self, value):
"""Sets the Z coordinate of the LAS point to a floating point
value.
..note::
The point will be descaled according to the obj:`liblas.point.Point.header`'s
value.
..note::
The point will be descaled according to the obj:`liblas.point.Point.header`'s
scale value for the Z dimension.
"""
return core.las.LASPoint_SetZ(self.handle, value)
Expand All @@ -199,10 +199,10 @@ def get_raw_z(self):

def set_raw_z(self, value):
"""Sets the Z coordinate of the LAS point to an integer value
value.
..note::
The point will be scaled according to the obj:`liblas.point.Point.header`'s
value.
..note::
The point will be scaled according to the obj:`liblas.point.Point.header`'s
scale value for the Z dimension when returned as a double obj:`liblas.point.Point.y`.
"""
return core.las.LASPoint_SetRawZ(self.handle, value)
Expand All @@ -214,7 +214,7 @@ def set_raw_z(self, value):
Use obj:`liblas.point.Point.z` if you want the scaled ``z`` data.
"""
raw_z = property(get_raw_z, set_raw_z, None, doc)

def get_return_number(self):
"""Returns the return number of the point"""
return core.las.LASPoint_GetReturnNumber(self.handle)
Expand Down Expand Up @@ -544,15 +544,15 @@ def set_color(self, value):

def get_header(self):
return header.Header(handle=core.las.LASPoint_GetHeader(self.handle))

def set_header(self, value):
return core.las.LASPoint_SetHeader(self.handle, value.handle)
header = property(get_header, set_header, None, None)


def get_xml(self):
return core.las.LASPoint_GetXML(self.handle)
return str(core.las.LASPoint_GetXML(self.handle).decode())

xml = property(get_xml, None, None, None)


Expand All @@ -562,12 +562,12 @@ def get_data(self):
d2 = ctypes.cast(d, ctypes.POINTER(ctypes.c_ubyte))
core.las.LASPoint_GetData(self.handle, d2)
return d

def set_data(self, data):
d = ctypes.cast(data, ctypes.POINTER(ctypes.c_ubyte))

core.las.LASPoint_SetData(self.handle, d, len(data))

doc = """Raw data for the point. Shoot yourself in the foot if you must!
"""
data = property(get_data, set_data, None, doc)
2 changes: 1 addition & 1 deletion python/liblas/srs.py
Expand Up @@ -115,7 +115,7 @@ def set_userinput(self, value):

def get_proj4(self):
"""Returns a Proj.4_ string that describes the SRS"""
return core.las.LASSRS_GetProj4(self.handle)
return str(core.las.LASSRS_GetProj4(self.handle).decode())

def set_proj4(self, value):
"""Sets the SRS description with a given Proj.4_ string"""
Expand Down
8 changes: 4 additions & 4 deletions python/tests/Color.txt
Expand Up @@ -6,7 +6,7 @@
0
>>> c.blue
0

>>> c = color.Color(red = 123, blue = 125, green = 124)
>>> c.red
123
Expand All @@ -17,10 +17,10 @@


>>> for i in c:
... print i
... print(i)
123
124
125

>>> list(c)
[123, 124, 125]
[123, 124, 125]

0 comments on commit a4f2e39

Please sign in to comment.