MCPcopy
hub / github.com/huggingface/transformers / parse_line

Function parse_line

utils/extract_warnings.py:20–38  ·  view source on GitHub ↗
(fp)

Source from the content-addressed store, hash-verified

18 buffer = []
19
20 def parse_line(fp):
21 for line in fp:
22 if isinstance(line, bytes):
23 line = line.decode("UTF-8")
24 if "warnings summary (final)" in line:
25 continue
26 # This means we are outside the body of a warning
27 elif not line.startswith(" "):
28 # process a single warning and move it to `selected_warnings`.
29 if len(buffer) > 0:
30 warning = "\n".join(buffer)
31 # Only keep the warnings specified in `targets`
32 if any(f": {x}: " in warning for x in targets):
33 selected_warnings.add(warning)
34 buffer.clear()
35 continue
36 else:
37 line = line.strip()
38 buffer.append(line)
39
40 if from_gh:
41 for filename in os.listdir(artifact_path):

Callers 1

Calls 4

joinMethod · 0.80
decodeMethod · 0.45
addMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected