示例#1
0
 def test_renaming_resources_using_rename_module_refactoring(self):
     mod1 = testutils.create_module(self.project, 'mod1')
     mod2 = testutils.create_module(self.project, 'mod2')
     mod1.write('a_var = 1')
     mod2.write('import mod1\nmy_var = mod1.a_var\n')
     renamer = rename.Rename(self.project, mod1)
     renamer.get_changes('newmod').do()
     self.assertEqual('import newmod\nmy_var = newmod.a_var\n',
                       mod2.read())
示例#2
0
    def get_refactor(self, ctx):
        """ Function description.

        :return Rename:

        """
        offset = None
        if not self.module:
            _, offset = env.get_offset_params()
        env.debug('Prepare rename', offset)
        return rename.Rename(ctx.project, ctx.resource, offset)
示例#3
0
def _PostTransferBaseStatistics (destinationBaseLibPath: str) -> None:
	moduleName = "statistics"  # type: str
	moduleNewName = "statistics_lib"  # type: str

	baseProject = project.Project(destinationBaseLibPath)  # type: project.Project
	baseChanges = rename.Rename(baseProject, baseProject.find_module(moduleName)).get_changes(moduleNewName, docs = True)
	baseProject.do(baseChanges)
	baseProject.close()

	# noinspection SpellCheckingInspection
	ropeProjectPath = destinationBaseLibPath + os.path.sep + ".ropeproject"  # type: str

	try:
		if os.path.exists(ropeProjectPath):
			shutil.rmtree(ropeProjectPath)
	except Exception as e:
		print("Failed to remove the rope project directory at '" + ropeProjectPath + "'.\n" + str(e))