Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _change_calls(self, call_changer, in_hierarchy=None, resources=None,
handle=taskhandle.NullTaskHandle()):
if resources is None:
resources = self.project.get_python_files()
changes = ChangeSet('Changing signature of <%s>' % self.name)
job_set = handle.create_jobset('Collecting Changes', len(resources))
finder = occurrences.create_finder(
self.project, self.name, self.pyname, instance=self.primary,
in_hierarchy=in_hierarchy and self.is_method())
if self.others:
name, pyname = self.others
constructor_finder = occurrences.create_finder(
self.project, name, pyname, only_calls=True)
finder = _MultipleFinders([finder, constructor_finder])
for file in resources:
job_set.started_job(file.path)
change_calls = _ChangeCallsInModule(
self.project, finder, file, call_changer)
def do(self, changes, task_handle=taskhandle.NullTaskHandle()):
"""Perform the change and add it to the `self.undo_list`
Note that uninteresting changes (changes to ignored files)
will not be appended to `self.undo_list`.
"""
try:
self.current_change = changes
changes.do(change.create_job_set(task_handle, changes))
finally:
self.current_change = None
if self._is_change_interesting(changes):
self.undo_list.append(changes)
self._remove_extra_items()
del self.redo_list[:]
def get_classes(self, task_handle=taskhandle.NullTaskHandle()):
warnings.warn('`PyCore.get_classes()` is deprecated',
DeprecationWarning, stacklevel=2)
return []
def _change_calls(self, call_changer, in_hierarchy=None, resources=None,
handle=taskhandle.NullTaskHandle()):
if resources is None:
resources = self.project.get_python_files()
changes = ChangeSet('Changing signature of <%s>' % self.name)
job_set = handle.create_jobset('Collecting Changes', len(resources))
finder = occurrences.create_finder(
self.project, self.name, self.pyname, instance=self.primary,
in_hierarchy=in_hierarchy and self.is_method())
if self.others:
name, pyname = self.others
constructor_finder = occurrences.create_finder(
self.project, name, pyname, only_calls=True)
finder = _MultipleFinders([finder, constructor_finder])
for file in resources:
job_set.started_job(file.path)
change_calls = _ChangeCallsInModule(
self.project, finder, file, call_changer)
def find_occurrences(project, resource, offset, unsure=False, resources=None,
in_hierarchy=False,
task_handle=taskhandle.NullTaskHandle()):
"""Return a list of `Location`\s
If `unsure` is `True`, possible matches are returned, too. You
can use `Location.unsure` to see which are unsure occurrences.
`resources` can be a list of `rope.base.resource.File`\s that
should be searched for occurrences; if `None` all python files
in the project are searched.
"""
name = worder.get_name_at(resource, offset)
this_pymodule = project.get_pymodule(resource)
primary, pyname = rope.base.evaluate.eval_location2(
this_pymodule, offset)
def is_match(occurrence):
return unsure
def _change_calls(self, call_changer, in_hierarchy=None, resources=None,
handle=taskhandle.NullTaskHandle()):
if resources is None:
resources = self.pycore.get_python_files()
changes = ChangeSet('Changing signature of <%s>' % self.name)
job_set = handle.create_jobset('Collecting Changes', len(resources))
finder = occurrences.create_finder(
self.pycore, self.name, self.pyname, instance=self.primary,
in_hierarchy=in_hierarchy and self.is_method())
if self.others:
name, pyname = self.others
constructor_finder = occurrences.create_finder(
self.pycore, name, pyname, only_calls=True)
finder = _MultipleFinders([finder, constructor_finder])
for file in resources:
job_set.started_job(file.path)
change_calls = _ChangeCallsInModule(
self.pycore, finder, file, call_changer)
def get_changes(self, remove=True, only_current=False, resources=None,
docs=False, task_handle=taskhandle.NullTaskHandle()):
if resources is None:
if rename._is_local(self.pyname):
resources = [self.resource]
else:
resources = self.project.get_python_files()
if only_current:
resources = [self.original]
if remove and self.original != self.resource:
resources.append(self.resource)
changes = ChangeSet('Inline variable <%s>' % self.name)
jobset = task_handle.create_jobset('Calculating changes',
len(resources))
for resource in resources:
jobset.started_job(resource.path)
if resource == self.resource:
def get_changes(self, getter=None, setter=None, resources=None,
task_handle=taskhandle.NullTaskHandle()):
"""Get the changes this refactoring makes
If `getter` is not `None`, that will be the name of the
getter, otherwise ``get_${field_name}`` will be used. The
same is true for `setter` and if it is None set_${field_name} is
used.
`resources` can be a list of `rope.base.resource.File`\s that
the refactoring should be applied on; if `None` all python
files in the project are searched.
"""
if resources is None:
resources = self.project.get_python_files()
changes = ChangeSet('Encapsulate field <%s>' % self.name)
job_set = task_handle.create_jobset('Collecting Changes',
def get_changes(self, remove=True, only_current=False, resources=None,
docs=False, task_handle=taskhandle.NullTaskHandle()):
if resources is None:
if rename._is_local(self.pyname):
resources = [self.resource]
else:
resources = self.project.get_python_files()
if only_current:
resources = [self.original]
if remove and self.original != self.resource:
resources.append(self.resource)
changes = ChangeSet('Inline variable <%s>' % self.name)
jobset = task_handle.create_jobset('Calculating changes',
len(resources))
for resource in resources:
jobset.started_job(resource.path)
if resource == self.resource:
def get_classes(self, task_handle=taskhandle.NullTaskHandle()):
warnings.warn('`PyCore.get_classes()` is deprecated',
DeprecationWarning, stacklevel=2)
return []