MCPcopy
hub / github.com/openai/gpt-oss / read_str

Method read_str

gpt_oss/tools/apply_patch.py:114–125  ·  view source on GitHub ↗

Consume the current line if it starts with *prefix* and return the text **after** the prefix. Raises if prefix is empty.

(self, prefix: str)

Source from the content-addressed store, hash-verified

112 return self._norm(self._cur_line()).startswith(prefix)
113
114 def read_str(self, prefix: str) -> str:
115 """
116 Consume the current line if it starts with *prefix* and return the text
117 **after** the prefix. Raises if prefix is empty.
118 """
119 if prefix == "":
120 raise ValueError("read_str() requires a non-empty prefix")
121 if self._norm(self._cur_line()).startswith(prefix):
122 text = self._cur_line()[len(prefix) :]
123 self.index += 1
124 return text
125 return ""
126
127 def read_line(self) -> str:
128 """Return the current raw line and advance."""

Callers 2

parseMethod · 0.95
_parse_update_fileMethod · 0.95

Calls 3

_normMethod · 0.95
_cur_lineMethod · 0.95
startswithMethod · 0.80

Tested by

no test coverage detected