MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / ListNode

Class ListNode

src/ifcopenshell-python/ifcopenshell/express/nodes.py:54–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53
54class ListNode:
55 def __init__(self, s, loc, tokens, rule=None):
56 self.rule = rule or (type(self).__name__)
57 self.tokens = tokens.asList()
58 self.dict_tokens = collections.defaultdict(list)
59
60 rules_as_list = set()
61 for t in self.tokens:
62 r = getattr(t, "rule", None)
63 if r:
64 rules_as_list.add(r)
65 self.dict_tokens[r].append(t)
66
67 for r, t in tokens.asDict().items():
68 if r not in rules_as_list:
69 self.dict_tokens[r].append(t)
70
71 self.flat = sum([getattr(t, "flat", [t]) for t in self.tokens], [])
72
73 def __repr__(self):
74 return "%s[%s]" % (self.rule, ",".join("%s" % i for i in self.tokens))
75
76 def __iter__(self):
77 return iter(self.tokens)
78
79 # Somehow indexing messes up the pyparsing results, so instead of x[0] use list(x)[0]
80 # def __getitem__(self, i):
81 # return self.tokens[i]
82
83 def init(self):
84 pass
85
86
87class SimpleType(Node):

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected