def parse(self, trace: T.Optional[str]=None) -> None:
    if (not self.requires_stderr()):
        if ((not self.trace_file_path.exists) and (not self.trace_file_path.is_file())):
            raise CMakeException(f'CMake: Trace file "{self.trace_file_path!s}" not found')
        trace = self.trace_file_path.read_text(errors='ignore', encoding='utf-8')
    if (not trace):
        raise CMakeException('CMake: The CMake trace was not provided or is empty')
    lexer1 = None
    if (self.trace_format == 'human'):
        lexer1 = self._lex_trace_human(trace)
    elif (self.trace_format == 'json-v1'):
        lexer1 = self._lex_trace_json(trace)
    else:
        raise CMakeException(f'CMake: Internal error: Invalid trace format {self.trace_format}. Expected [human, json-v1]')
    for l in lexer1:
        if (l.func in self.delayed_commands):
            self.stored_commands += [l]
            continue
        fn = self.functions.get(l.func, None)
        if fn:
            fn(l)
    for tgt in self.targets.values():
        tgt.strip_properties()
def parse(self, trace: T.Optional[str]=None) -> None:
    if (not self.requires_stderr()):
        if ((not self.trace_file_path.exists) and (not self.trace_file_path.is_file())):
            raise CMakeException(f'CMake: Trace file "{self.trace_file_path!s}" not found')
        trace = self.trace_file_path.read_text(errors='ignore', encoding='utf-8')
    if (not trace):
        raise CMakeException('CMake: The CMake trace was not provided or is empty')
    lexer1 = None
    if (self.trace_format == 'human'):
        lexer1 = self._lex_trace_human(trace)
    elif (self.trace_format == 'json-v1'):
        lexer1 = self._lex_trace_json(trace)
    else:
        raise CMakeException(f'CMake: Internal error: Invalid trace format {self.trace_format}. Expected [human, json-v1]')
    for l in lexer1:
        if (l.func in self.delayed_commands):
            self.stored_commands += [l]
            continue
        fn = self.functions.get(l.func, None)
        if fn:
            fn(l)
    for tgt in self.targets.values():
        tgt.strip_properties()