Normalise a paragraph dict so text is a plain string.
(p)
| 60 | |
| 61 | |
| 62 | def _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 | |
| 81 | def migrate(manpage_file, mapping_file, db_path): |