rope.refactor.move ================== .. py:module:: rope.refactor.move .. autoapi-nested-parse:: A module containing classes for move refactoring `create_move()` is a factory for creating move refactoring objects based on inputs. Classes ------- .. autoapisummary:: rope.refactor.move.MoveMethod rope.refactor.move.MoveGlobal rope.refactor.move.MoveModule rope.refactor.move.ModuleSkipRenamerHandle rope.refactor.move.ModuleSkipRenamer Functions --------- .. autoapisummary:: rope.refactor.move.create_move rope.refactor.move.moving_code_with_imports Module Contents --------------- .. py:function:: create_move(project, resource, offset=None) A factory for creating Move objects Based on `resource` and `offset`, return one of `MoveModule`, `MoveGlobal` or `MoveMethod` for performing move refactoring. .. py:class:: MoveMethod(project, resource, offset) For moving methods It makes a new method in the destination class and changes the body of the old method to call the new method. You can inline the old method to change all of its occurrences. .. py:attribute:: project .. py:attribute:: method_name .. py:attribute:: pyfunction .. py:method:: get_changes(dest_attr: str, new_name: Optional[str] = None, resources: Optional[List[MoveMethod.get_changes.resources]] = None, task_handle=taskhandle.DEFAULT_TASK_HANDLE) Return the changes needed for this refactoring Parameters: - `dest_attr`: the name of the destination attribute - `new_name`: the name of the new method; if `None` uses the old name - `resources` can be a list of `rope.base.resources.File` to apply this refactoring on. If `None`, the restructuring will be applied to all python files. .. py:method:: get_method_name() .. py:method:: get_new_method(name) .. py:class:: MoveGlobal(project, resource, offset) For moving global function and classes .. py:attribute:: project :type: MoveGlobal.project .. py:attribute:: old_pyname .. py:attribute:: source .. py:attribute:: tools .. py:attribute:: import_tools .. py:method:: get_changes(dest: Optional[Union[str, MoveGlobal.get_changes.resources]], resources: Optional[List[MoveGlobal.get_changes.resources]] = None, task_handle=taskhandle.DEFAULT_TASK_HANDLE) Return the changes needed for this refactoring Parameters: - `dest`: the Resource or dotted moddule name of the move destination - `resources` can be a list of `rope.base.resources.File` to apply this refactoring on. If `None`, the restructuring will be applied to all python files. .. py:class:: MoveModule(project, resource) For moving modules and packages .. py:attribute:: project .. py:attribute:: old_pyname .. py:attribute:: source .. py:attribute:: tools .. py:attribute:: import_tools .. py:method:: get_changes(dest: MoveModule.get_changes.resources, resources: Optional[List[MoveModule.get_changes.resources]] = None, task_handle=taskhandle.DEFAULT_TASK_HANDLE) .. py:function:: moving_code_with_imports(project, resource, source) .. py:class:: ModuleSkipRenamerHandle .. py:method:: occurred_outside_skip(change_collector, occurrence) .. py:method:: occurred_inside_skip(change_collector, occurrence) .. py:class:: ModuleSkipRenamer(occurrence_finder, resource, handle=None, skip_start=0, skip_end=0, replacement='') Rename occurrences in a module This class can be used when you want to treat a region in a file separately from other parts when renaming. .. py:attribute:: occurrence_finder .. py:attribute:: resource .. py:attribute:: skip_start :value: 0 .. py:attribute:: skip_end :value: 0 .. py:attribute:: replacement :value: '' .. py:attribute:: handle :value: None .. py:method:: get_changed_module()