Skip to content

Commit

Permalink
Add OEM constraint to enforce consistent object (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradsease committed Jun 3, 2020
1 parent e62c6f0 commit 951c5c5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions oem/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ def func(self, oem):
)


class ConstrainOemObject(Constraint):
"""Apply constraint to OEM OBJECT_NAME and OBJECT_ID."""

versions = ["1.0", "2.0"]

def func(self, oem):
object_name = oem._segments[0].metadata["OBJECT_NAME"]
object_id = oem._segments[0].metadata["OBJECT_ID"]
for segment in oem:
require(
segment.metadata["OBJECT_NAME"] == object_name,
"OBJECT_NAME not fixed in OEM"
)
require(
segment.metadata["OBJECT_ID"] == object_id,
"OBJECT_ID not fixed in OEM"
)


class ConstrainOemStates(Constraint):
'''Apply constraints to OEM data sections'''

Expand Down Expand Up @@ -103,6 +122,7 @@ class method. For example, to convert a KVN OEM to XML:

_constraint_spec = ConstraintSpecification(
ConstrainOemTimeSystem,
ConstrainOemObject,
ConstrainOemStates
)

Expand Down

0 comments on commit 951c5c5

Please sign in to comment.