File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 11import ifcopenshell
22import ifcopenshell .geom
33
4- import itertools
54import os
5+ import itertools
66
7- import xlsxwriter
87import csv
8+ import xlsxwriter
99
1010
1111def is_applicability (concept ):
@@ -431,10 +431,14 @@ def transform_data(d):
431431 Transform dictionary keys from tree nodes to rule ids
432432 """
433433
434- return {(k .parent if k .bind is None and k .parent . bind is not None else k ).bind : v for k , v in d .items ()}
434+ return {(k .parent if k .bind is None and ( k .parent is not None and k . parent . bind is not None ) else k ).bind : v for k , v in d .items ()}
435435
436436
437437 def parse_mvdxml_token (v ):
438+ if v .lower () == "true" :
439+ return True
440+ if v .lower () == "false" :
441+ return False
438442 # @todo make more permissive and tolerant
439443 return ast .literal_eval (v )
440444
@@ -468,10 +472,14 @@ def translate(v):
468472 if isinstance (v , str ):
469473 return getattr (operator , v .lower () + "_" )
470474 else :
471- if v .b == "Value" :
475+ if v .b == "Value" or v . b is None :
472476 return d .get (v .a ) == parse_mvdxml_token (v .c )
473477 elif v .b == "Type" :
474- return d .get (v .a ) and d .get (v .a ).is_a (parse_mvdxml_token (v .c ))
478+ return d .get (v .a ) is not None and d .get (v .a ).is_a (parse_mvdxml_token (v .c ))
479+ elif v .b == "Exists" :
480+ return (d .get (v .a ) is not None ) == parse_mvdxml_token (v .c )
481+ else :
482+ raise RuntimeError (f"Invalid rule predicate { v .b } " )
475483
476484 r2 = list (map (translate , r ))
477485 yield reduce (operation_reduce , r2 )
You can’t perform that action at this time.
0 commit comments