Beispiel #1
0
 def cardinality(self):
     """
     Returns the cardinality of the node.
     :rtype: dict
     """
     cardinality = {'min': None, 'max': None}
     match = RE_CARDINALITY.match(self.text())
     if match:
         if match.group('min') != '-':
             cardinality['min'] = int(match.group('min'))
         if match.group('max') != '-':
             cardinality['max'] = int(match.group('max'))
     return cardinality
Beispiel #2
0
 def forLabel(cls, value):
     """
     Returns the restriction matching the given label.
     :type value: str
     :rtype: Restriction
     """
     value = value.lower().strip()
     for x in {Restriction.Exists, Restriction.Forall, Restriction.Self}:
         if value == x.toString():
             return x
     match = RE_CARDINALITY.match(value)
     if match:
         return Restriction.Cardinality
     return None
Beispiel #3
0
 def forLabel(cls, label):
     """
     Returns the restriction matching the given label.
     :type label: str
     :rtype: Restriction
     """
     label = label.lower().strip()
     for x in {Restriction.Exists, Restriction.Forall, Restriction.Self}:
         if label == x.label:
             return x
     match = RE_CARDINALITY.match(label)
     if match:
         return Restriction.Cardinality
     return None
Beispiel #4
0
 def forLabel(cls, value):
     """
     Returns the restriction matching the given label.
     :type value: str
     :rtype: Restriction
     """
     value = value.lower().strip()
     for x in {Restriction.Exists, Restriction.Forall, Restriction.Self}:
         if value == x.toString():
             return x
     match = RE_CARDINALITY.match(value)
     if match:
         return Restriction.Cardinality
     return None
Beispiel #5
0
 def forLabel(cls, label):
     """
     Returns the restriction matching the given label.
     :type label: str
     :rtype: Restriction
     """
     label = label.lower().strip()
     for x in {Restriction.Exists, Restriction.Forall, Restriction.Self}:
         if label == x.label:
             return x
     match = RE_CARDINALITY.match(label)
     if match:
         return Restriction.Cardinality
     return None
Beispiel #6
0
 def cardinality(self, *args):
     """
     Returns the cardinality of the node.
     :rtype: T <= int|dict
     """
     cardinality = {'min': None, 'max': None}
     match = RE_CARDINALITY.match(self.text())
     if match:
         if match.group('min') != '-':
             cardinality['min'] = int(match.group('min'))
         if match.group('max') != '-':
             cardinality['max'] = int(match.group('max'))
     if args:
         cardinality = {k:v for k, v in cardinality.items() if k in args}
         if len(cardinality) == 1:
             cardinality = first(cardinality.values())
     return cardinality
Beispiel #7
0
 def cardinality(self, *args):
     """
     Returns the cardinality of the node.
     :rtype: T <= int|dict
     """
     cardinality = {'min': None, 'max': None}
     match = RE_CARDINALITY.match(self.text())
     if match:
         if match.group('min') != '-':
             cardinality['min'] = int(match.group('min'))
         if match.group('max') != '-':
             cardinality['max'] = int(match.group('max'))
     if args:
         cardinality = {k: v for k, v in cardinality.items() if k in args}
         if len(cardinality) == 1:
             cardinality = first(cardinality.values())
     return cardinality