rope.refactor.similarfinder =========================== .. py:module:: rope.refactor.similarfinder .. autoapi-nested-parse:: This module can be used for finding similar code Exceptions ---------- .. autoapisummary:: rope.refactor.similarfinder.BadNameInCheckError Classes ------- .. autoapisummary:: rope.refactor.similarfinder.SimilarFinder rope.refactor.similarfinder.RawSimilarFinder rope.refactor.similarfinder.Match rope.refactor.similarfinder.ExpressionMatch rope.refactor.similarfinder.StatementMatch rope.refactor.similarfinder.CodeTemplate Functions --------- .. autoapisummary:: rope.refactor.similarfinder.make_pattern Module Contents --------------- .. py:exception:: BadNameInCheckError Bases: :py:obj:`rope.base.exceptions.RefactoringError` Errors for performing a refactoring .. py:class:: 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. .. py:attribute:: source .. py:attribute:: pymodule .. py:method:: get_matches(code, args=None, start=0, end=None) .. py:method:: get_match_regions(*args, **kwds) .. py:class:: RawSimilarFinder(source, node=None, does_match=None) A class for finding similar expressions and statements .. py:method:: 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. .. py:class:: Match(mapping) .. py:attribute:: mapping .. py:method:: get_region() Returns match region .. py:method:: get_ast(name) Return the ast node that has matched rope variables .. py:class:: ExpressionMatch(ast, mapping) Bases: :py:obj:`Match` .. py:attribute:: ast .. py:method:: get_region() Returns match region .. py:attribute:: mapping .. py:method:: get_ast(name) Return the ast node that has matched rope variables .. py:class:: StatementMatch(ast_list, mapping) Bases: :py:obj:`Match` .. py:attribute:: ast_list .. py:method:: get_region() Returns match region .. py:attribute:: mapping .. py:method:: get_ast(name) Return the ast node that has matched rope variables .. py:class:: CodeTemplate(template) .. py:attribute:: template .. py:method:: get_names() .. py:method:: substitute(mapping) .. py:function:: make_pattern(code, variables)