rope.refactor.move

A module containing classes for move refactoring

create_move() is a factory for creating move refactoring objects based on inputs.

Classes

MoveMethod

For moving methods

MoveGlobal

For moving global function and classes

MoveModule

For moving modules and packages

ModuleSkipRenamerHandle

ModuleSkipRenamer

Rename occurrences in a module

Functions

create_move(project, resource[, offset])

A factory for creating Move objects

moving_code_with_imports(project, resource, source)

Module Contents

rope.refactor.move.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.

class rope.refactor.move.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.

project
method_name
pyfunction
get_changes(dest_attr: str, new_name: str | None = None, resources: List[MoveMethod.get_changes.resources] | None = 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.

get_method_name()
get_new_method(name)
class rope.refactor.move.MoveGlobal(project, resource, offset)

For moving global function and classes

project: MoveGlobal.project
old_pyname
source
tools
import_tools
get_changes(dest: str | MoveGlobal.get_changes.resources | None, resources: List[MoveGlobal.get_changes.resources] | None = 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.

class rope.refactor.move.MoveModule(project, resource)

For moving modules and packages

project
old_pyname
source
tools
import_tools
get_changes(dest: MoveModule.get_changes.resources, resources: List[MoveModule.get_changes.resources] | None = None, task_handle=taskhandle.DEFAULT_TASK_HANDLE)
rope.refactor.move.moving_code_with_imports(project, resource, source)
class rope.refactor.move.ModuleSkipRenamerHandle
occurred_outside_skip(change_collector, occurrence)
occurred_inside_skip(change_collector, occurrence)
class rope.refactor.move.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.

occurrence_finder
resource
skip_start = 0
skip_end = 0
replacement = ''
handle = None
get_changed_module()