move_and_rename_module
Moves a Python module to a folder, optionally renames it, and fixes imports from both the source and destination packages.
Instructions
Move a module to a folder and optionally rename it.
This is a two-step operation:
Move module to destination folder
Rename the module (if new_name provided or auto-detected)
Auto-detection: If module is foo_bar.py and dest is foo/,
it will automatically strip the foo_ prefix → foo/bar.py
Includes workaround for Rope bug: Files that import from BOTH the destination package AND the module being moved are temporarily hidden during the move, then their imports are fixed manually.
Example: move_and_rename_module( "views/service_contractor_extra.py", "views/service_contractor/", new_name="extra" # or None for auto-detect ) Result: views/service_contractor/extra.py
Args: project_path: Root directory of the Python project module_path: Path to module file (relative to project_path) dest_folder: Destination folder path (relative to project_path) new_name: New name for the module (without .py), or None to auto-detect
Returns: JSON with success status and list of changed files
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | Yes | ||
| module_path | Yes | ||
| dest_folder | Yes | ||
| new_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |