MCPcopy
hub / github.com/xming521/WeClone / write

Method write

weclone/utils/log.py:61–82  ·  view source on GitHub ↗
(self, data_chunk)

Source from the content-addressed store, hash-verified

59 self.current_line_content = "" # Represents the current state of the line to be logged
60
61 def write(self, data_chunk):
62 self.original_stream.write(data_chunk) # Pass through to console
63
64 if data_chunk.endswith("\\r") and "\\n" not in data_chunk:
65 self.current_line_content = data_chunk[:-1] # Store without the trailing \\r
66 return
67
68 full_buffer = self.current_line_content + data_chunk
69 lines_to_process = full_buffer.split("\\n")
70
71 for i in range(len(lines_to_process) - 1):
72 line = lines_to_process[i]
73 final_content_of_line = line
74 last_cr = line.rfind("\\r")
75 if last_cr != -1:
76 final_content_of_line = line[last_cr + 1 :]
77
78 escaped_log = final_content_of_line.replace("{", "{{").replace("}", "}}")
79 if final_content_of_line.strip() or line:
80 self.log_method(escaped_log, raw=True)
81
82 self.current_line_content = lines_to_process[-1]
83
84 def flush(self):
85 self.original_stream.flush()

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by 1

mainFunction · 0.64