from rope.base import exceptions, codeanalyze, pyobjects, pynames, taskhandle
from rope.base.change import ChangeSet, ChangeContents, MoveResource
from rope.refactor import occurrences, sourceutils
def get_changes(self, new_name, in_file=False, in_hierarchy=False,
False, docs=False, confirm=None,
+ unsure=e, docs=False,
"""Get the changes needed for this refactoring
- `docs`: when `True` rename refactoring will rename
occurrences in comments and strings where the name is
visible. Setting it will make renames faster, too.
- - `unsure`: rename occurrence even if unsure. Do not use it
- unless you know what you're doing. If `True`, all name
- occurrences except those that we are sure are not what we
- - `confirm`: when renaming unsure occurrences this function
- is called with an instance of `occorrences.Occurrence`.
- If it returns `True` the occurrence will be renamed
+ - `unsure`: decides what to do about unsure occurrences.
+ If `None`, they are ignored. Otherwise `unsure` is
+ called with an instance of `occurrence.Occurrence` as
+ parameter. If it returns `True`, the occurrence is
+ considered to be a match.
+ if unsure in (True, False):
+ 'unsure parameter should be a function that returns'
+ ' True or False', DeprecationWarning, stacklevel=2)
+ def unsure_func(value=unsure):
old_pynames = self._get_old_pynames(in_file, in_hierarchy, task_handle)
if not in_file and len(old_pynames) == 1 and \
changes = ChangeSet('Renaming <%s> to <%s>' %
finder = occurrences.FilteredFinder(
- self.pycore, self.old_name, old_pynames,
- unsure=unsure, docs=docs, confirm=confirm)
+ self.pycore, self.old_name, old_pynames, unsure=unsure, docs=docs)
job_set = task_handle.create_jobset('Collecting Changes', len(files))
job_set.started_job('Working on <%s>' % file_.path)