MCPcopy Index your code
hub / github.com/idank/explainshell / _para_to_store

Function _para_to_store

tools/migrate_mongo_to_sqlite.py:62–78  ·  view source on GitHub ↗

Normalise a paragraph dict so text is a plain string.

(p)

Source from the content-addressed store, hash-verified

60
61
62def _para_to_store(p):
63 """Normalise a paragraph dict so text is a plain string."""
64 text = p.get("text", "")
65 if isinstance(text, bytes):
66 text = text.decode("utf-8")
67 return {
68 "idx": p.get("idx", 0),
69 "text": text,
70 "section": p.get("section", ""),
71 "is_option": p.get("is_option", False),
72 # option-specific fields (absent for plain paragraphs)
73 **{
74 k: p[k]
75 for k in ("short", "long", "expectsarg", "argument", "nestedcmd")
76 if k in p
77 },
78 }
79
80
81def migrate(manpage_file, mapping_file, db_path):

Callers 1

migrateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected