Skip to content

Commit

Permalink
docs: add and update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
smlng committed Apr 10, 2021
1 parent 172bd91 commit e9b0235
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions cayennelpp/lpp_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class LppFrame(object):
Attributes:
data (list): a list of LppData objects
maxsize (int): (otpional) byte size limit
"""

def __init__(self, data=None, maxsize=0):
Expand Down
8 changes: 6 additions & 2 deletions cayennelpp/lpp_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, type_, name, sizes, scales, signs):
self.signs = signs

def __int__(self):
"""Return LppType attribute as integer."""
"""Return LppType as integer, i.e. its numeric type."""
return self.type

@staticmethod
Expand Down Expand Up @@ -106,7 +106,7 @@ def __to_unsigned(val):

@classmethod
def get_lpp_type(cls, type_):
"""Returns LppType object for given type or `None` if not found."""
"""Return LppType object for given type or `None` if not found."""
if not isinstance(type_, int):
raise TypeError('Parameter (type_) must be an integer!')

Expand All @@ -116,13 +116,16 @@ def get_lpp_type(cls, type_):

@property
def dimension(self):
"""Return number of value dimensions."""
return len(self.sizes)

@property
def size(self):
"""Return size of byte string representation."""
return sum(self.sizes)

def decode(self, buf):
"""Parse LppType from a byte string."""
if len(buf) != sum(self.sizes):
raise BufferError('Invalid buffer length!')
data = []
Expand All @@ -138,6 +141,7 @@ def decode(self, buf):
return tuple(data)

def encode(self, data):
"""Convert LppType into a byte string."""
data = self.__assert_data_tuple(data, len(self.sizes))
buf = bytearray(sum(self.sizes))
pos = 0
Expand Down

0 comments on commit e9b0235

Please sign in to comment.