MCPcopy
hub / github.com/wshobson/agents / _split_inline_list

Function _split_inline_list

tools/adapters/base.py:178–205  ·  view source on GitHub ↗

Split a comma-separated YAML inline list, respecting single/double-quoted items. Handles `tools: [Read, Grep]` → ['Read', 'Grep'] AND `tools: ["foo, bar", baz]` → ['foo, bar', 'baz']

(inner: str)

Source from the content-addressed store, hash-verified

176
177
178def _split_inline_list(inner: str) -> list[str]:
179 """Split a comma-separated YAML inline list, respecting single/double-quoted items.
180
181 Handles `tools: [Read, Grep]` → ['Read', 'Grep']
182 AND `tools: ["foo, bar", baz]` → ['foo, bar', 'baz']
183 """
184 items: list[str] = []
185 buf: list[str] = []
186 quote: str | None = None
187 for ch in inner:
188 if quote:
189 if ch == quote:
190 quote = None
191 else:
192 buf.append(ch)
193 elif ch in ('"', "'"):
194 quote = ch
195 elif ch == ",":
196 item = "".join(buf).strip()
197 if item:
198 items.append(item)
199 buf = []
200 else:
201 buf.append(ch)
202 tail = "".join(buf).strip()
203 if tail:
204 items.append(tail)
205 return items
206
207
208def split_tools_list(raw) -> list[str]:

Callers 1

parse_frontmatterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected