Generate complete file content for one output module.
(
self,
module_path: str,
module_nodes: List[NodeInfo],
)
| 1012 | return "\n".join(out) |
| 1013 | |
| 1014 | def generate_module( |
| 1015 | self, |
| 1016 | module_path: str, |
| 1017 | module_nodes: List[NodeInfo], |
| 1018 | ) -> str: |
| 1019 | """Generate complete file content for one output module.""" |
| 1020 | if module_path.endswith("__init__.py") and not module_nodes: |
| 1021 | return self._generate_init(module_path) |
| 1022 | |
| 1023 | parts: List[str] = [] |
| 1024 | parts.append(self.HEADER_TEMPLATE) |
| 1025 | bridge_rel = self.dep_analyzer._relative_import(module_path, self.SOURCE_BRIDGE_MODULE) |
| 1026 | bind_names = self._module_stub_names(module_nodes) |
| 1027 | if bind_names: |
| 1028 | parts.append(f"from {bridge_rel} import _split_source_symbol") |
| 1029 | parts.append("") |
| 1030 | parts.append("# Symbols are bound from the original monolith to keep the split package importable.") |
| 1031 | parts.append("# Use FRAMEWORK.md for the architecture map and Clouds_Coder.py for executable source.") |
| 1032 | for name in bind_names: |
| 1033 | parts.append(f"{name} = _split_source_symbol({name!r})") |
| 1034 | if module_path == "__main__.py" and "main" in bind_names: |
| 1035 | parts.append("") |
| 1036 | parts.append('if __name__ == "__main__":') |
| 1037 | parts.append(" main()") |
| 1038 | else: |
| 1039 | parts.append("# No executable top-level symbols are routed to this module.") |
| 1040 | |
| 1041 | return "\n".join(parts) + "\n" |
| 1042 | |
| 1043 | def _module_stub_names(self, module_nodes: List[NodeInfo]) -> List[str]: |
| 1044 | names: List[str] = [] |
no test coverage detected