MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _parse_json_list

Function _parse_json_list

server/services/batch_parser.py:118–144  ·  view source on GitHub ↗
(
    row: Dict[str, Any],
    column: Optional[str],
    row_index: int,
)

Source from the content-addressed store, hash-verified

116
117
118def _parse_json_list(
119 row: Dict[str, Any],
120 column: Optional[str],
121 row_index: int,
122) -> List[str]:
123 if not column:
124 return []
125 raw_value = row.get(column)
126 if raw_value is None or (isinstance(raw_value, float) and pd.isna(raw_value)):
127 return []
128 if isinstance(raw_value, list):
129 return _ensure_string_list(raw_value, row_index, "Attachments")
130 if isinstance(raw_value, str):
131 if not raw_value.strip():
132 return []
133 try:
134 parsed = json.loads(raw_value)
135 except json.JSONDecodeError as exc:
136 raise ValidationError(
137 f"Invalid JSON in Attachments: {exc}",
138 details={"row_index": row_index},
139 )
140 return _ensure_string_list(parsed, row_index, "Attachments")
141 raise ValidationError(
142 "Attachments must be a JSON list",
143 details={"row_index": row_index},
144 )
145
146
147def _parse_json_dict(

Callers 1

_parse_dataframeFunction · 0.85

Calls 3

ValidationErrorClass · 0.90
_ensure_string_listFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected