rope.refactor.similarfinder

This module can be used for finding similar code

Exceptions

BadNameInCheckError

Errors for performing a refactoring

Classes

SimilarFinder

SimilarFinder can be used to find similar pieces of code

RawSimilarFinder

A class for finding similar expressions and statements

Match

ExpressionMatch

StatementMatch

CodeTemplate

Functions

make_pattern(code, variables)

Module Contents

exception rope.refactor.similarfinder.BadNameInCheckError

Bases: rope.base.exceptions.RefactoringError

Errors for performing a refactoring

class rope.refactor.similarfinder.SimilarFinder(pymodule, wildcards=None)

SimilarFinder can be used to find similar pieces of code

See the notes in the rope.refactor.restructure module for more info.

source
pymodule
get_matches(code, args=None, start=0, end=None)
get_match_regions(*args, **kwds)
class rope.refactor.similarfinder.RawSimilarFinder(source, node=None, does_match=None)

A class for finding similar expressions and statements

get_matches(code, start=0, end=None, skip=None)

Search for code in source and return a list of Match-es

code can contain wildcards. ${name} matches normal names and ``${?name} can match any expression. You can use Match.get_ast() for getting the node that has matched a given pattern.

class rope.refactor.similarfinder.Match(mapping)
mapping
get_region()

Returns match region

get_ast(name)

Return the ast node that has matched rope variables

class rope.refactor.similarfinder.ExpressionMatch(ast, mapping)

Bases: Match

ast
get_region()

Returns match region

mapping
get_ast(name)

Return the ast node that has matched rope variables

class rope.refactor.similarfinder.StatementMatch(ast_list, mapping)

Bases: Match

ast_list
get_region()

Returns match region

mapping
get_ast(name)

Return the ast node that has matched rope variables

class rope.refactor.similarfinder.CodeTemplate(template)
template
get_names()
substitute(mapping)
rope.refactor.similarfinder.make_pattern(code, variables)