| 1077 | return f"# {pkg}\n" |
| 1078 | |
| 1079 | def generate_root_init(self, all_modules: List[str]) -> str: |
| 1080 | sub_modules = sorted( |
| 1081 | m.split("/")[0] |
| 1082 | for m in all_modules |
| 1083 | if "/" in m and not m.startswith("_") |
| 1084 | ) |
| 1085 | seen: Set[str] = set() |
| 1086 | unique = [x for x in sub_modules if not (x in seen or seen.add(x))] # type: ignore |
| 1087 | lines = ["# Auto-generated package root.", ""] |
| 1088 | for mod in unique: |
| 1089 | lines.append(f"from . import {mod} as {mod}") |
| 1090 | return "\n".join(lines) + "\n" |
| 1091 | |
| 1092 | def _rewrite_context_sensitive_source(self, node: NodeInfo, src: str) -> str: |
| 1093 | """Patch a small set of known context-sensitive snippets after relocation.""" |