MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _normalize_list

Function _normalize_list

agents/wiki-agent/ingest/from_feedback.py:17–39  ·  view source on GitHub ↗
(value: Any)

Source from the content-addressed store, hash-verified

15
16
17def _normalize_list(value: Any) -> List[str]:
18 if value is None:
19 return []
20 if isinstance(value, str):
21 text = value.strip()
22 if not text:
23 return []
24 if text.startswith("["):
25 try:
26 import json
27
28 parsed = json.loads(text)
29 if isinstance(parsed, list):
30 return [str(item).strip() for item in parsed if str(item).strip()]
31 except Exception:
32 pass
33 return [text]
34 if isinstance(value, dict):
35 return [str(item).strip() for item in value.values() if str(item).strip()]
36 if isinstance(value, Iterable):
37 return [str(item).strip() for item in value if str(item).strip()]
38 text = str(value).strip()
39 return [text] if text else []
40
41
42def _slug(value: str, max_len: int = 80) -> str:

Callers 2

_keywordsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected