rope /

Filename Size Date modified Message
docs
rope
ropetest
654 B
17.6 KB
137 B
4.3 KB
1.5 KB

rope, a python refactoring library ...

Overview

Rope is a python refactoring library.

New Features

  • inline variable can now inline variable in other modules
  • handling only_current option for inline in other modules
  • better extension module handling
  • added rope.contrib.findit.find_definition()
  • added rope.contrib.changestack module to perform many refactorings as a single command
  • added rope.contrib.fixmodnames for fixing module and package names
  • added rope.contrib.finderrors module for finding bad name and attribute accesses
  • added region field to rope.contrib.findit.Location
  • added remove_self argument to codeassist.get_calltip()

Inline Refactoring Enhancements

Inline variable can now inline variables in other (the ones not containing the definition) modules. It adds import to changed modules when needed.

One problem for inline refactoring is from-imports. If a name is imported as from mod import f then after removing the definition of f, these imports should be removed; rope does this now.

Also only_current option of inline didn't work in other modules; it was fixed.

rope.contrib.changestack

changestack module can be used to perform many refactorings on top of each other as one bigger command. It can be used like:

stack = ChangeStack(project, 'my big command')

#..
stack.push(refactoring1.get_changes())
#..
stack.push(refactoring2.get_changes())
#..
stack.push(refactoringX.get_changes())

stack.pop_all()
changes = stack.merged()

Now changes can be previewed or performed as before.

rope.contrib.fixmodnames

This module is useful when you want to rename many of the modules in your project. That can happen specially when you want to change their naming style.

For instance:

fixmods = FixModuleNames(project)
changes = fixmods.get_changes(fixer=str.lower)
project.do(changes)

renames all modules and packages to use lower-cased chars. You can tell it to use any other style by using the fixer argument.

rope.contrib.finderrors

find_errors function can be used to find possible bad name and attribute accesses. As an example:

errors = find_errors(project, project.get_resource('mod.py'))
for error in errors:
    print '%s: %s' % (error.lineno, error.error)

prints possible errors for mod.py file.

Currently this module is experimental and reports many false-positives. Contributions are welcome.

rope.contrib.findit.find_definition

This function finds the definition of a name, just like the older rope.contrib.codeassist.get_definition_location function. The difference is it returns a findit.Location object like other functions is findit module.

Also rope.contrib.findit.Location has a new field called region it is a tuple that holds the start and end offset of the occurrence; this can probably be used in IDE's that highlight locations.

Better Extension Module Handling

extension_modules project config tells rope to import these modules if their source code cannot be found. Rope can now handle nested extension modules in normal packages.

Getting Started

To change your project preferences edit $PROJECT_ROOT/.ropeproject/config.py where $PROJECT_ROOT is the root folder of your project (this file is created the first time you open a project).

Bug Reports

Send your bug reports and feature requests to rope-dev (at) googlegroups.com.

License

This program is under the terms of GPL (GNU General Public License). Have a look at COPYING file for more information.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.