2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-24 04:04:20 +00:00

Updating application attributes

This change updates the various Application attributes, adding inline
documentation, and reorganizing the different related test suites. Minor
updates to supporting primitive objects are included.
This commit is contained in:
Peter Hamilton
2015-02-23 14:13:21 -05:00
parent 0cd2d3dab6
commit 0c4f9cd9d0
9 changed files with 576 additions and 164 deletions

View File

@@ -81,15 +81,7 @@ class Base(object):
min_bytes = 'a minimum of {0} bytes'.format(self.LENGTH_SIZE)
raise errors.ReadValueError(Base.__name__, 'length', min_bytes,
'{0} bytes'.format(num_bytes))
length = unpack('!I', lst)[0]
# Verify that the length matches the expected length, if one exists
if self.length is not None:
if length is not self.length:
raise errors.ReadValueError(Base.__name__, 'length',
self.length, length)
else:
self.length = length
self.length = unpack('!I', lst)[0]
def read_value(self, istream):
raise NotImplementedError()
@@ -487,7 +479,11 @@ class TextString(Base):
def __init__(self, value=None, tag=Tags.DEFAULT):
super(TextString, self).__init__(tag, type=Types.TEXT_STRING)
self.value = value
if value is None:
self.value = ''
else:
self.value = value
self.validate()