Skip to content

Commit

Permalink
Merge pull request #98 from jokva/reorder-attribute-update
Browse files Browse the repository at this point in the history
Reorder attribte updates in basicobject.load
  • Loading branch information
jokva authored Apr 26, 2019
2 parents 7015948 + 56a1ec2 commit 211e89d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions python/dlisio/plumbing/basicobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,21 @@ def load(cls, obj, name = None):
if value is None: continue

attr, value_type = attrs[label]
if value_type == ValueTypeBoolean:
if value[0]: setattr(self, attr, True)
else: setattr(self, attr, False)

elif value_type == ValueTypeScalar:
if value_type == ValueTypeScalar:
setattr(self, attr, value[0])

elif value_type == ValueTypeVector:
setattr(self, attr, value)

elif value_type == ValueTypeBoolean:
setattr(self, attr, bool(value[0]))

else:
problem = 'unknown value extraction descriptor {}'
solution = 'should be either scalar, vector, or boolean'
msg = ', '.join((problem.format(value_type), solution))
raise ValueError(msg)


self.stripspaces()
return self

0 comments on commit 211e89d

Please sign in to comment.