rope.base.libutils

A few useful functions for using rope as a library

Functions

path_to_resource(project, path[, type])

Get the resource at path

path_relative_to_project_root(project, path)

relative(root, path)

report_change(project, path, old_content)

Report that the contents of file at path was changed

analyze_module(project, resource)

Perform static object analysis on a python file in the project

analyze_modules(project[, task_handle])

Perform static object analysis on all python files in the project

get_string_module(project, code[, resource, force_errors])

Returns a PyObject object for the given code

get_string_scope(project, code[, resource])

Returns a Scope object for the given code

is_python_file(project, resource)

modname(resource)

Module Contents

rope.base.libutils.path_to_resource(project, path, type=None)

Get the resource at path

You only need to specify type if path does not exist. It can be either ‘file’ or ‘folder’. If the type is None it is assumed that the resource already exists.

Note that this function uses Project.get_resource(), Project.get_file(), and Project.get_folder() methods.

rope.base.libutils.path_relative_to_project_root(project, path)
rope.base.libutils.relative(root, path)
rope.base.libutils.report_change(project, path, old_content)

Report that the contents of file at path was changed

The new contents of file is retrieved by reading the file.

rope.base.libutils.analyze_module(project, resource)

Perform static object analysis on a python file in the project

Note that this might be really time consuming.

rope.base.libutils.analyze_modules(project, task_handle=taskhandle.DEFAULT_TASK_HANDLE)

Perform static object analysis on all python files in the project

Note that this might be really time consuming.

rope.base.libutils.get_string_module(project, code, resource=None, force_errors=False)

Returns a PyObject object for the given code

If force_errors is True, exceptions.ModuleSyntaxError is raised if module has syntax errors. This overrides ignore_syntax_errors project config.

rope.base.libutils.get_string_scope(project, code, resource=None)

Returns a Scope object for the given code

rope.base.libutils.is_python_file(project, resource)
rope.base.libutils.modname(resource)