feat: adicionando return a parse_chunk e yield a parse

adicionando return do header tipo 7 a função parse_chunk

adicionando yield a função parse para cada evento
This commit is contained in:
aulojor
2025-11-01 16:57:32 -01:00
parent c855dca7be
commit b0d8c55bb5

View File

@@ -26,7 +26,7 @@ def parse():
chunks = boundaries(data) chunks = boundaries(data)
for c in chunks: for c in chunks:
parse_chunk(data[c[0]:c[1]]) yield parse_chunk(data[c[0]:c[1]])
fp.close() fp.close()
@@ -55,9 +55,10 @@ def parse_chunk(chunk_lines: list[str]):
raise ValueError("Expected a '7' phase header in chunk_lines") raise ValueError("Expected a '7' phase header in chunk_lines")
else: else:
headersRet = parse_header(chunk_lines[:hIdx]) headersRet = parse_header(chunk_lines[:hIdx])
# TODO: implementar o parser das fases parser_type_7 phaseRet = parse_type_7(chunk_lines[hIdx+1:])
eventData = headersRet | phaseRet
return headersRet return eventData
def parse_header(hLines: list[str]): def parse_header(hLines: list[str]):
@@ -142,7 +143,6 @@ def parse_type_7(data: list[str]):
phases = [] phases = []
# nordic format # nordic format
for l in data: for l in data:
print(l)
h = int(l[18:20]) h = int(l[18:20])
m = int(l[20:22]) m = int(l[20:22])
sec = int(l[23:25]) sec = int(l[23:25])
@@ -171,4 +171,4 @@ def parse_type_i(data: list[str]):
FUNCS = {1: parse_type_1, 3: parse_type_3, 6: parse_type_6, "E": parse_type_e, "F": parse_type_f, "I": parse_type_i} FUNCS = {1: parse_type_1, 3: parse_type_3, 6: parse_type_6, "E": parse_type_e, "F": parse_type_f, "I": parse_type_i}
parse() print(next(parse()))