Sat, 23 Feb 2013 15:28:39 +0100
Modified the code to do lazy import.
--- a/ChangeLog Sat Feb 09 11:32:10 2013 +0100 +++ b/ChangeLog Sat Feb 23 15:28:39 2013 +0100 @@ -1,5 +1,9 @@ ChangeLog --------- +Version 2.3.0 +- bug fixes +- modified code to do lazy import + Version 2.2.1: - fixed an issue causing failures for files with Windows end-of-line indicators
--- a/PluginRefactoringRope.py Sat Feb 09 11:32:10 2013 +0100 +++ b/PluginRefactoringRope.py Sat Feb 23 15:28:39 2013 +0100 @@ -20,7 +20,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "2.2.1" +version = "2.3.0" className = "RefactoringRopePlugin" packageName = "RefactoringRope" internalPackages = "rope"
--- a/RefactoringRope/ChangeSignatureDialog.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/ChangeSignatureDialog.py Sat Feb 23 15:28:39 2013 +0100 @@ -17,7 +17,6 @@ from Ui_ChangeSignatureDialog import Ui_ChangeSignatureDialog from RefactoringDialogBase import RefactoringDialogBase -from AddParameterDialog import AddParameterDialog class ChangeSignatureDialog(RefactoringDialogBase, Ui_ChangeSignatureDialog): @@ -137,6 +136,7 @@ """ Private slot to add a new parameter. """ + from AddParameterDialog import AddParameterDialog dlg = AddParameterDialog(self) if dlg.exec_() == QDialog.Accepted: name, default, value = dlg.getData()
--- a/RefactoringRope/ConfirmationDialog.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/ConfirmationDialog.py Sat Feb 23 15:28:39 2013 +0100 @@ -11,7 +11,6 @@ from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractButton from Ui_ConfirmationDialog import Ui_ConfirmationDialog -from ChangesPreviewDialog import ChangesPreviewDialog import Utilities @@ -56,6 +55,7 @@ """ Private method to preview the changes. """ + from ChangesPreviewDialog import ChangesPreviewDialog dlg = ChangesPreviewDialog(self.__changes, self) if dlg.exec_() == QDialog.Accepted: self.accept()
--- a/RefactoringRope/HelpDialog.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/HelpDialog.py Sat Feb 23 15:28:39 2013 +0100 @@ -10,7 +10,6 @@ from PyQt4.QtGui import QDialog, QDialogButtonBox, QTextDocument, QTextCursor from Ui_HelpDialog import Ui_HelpDialog -from SearchDialog import SearchDialog import Globals @@ -57,6 +56,7 @@ """ if button == self.searchButton: if self.__searchDlg is None: + from SearchDialog import SearchDialog self.__searchDlg = SearchDialog(self) self.__searchDlg.showFind()
--- a/RefactoringRope/HistoryDialog.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/HistoryDialog.py Sat Feb 23 15:28:39 2013 +0100 @@ -14,7 +14,6 @@ from E5Gui.E5Application import e5App from PreviewDialogBase import PreviewDialogBase -from ProgressHandle import ProgressHandle import Utilities @@ -118,6 +117,7 @@ if not self.__refactoring.confirmAllBuffersSaved(): return + from ProgressHandle import ProgressHandle handle = ProgressHandle(change.description, False, self) handle.show() QApplication.processEvents()
--- a/RefactoringRope/InlineArgumentDefaultDialog.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/InlineArgumentDefaultDialog.py Sat Feb 23 15:28:39 2013 +0100 @@ -10,8 +10,6 @@ from PyQt4.QtCore import pyqtSlot, Qt from PyQt4.QtGui import QDialogButtonBox, QListWidgetItem, QAbstractButton -import rope.refactor.change_signature - from Ui_InlineArgumentDefaultDialog import Ui_InlineArgumentDefaultDialog from RefactoringDialogBase import RefactoringDialogBase @@ -98,6 +96,8 @@ """ items = self.parameterList.selectedItems() if len(items) > 0: + import rope.refactor.change_signature + itm = items[0] name = itm.data(InlineArgumentDefaultDialog.NameRole) index = self.__getParameterIndex(self.__definition_info, name)
--- a/RefactoringRope/Refactoring.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/Refactoring.py Sat Feb 23 15:28:39 2013 +0100 @@ -13,25 +13,8 @@ sys.path.insert(0, os.path.dirname(__file__)) import rope import rope.base.libutils -import rope.base.project import rope.base.exceptions -import rope.refactor.rename -import rope.refactor.extract -import rope.refactor.usefunction -import rope.refactor.inline -import rope.refactor.move -import rope.refactor.change_signature -import rope.refactor.introduce_factory -import rope.refactor.introduce_parameter -import rope.refactor.method_object -import rope.refactor.encapsulate_field -import rope.refactor.localtofield -import rope.refactor.topackage -from rope.refactor.importutils import ImportOrganizer - -import rope.contrib.findit - from PyQt4.QtCore import QObject from PyQt4.QtGui import QMenu, QApplication, QMessageBox, QDialog, QAction from PyQt4.Qsci import QsciScintilla @@ -40,30 +23,6 @@ from E5Gui.E5Action import E5Action -from QScintilla.MiniEditor import MiniEditor - -from FileSystemCommands import e5FileSystemCommands -from ProgressHandle import ProgressHandle -from HelpDialog import HelpDialog -from MatchesDialog import MatchesDialog -from RenameDialog import RenameDialog -from ChangeOccurrencesDialog import ChangeOccurrencesDialog -from HistoryDialog import HistoryDialog -from ExtractDialog import ExtractDialog -from InlineDialog import InlineDialog -from MoveMethodDialog import MoveMethodDialog -from MoveGlobalMethodDialog import MoveGlobalMethodDialog -from MoveModuleDialog import MoveModuleDialog -from UseFunctionDialog import UseFunctionDialog -from IntroduceFactoryDialog import IntroduceFactoryDialog -from IntroduceParameterDialog import IntroduceParameterDialog -from ConfirmationDialog import ConfirmationDialog -from RestructureDialog import RestructureDialog -from ChangeSignatureDialog import ChangeSignatureDialog -from InlineArgumentDefaultDialog import InlineArgumentDefaultDialog -from GetterSetterDialog import GetterSetterDialog -from MethodToMethodObjectDialog import MethodToMethodObjectDialog - import Utilities @@ -92,6 +51,8 @@ # Rope objects self.__project = None + + from FileSystemCommands import e5FileSystemCommands self.__fsCommands = e5FileSystemCommands(self.__e5project) def initActions(self): @@ -1032,6 +993,7 @@ # keep it inside the object offset = self.__getOffset(aw, line, index) + import rope.refactor.rename resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1045,6 +1007,7 @@ localResource = resource else: localResource = None + from RenameDialog import RenameDialog self.dlg = RenameDialog(self, title, renamer, resource=localResource, parent=self.__ui) self.dlg.show() @@ -1073,6 +1036,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.rename resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1082,6 +1046,7 @@ self.handleRopeError(err, title) return + from ChangeOccurrencesDialog import ChangeOccurrencesDialog self.dlg = ChangeOccurrencesDialog(self, title, renamer, parent=self.__ui) self.dlg.show() @@ -1130,6 +1095,7 @@ startOffset = self.__getOffset(aw, startline, startcolumn) endOffset = self.__getOffset(aw, endline, endcolumn) + import rope.refactor.extract resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1145,6 +1111,7 @@ self.handleRopeError(err, title) return + from ExtractDialog import ExtractDialog self.dlg = ExtractDialog(self, title, extractor, parent=self.__ui) self.dlg.show() @@ -1176,6 +1143,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.inline resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1185,6 +1153,7 @@ self.handleRopeError(err, title) return + from InlineDialog import InlineDialog self.dlg = InlineDialog(self, title, inliner, parent=self.__ui) self.dlg.show() @@ -1216,6 +1185,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.move resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1226,9 +1196,11 @@ return if isinstance(mover, rope.refactor.move.MoveGlobal): + from MoveGlobalMethodDialog import MoveGlobalMethodDialog self.dlg = MoveGlobalMethodDialog(self, title, mover, self.__project, parent=self.__ui) else: + from MoveMethodDialog import MoveMethodDialog self.dlg = MoveMethodDialog(self, title, mover, parent=self.__ui) self.dlg.show() @@ -1249,6 +1221,7 @@ filename = aw.getFileName() offset = None + import rope.refactor.move resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1258,6 +1231,7 @@ self.handleRopeError(err, title) return + from MoveModuleDialog import MoveModuleDialog self.dlg = MoveModuleDialog(self, title, mover, parent=self.__ui) self.dlg.show() @@ -1288,6 +1262,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.usefunction resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1297,6 +1272,7 @@ self.handleRopeError(err, title) return + from UseFunctionDialog import UseFunctionDialog self.dlg = UseFunctionDialog(self, title, user, parent=self.__ui) self.dlg.show() @@ -1328,6 +1304,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.introduce_factory resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1338,6 +1315,7 @@ self.handleRopeError(err, title) return + from IntroduceFactoryDialog import IntroduceFactoryDialog self.dlg = IntroduceFactoryDialog(self, title, introducer, parent=self.__ui) self.dlg.show() @@ -1366,6 +1344,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.introduce_parameter resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1375,6 +1354,7 @@ self.handleRopeError(err, title) return + from IntroduceParameterDialog import IntroduceParameterDialog self.dlg = IntroduceParameterDialog(self, title, introducer, parent=self.__ui) self.dlg.show() @@ -1387,6 +1367,7 @@ """ Private slot to organize imports. """ + from rope.refactor.importutils import ImportOrganizer self.__doImports(self.trUtf8("Organize Imports"), ImportOrganizer.organize_imports) @@ -1394,6 +1375,7 @@ """ Private slot to expand star imports. """ + from rope.refactor.importutils import ImportOrganizer self.__doImports(self.trUtf8("Expand Star Imports"), ImportOrganizer.expand_star_imports) @@ -1401,6 +1383,7 @@ """ Private slot to transform relative to absolute imports. """ + from rope.refactor.importutils import ImportOrganizer self.__doImports(self.trUtf8("Relative to Absolute"), ImportOrganizer.relatives_to_absolutes) @@ -1408,6 +1391,7 @@ """ Private slot to transform from imports to plain imports. """ + from rope.refactor.importutils import ImportOrganizer self.__doImports(self.trUtf8("Froms to Imports"), ImportOrganizer.froms_to_imports) @@ -1415,6 +1399,7 @@ """ Private slot to handle long imports. """ + from rope.refactor.importutils import ImportOrganizer self.__doImports(self.trUtf8("Handle Long Imports"), ImportOrganizer.handle_long_imports) @@ -1437,12 +1422,14 @@ else: offset = None + from rope.refactor.importutils import ImportOrganizer importOrganizer = ImportOrganizer(self.__project) resource = rope.base.libutils.path_to_resource( self.__project, filename) try: changes = method(importOrganizer, resource, offset=offset) if changes is not None: + from ConfirmationDialog import ConfirmationDialog dlg = ConfirmationDialog(changes, self.__ui) if dlg.exec_() == QDialog.Accepted: self.__project.do(changes) @@ -1464,6 +1451,7 @@ """ Private slot to restructure code. """ + from RestructureDialog import RestructureDialog title = self.trUtf8("Restructure") self.dlg = RestructureDialog(self, title, parent=self.__ui) self.dlg.show() @@ -1492,6 +1480,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.change_signature resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1501,6 +1490,7 @@ self.handleRopeError(err, title) return + from ChangeSignatureDialog import ChangeSignatureDialog self.dlg = ChangeSignatureDialog(self, title, changer, parent=self.__ui) self.dlg.show() @@ -1530,6 +1520,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.change_signature resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1539,6 +1530,7 @@ self.handleRopeError(err, title) return + from InlineArgumentDefaultDialog import InlineArgumentDefaultDialog self.dlg = InlineArgumentDefaultDialog(self, title, changer, parent=self.__ui) self.dlg.show() @@ -1559,6 +1551,7 @@ filename = aw.getFileName() + import rope.refactor.topackage resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1595,9 +1588,9 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.encapsulate_field resource = rope.base.libutils.path_to_resource( self.__project, filename) - try: encapsulateField = \ rope.refactor.encapsulate_field.EncapsulateField( @@ -1606,8 +1599,11 @@ self.handleRopeError(err, title) return + from GetterSetterDialog import GetterSetterDialog dlg = GetterSetterDialog(encapsulateField.get_field_name()) if dlg.exec_() == QDialog.Accepted: + from ProgressHandle import ProgressHandle + from ConfirmationDialog import ConfirmationDialog getter, setter = dlg.getData() handle = ProgressHandle(title, False, self.__ui) handle.show() @@ -1649,6 +1645,8 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.localtofield + from ConfirmationDialog import ConfirmationDialog resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1687,6 +1685,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.refactor.method_object resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1696,6 +1695,7 @@ self.handleRopeError(err, title) return + from MethodToMethodObjectDialog import MethodToMethodObjectDialog self.dlg = MethodToMethodObjectDialog(self, title, converter, parent=self.__ui) self.dlg.show() @@ -1723,6 +1723,7 @@ if not self.confirmAllBuffersSaved(): return + from ProgressHandle import ProgressHandle changes = history.undo_list[-1] handle = ProgressHandle(self.trUtf8("Undo"), False, self.__ui) handle.show() @@ -1755,6 +1756,7 @@ if not self.confirmAllBuffersSaved(): return + from ProgressHandle import ProgressHandle changes = history.redo_list[-1] handle = ProgressHandle(self.trUtf8("Redo"), False, self.__ui) handle.show() @@ -1772,6 +1774,7 @@ """ Private method to show list of changes available for an undo operation. """ + from HistoryDialog import HistoryDialog undoList = list(reversed(self.__project.history.undo_list)) self.dlg = HistoryDialog(self, undoList, True, self.__ui) self.dlg.show() @@ -1780,6 +1783,7 @@ """ Private method to show list of changes available for a redo operation. """ + from HistoryDialog import HistoryDialog redoList = self.__project.history.redo_list self.dlg = HistoryDialog(self, redoList, False, self.__ui) self.dlg.show() @@ -1794,6 +1798,7 @@ if aw is None: return + from HistoryDialog import HistoryDialog filename = aw.getFileName() resource = rope.base.libutils.path_to_resource( self.__project, filename) @@ -1811,6 +1816,7 @@ if aw is None: return + from HistoryDialog import HistoryDialog filename = aw.getFileName() resource = rope.base.libutils.path_to_resource( self.__project, filename) @@ -1861,6 +1867,8 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.contrib.findit + from ProgressHandle import ProgressHandle resource = rope.base.libutils.path_to_resource( self.__project, filename) handle = ProgressHandle(title, True, self.__ui) @@ -1876,6 +1884,7 @@ handle.reset() if occurrences: + from MatchesDialog import MatchesDialog self.dlg = MatchesDialog(self.__ui, True) self.dlg.show() for occurrence in occurrences: @@ -1910,6 +1919,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.contrib.findit resource = rope.base.libutils.path_to_resource( self.__project, filename) try: @@ -1920,6 +1930,7 @@ return if location is not None: + from MatchesDialog import MatchesDialog self.dlg = MatchesDialog(self.__ui, False) self.dlg.show() self.dlg.addEntry(location.resource, location.lineno) @@ -1951,6 +1962,8 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) + import rope.contrib.findit + from ProgressHandle import ProgressHandle resource = rope.base.libutils.path_to_resource(self.__project, filename) handle = ProgressHandle(title, True, self.__ui) @@ -1965,6 +1978,7 @@ handle.reset() if occurrences: + from MatchesDialog import MatchesDialog self.dlg = MatchesDialog(self.__ui, True) self.dlg.show() for occurrence in occurrences: @@ -1987,6 +2001,7 @@ if ropedir is not None: configfile = os.path.join(ropedir.real_path, "config.py") if os.path.exists(configfile): + from QScintilla.MiniEditor import MiniEditor self.__editor = MiniEditor(configfile) self.__editor.show() self.__editor.editorSaved.connect(self.__configChanged) @@ -2034,6 +2049,7 @@ Private slot to show help about the refactorings offered by Rope. """ if self.__helpDialog is None: + from HelpDialog import HelpDialog helpfile = os.path.join(os.path.dirname(__file__), "rope", "docs", "overview.txt") self.__helpDialog = \ @@ -2055,6 +2071,7 @@ QMessageBox.Yes), QMessageBox.No) if res == QMessageBox.Yes: + from ProgressHandle import ProgressHandle handle = ProgressHandle(title, True, self.__ui) handle.show() QApplication.processEvents() @@ -2092,6 +2109,7 @@ """ Private slot called, when the rope config file has changed. """ + import rope.base.project self.__project.close() self.__project = rope.base.project.Project(self.__projectpath, fscommands=self.__fsCommands) @@ -2132,6 +2150,7 @@ self.__projectLanguage = self.__e5project.getProjectLanguage() if self.__projectLanguage in ["Python3"]: + import rope.base.project self.__project = rope.base.project.Project(self.__projectpath, fscommands=self.__fsCommands) for act in self.actions:
--- a/RefactoringRope/RefactoringDialogBase.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/RefactoringDialogBase.py Sat Feb 23 15:28:39 2013 +0100 @@ -12,9 +12,6 @@ from E5Gui.E5Application import e5App -from ChangesPreviewDialog import ChangesPreviewDialog -from ProgressHandle import ProgressHandle - class RefactoringDialogBase(QDialog): """ @@ -44,6 +41,7 @@ @param interruptable flag indicating, that the task may be interrupted (boolean) """ + from ProgressHandle import ProgressHandle self.__handle = ProgressHandle(self._title, interruptable, self) self.__handle.show() QApplication.processEvents() @@ -78,6 +76,7 @@ changes = self.__getChanges() if changes is not None: + from ChangesPreviewDialog import ChangesPreviewDialog dlg = ChangesPreviewDialog(changes, self) if dlg.exec_() == QDialog.Accepted: self.applyChanges(changes)
--- a/RefactoringRope/RenameDialog.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/RenameDialog.py Sat Feb 23 15:28:39 2013 +0100 @@ -13,7 +13,6 @@ from E5Gui.E5Application import e5App from Ui_RenameDialog import Ui_RenameDialog - from RefactoringDialogBase import RefactoringDialogBase
--- a/RefactoringRope/RestructureDialog.py Sat Feb 09 11:32:10 2013 +0100 +++ b/RefactoringRope/RestructureDialog.py Sat Feb 23 15:28:39 2013 +0100 @@ -10,8 +10,6 @@ from PyQt4.QtCore import pyqtSlot from PyQt4.QtGui import QDialogButtonBox, QAbstractButton -import rope.refactor.restructure - from Ui_RestructureDialog import Ui_RestructureDialog from RefactoringDialogBase import RefactoringDialogBase @@ -98,6 +96,7 @@ value = splitted[1].strip() args[name] = value + import rope.refactor.restructure self._refactoring.getProject().validate( self._refactoring.getProject().root) try: