MCPcopy Create free account
hub / github.com/IENT/YUView / ContainerIf

Class ContainerIf

tools/standardTextToCode/parseTables.py:280–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278 print(f"Table: {self.name}")
279
280class ContainerIf(Container):
281 def __init__(self, parent):
282 super().__init__(parent)
283 self.condition = None
284 self.isElseIf = False
285 self.isElse = False
286 def fromText(self, text : str):
287 if (not text.startswith("if") and not text.startswith("else if") and not text.startswith("} else") and not text.startswith("else")):
288 raise SyntaxError("If container does not start with if or else if")
289 if (text.startswith("else if")):
290 self.isElseIf = True
291 if (text.startswith("} else") or text.startswith("else")):
292 self.isElse = True
293 return
294 start = text.find("(")
295 end = text.rfind(")")
296 if (start == -1 or end == -1):
297 raise SyntaxError("If condition does not contain brackets")
298 self.condition = cleanCondition(text[start+1:end])
299 def __str__(self):
300 spaces = ""
301 for _ in range(self.parent.depth):
302 spaces += " "
303 if (self.isElse):
304 return f"{spaces}else"
305 if (self.isElseIf):
306 return f"{spaces}else if({self.condition})"
307 return f"{spaces}if({self.condition})"
308
309class ContainerWhile(Container):
310 def __init__(self, parent):

Callers 1

parseChildrenMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected