mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
add length restriction
both length and min/maxlength added
This commit is contained in:
@@ -247,17 +247,21 @@ class restriction:
|
|||||||
if n[6:9] == 'Inc':
|
if n[6:9] == 'Inc':
|
||||||
self.options[0] += '='
|
self.options[0] += '='
|
||||||
self.options[0] += node[n]['@value']
|
self.options[0] += node[n]['@value']
|
||||||
#TODO implement other restrictions
|
elif n[-5:] == "ength":
|
||||||
# elif n.nodeType == n.ELEMENT_NODE and n.tagName.endswith("length"):
|
self.type = "length"
|
||||||
# self.type = "length"
|
if n[3:6] == "min":
|
||||||
# self.options.append(n.getAttribute("value"))
|
self.options.append('>=')
|
||||||
# elif n.nodeType == n.ELEMENT_NODE and n.tagName.endswith("pattern"):
|
elif n[3:6] == "max":
|
||||||
# self.type = "pattern"
|
self.options.append('<=')
|
||||||
# self.options.append(n.getAttribute("value"))
|
else:
|
||||||
#TODO add min/maxLength
|
self.options.append('==')
|
||||||
#TODO add fractionDigits
|
self.options[-1] += str(node[n]['@value'])
|
||||||
#TODO add totalDigits
|
elif n[3:] == "pattern":
|
||||||
#TODO add whiteSpace
|
self.type = "pattern"
|
||||||
|
self.options.append(node[n]['@value'])
|
||||||
|
#TODO add fractionDigits
|
||||||
|
#TODO add totalDigits
|
||||||
|
#TODO add whiteSpace
|
||||||
else:
|
else:
|
||||||
logger.error({'result':'ERROR', 'sentence':'Restriction not implemented'})
|
logger.error({'result':'ERROR', 'sentence':'Restriction not implemented'})
|
||||||
|
|
||||||
@@ -271,10 +275,14 @@ class restriction:
|
|||||||
result = False
|
result = False
|
||||||
return result
|
return result
|
||||||
elif self.type == "length":
|
elif self.type == "length":
|
||||||
return False #TODO
|
result = True
|
||||||
|
for op in self.options:
|
||||||
|
if not(eval(str(len(other))+op)):
|
||||||
|
result = False
|
||||||
|
return result
|
||||||
elif self.type == "pattern":
|
elif self.type == "pattern":
|
||||||
return False #TODO
|
#TODO verify XML pattern
|
||||||
#TODO add min/maxLength
|
return False
|
||||||
#TODO add fractionDigits
|
#TODO add fractionDigits
|
||||||
#TODO add totalDigits
|
#TODO add totalDigits
|
||||||
#TODO add whiteSpace
|
#TODO add whiteSpace
|
||||||
@@ -286,10 +294,9 @@ class restriction:
|
|||||||
self.options.sort()
|
self.options.sort()
|
||||||
return "of type '%s', having a value %s" % (self.restriction_on, ' and '.join(self.options))
|
return "of type '%s', having a value %s" % (self.restriction_on, ' and '.join(self.options))
|
||||||
elif self.type == "length":
|
elif self.type == "length":
|
||||||
return "of type '%s' with a length of %s" % (self.restriction_on, str(self.options[0]))
|
return "of type '%s' with %s letters" % (self.restriction_on, ' and '.join(self.options))
|
||||||
elif self.type == "pattern":
|
elif self.type == "pattern":
|
||||||
return "of type '%s' respecting pattern '%s'" % (self.restriction_on, self.options[0])
|
return "of type '%s' respecting pattern '%s'" % (self.restriction_on, ' and '.join(self.options))
|
||||||
#TODO add min/maxLength
|
|
||||||
#TODO add fractionDigits
|
#TODO add fractionDigits
|
||||||
#TODO add totalDigits
|
#TODO add totalDigits
|
||||||
#TODO add whiteSpace
|
#TODO add whiteSpace
|
||||||
|
|||||||
Reference in New Issue
Block a user