Skip to content

Commit 4f31158

Browse files
committed
[section] Add sec card accessort methods
1 parent 8e50deb commit 4f31158

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

odml/section.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def __init__(self, name=None, type="n.s.", parent=None,
9999

100100
# This might lead to a validation warning, since properties are set
101101
# at a later point in time.
102+
self.sec_cardinality = sec_cardinality
102103
self.prop_cardinality = prop_cardinality
103104

104105
for err in validation.Validation(self).errors:
@@ -365,6 +366,34 @@ def get_repository(self):
365366
def repository(self, url):
366367
base.Sectionable.repository.fset(self, url)
367368

369+
@property
370+
def sec_cardinality(self):
371+
"""
372+
The Section cardinality of a Section. It defines how many Sections
373+
are minimally required and how many Sections should be maximally
374+
stored. Use the 'set_sections_cardinality' method to set.
375+
"""
376+
return self._sec_cardinality
377+
378+
@sec_cardinality.setter
379+
def sec_cardinality(self, new_value):
380+
"""
381+
Sets the Sections cardinality of a Section.
382+
383+
The following cardinality cases are supported:
384+
(n, n) - default, no restriction
385+
(d, n) - minimally d entries, no maximum
386+
(n, d) - maximally d entries, no minimum
387+
(d, d) - minimally d entries, maximally d entries
388+
389+
Only positive integers are supported. 'None' is used to denote
390+
no restrictions on a maximum or minimum.
391+
392+
:param new_value: Can be either 'None', a positive integer, which will set
393+
the maximum or an integer 2-tuple of the format '(min, max)'.
394+
"""
395+
self._sec_cardinality = format_cardinality(new_value)
396+
368397
@property
369398
def prop_cardinality(self):
370399
"""

0 commit comments

Comments
 (0)