MCPcopy
hub / github.com/microsoft/PyRIT / write

Method write

pyrit/memory/migration.py:177–200  ·  view source on GitHub ↗

Write text to the underlying stream, prefixing the start of each line. Args: text (str): The text to write. Returns: int: The number of characters of the original text written.

(self, text: str)

Source from the content-addressed store, hash-verified

175 self._at_line_start = True
176
177 def write(self, text: str) -> int:
178 """
179 Write text to the underlying stream, prefixing the start of each line.
180
181 Args:
182 text (str): The text to write.
183
184 Returns:
185 int: The number of characters of the original text written.
186 """
187 if not text:
188 return 0
189
190 chunks: list[str] = []
191 for char in text:
192 if self._at_line_start and char != "\n":
193 chunks.append(self._prefix)
194 self._at_line_start = False
195 chunks.append(char)
196 if char == "\n":
197 self._at_line_start = True
198
199 self._stream.write("".join(chunks))
200 return len(text)
201
202 def __getattr__(self, name: str) -> Any:
203 """

Callers 15

create_key_vaultFunction · 0.80
to_json_fileMethod · 0.80
to_json_fileMethod · 0.80
_write_syncMethod · 0.80
export_to_markdownMethod · 0.80
play_animationFunction · 0.80
_append_jsonl_entryFunction · 0.80
convert_asyncMethod · 0.80
convert_asyncMethod · 0.80

Calls

no outgoing calls