--- a/RefactoringRope/Refactoring.py Sun Oct 13 18:35:25 2013 +0200 +++ b/RefactoringRope/Refactoring.py Fri Oct 25 19:33:36 2013 +0200 @@ -52,8 +52,8 @@ # Rope objects self.__project = None - from FileSystemCommands import e5FileSystemCommands - self.__fsCommands = e5FileSystemCommands(self.__e5project) + from FileSystemCommands import E5FileSystemCommands + self.__fsCommands = E5FileSystemCommands(self.__e5project) def initActions(self): """ @@ -65,10 +65,11 @@ ## Rename refactoring actions ##################################################### - self.refactoringRenameAct = E5Action(self.trUtf8('Rename'), - self.trUtf8('&Rename'), - 0, 0, - self, 'refactoring_rename') + self.refactoringRenameAct = E5Action( + self.trUtf8('Rename'), + self.trUtf8('&Rename'), + 0, 0, + self, 'refactoring_rename') self.refactoringRenameAct.setStatusTip(self.trUtf8( 'Rename the highlighted object')) self.refactoringRenameAct.setWhatsThis(self.trUtf8( @@ -79,10 +80,11 @@ self.__rename) self.actions.append(self.refactoringRenameAct) - self.refactoringRenameLocalAct = E5Action(self.trUtf8('Local Rename'), - self.trUtf8('&Local Rename'), - 0, 0, - self, 'refactoring_rename_local') + self.refactoringRenameLocalAct = E5Action( + self.trUtf8('Local Rename'), + self.trUtf8('&Local Rename'), + 0, 0, + self, 'refactoring_rename_local') self.refactoringRenameLocalAct.setStatusTip(self.trUtf8( 'Rename the highlighted object in the current module only')) self.refactoringRenameLocalAct.setWhatsThis(self.trUtf8( @@ -95,10 +97,10 @@ self.actions.append(self.refactoringRenameLocalAct) self.refactoringRenameModuleAct = E5Action( - self.trUtf8('Rename Current Module'), - self.trUtf8('Rename Current Module'), - 0, 0, - self, 'refactoring_rename_module') + self.trUtf8('Rename Current Module'), + self.trUtf8('Rename Current Module'), + 0, 0, + self, 'refactoring_rename_module') self.refactoringRenameModuleAct.setStatusTip(self.trUtf8( 'Rename the current module')) self.refactoringRenameModuleAct.setWhatsThis(self.trUtf8( @@ -110,10 +112,10 @@ self.actions.append(self.refactoringRenameModuleAct) self.refactoringChangeOccurrencesAct = E5Action( - self.trUtf8('Change Occurrences'), - self.trUtf8('Change &Occurrences'), - 0, 0, - self, 'refactoring_change_occurrences') + self.trUtf8('Change Occurrences'), + self.trUtf8('Change &Occurrences'), + 0, 0, + self, 'refactoring_change_occurrences') self.refactoringChangeOccurrencesAct.setStatusTip(self.trUtf8( 'Change all occurrences in the local scope')) self.refactoringChangeOccurrencesAct.setWhatsThis(self.trUtf8( @@ -129,10 +131,10 @@ ##################################################### self.refactoringExtractMethodAct = E5Action( - self.trUtf8('Extract method'), - self.trUtf8('Extract &Method'), - 0, 0, - self, 'refactoring_extract_method') + self.trUtf8('Extract method'), + self.trUtf8('Extract &Method'), + 0, 0, + self, 'refactoring_extract_method') self.refactoringExtractMethodAct.setStatusTip(self.trUtf8( 'Extract the highlighted area as a method')) self.refactoringExtractMethodAct.setWhatsThis(self.trUtf8( @@ -144,10 +146,10 @@ self.actions.append(self.refactoringExtractMethodAct) self.refactoringExtractLocalVariableAct = E5Action( - self.trUtf8('Extract local variable'), - self.trUtf8('&Extract Local Variable'), - 0, 0, - self, 'refactoring_extract_variable') + self.trUtf8('Extract local variable'), + self.trUtf8('&Extract Local Variable'), + 0, 0, + self, 'refactoring_extract_variable') self.refactoringExtractLocalVariableAct.setStatusTip(self.trUtf8( 'Extract the highlighted area as a local variable')) self.refactoringExtractLocalVariableAct.setWhatsThis(self.trUtf8( @@ -163,10 +165,10 @@ ##################################################### self.refactoringInlineAct = E5Action( - self.trUtf8('Inline'), - self.trUtf8('&Inline'), - 0, 0, - self, 'refactoring_inline') + self.trUtf8('Inline'), + self.trUtf8('&Inline'), + 0, 0, + self, 'refactoring_inline') self.refactoringInlineAct.setStatusTip(self.trUtf8( 'Inlines the selected local variable or method')) self.refactoringInlineAct.setWhatsThis(self.trUtf8( @@ -182,10 +184,10 @@ ##################################################### self.refactoringMoveMethodAct = E5Action( - self.trUtf8('Move method'), - self.trUtf8('Mo&ve Method'), - 0, 0, - self, 'refactoring_move_method') + self.trUtf8('Move method'), + self.trUtf8('Mo&ve Method'), + 0, 0, + self, 'refactoring_move_method') self.refactoringMoveMethodAct.setStatusTip(self.trUtf8( 'Move the highlighted method to another class')) self.refactoringMoveMethodAct.setWhatsThis(self.trUtf8( @@ -197,10 +199,10 @@ self.actions.append(self.refactoringMoveMethodAct) self.refactoringMoveModuleAct = E5Action( - self.trUtf8('Move current module'), - self.trUtf8('Move Current Module'), - 0, 0, - self, 'refactoring_move_module') + self.trUtf8('Move current module'), + self.trUtf8('Move Current Module'), + 0, 0, + self, 'refactoring_move_module') self.refactoringMoveModuleAct.setStatusTip(self.trUtf8( 'Move the current module to another package')) self.refactoringMoveModuleAct.setWhatsThis(self.trUtf8( @@ -216,10 +218,10 @@ ##################################################### self.refactoringUseFunctionAct = E5Action( - self.trUtf8('Use Function'), - self.trUtf8('Use Function'), - 0, 0, - self, 'refactoring_use_function') + self.trUtf8('Use Function'), + self.trUtf8('Use Function'), + 0, 0, + self, 'refactoring_use_function') self.refactoringUseFunctionAct.setStatusTip(self.trUtf8( 'Use a function wherever possible.')) self.refactoringUseFunctionAct.setWhatsThis(self.trUtf8( @@ -235,10 +237,10 @@ ##################################################### self.refactoringIntroduceFactoryAct = E5Action( - self.trUtf8('Introduce Factory Method'), - self.trUtf8('Introduce &Factory Method'), - 0, 0, - self, 'refactoring_introduce_factory_method') + self.trUtf8('Introduce Factory Method'), + self.trUtf8('Introduce &Factory Method'), + 0, 0, + self, 'refactoring_introduce_factory_method') self.refactoringIntroduceFactoryAct.setStatusTip(self.trUtf8( 'Introduce a factory method or function')) self.refactoringIntroduceFactoryAct.setWhatsThis(self.trUtf8( @@ -250,10 +252,10 @@ self.actions.append(self.refactoringIntroduceFactoryAct) self.refactoringIntroduceParameterAct = E5Action( - self.trUtf8('Introduce Parameter'), - self.trUtf8('Introduce &Parameter'), - 0, 0, - self, 'refactoring_introduce_parameter_method') + self.trUtf8('Introduce Parameter'), + self.trUtf8('Introduce &Parameter'), + 0, 0, + self, 'refactoring_introduce_parameter_method') self.refactoringIntroduceParameterAct.setStatusTip(self.trUtf8( 'Introduce a parameter in a function')) self.refactoringIntroduceParameterAct.setWhatsThis(self.trUtf8( @@ -269,10 +271,10 @@ ##################################################### self.refactoringImportsOrganizeAct = E5Action( - self.trUtf8('Organize Imports'), - self.trUtf8('&Organize Imports'), - 0, 0, - self, 'refactoring_organize_imports') + self.trUtf8('Organize Imports'), + self.trUtf8('&Organize Imports'), + 0, 0, + self, 'refactoring_organize_imports') self.refactoringImportsOrganizeAct.setStatusTip(self.trUtf8( 'Sort imports according to PEP-8')) self.refactoringImportsOrganizeAct.setWhatsThis(self.trUtf8( @@ -284,10 +286,10 @@ self.actions.append(self.refactoringImportsOrganizeAct) self.refactoringImportsStarExpandAct = E5Action( - self.trUtf8('Expand Star Imports'), - self.trUtf8('E&xpand Star Imports'), - 0, 0, - self, 'refactoring_expand_star_imports') + self.trUtf8('Expand Star Imports'), + self.trUtf8('E&xpand Star Imports'), + 0, 0, + self, 'refactoring_expand_star_imports') self.refactoringImportsStarExpandAct.setStatusTip(self.trUtf8( 'Expand imports like "from xxx import *"')) self.refactoringImportsStarExpandAct.setWhatsThis(self.trUtf8( @@ -301,10 +303,10 @@ self.actions.append(self.refactoringImportsStarExpandAct) self.refactoringImportsRelativeToAbsoluteAct = E5Action( - self.trUtf8('Relative to Absolute'), - self.trUtf8('Relative to &Absolute'), - 0, 0, - self, 'refactoring_relative_to_absolute_imports') + self.trUtf8('Relative to Absolute'), + self.trUtf8('Relative to &Absolute'), + 0, 0, + self, 'refactoring_relative_to_absolute_imports') self.refactoringImportsRelativeToAbsoluteAct.setStatusTip(self.trUtf8( 'Transform relative imports to absolute ones')) self.refactoringImportsRelativeToAbsoluteAct.setWhatsThis(self.trUtf8( @@ -318,10 +320,10 @@ self.actions.append(self.refactoringImportsRelativeToAbsoluteAct) self.refactoringImportsFromsToImportsAct = E5Action( - self.trUtf8('Froms to Imports'), - self.trUtf8('Froms to &Imports'), - 0, 0, - self, 'refactoring_froms_to_imports') + self.trUtf8('Froms to Imports'), + self.trUtf8('Froms to &Imports'), + 0, 0, + self, 'refactoring_froms_to_imports') self.refactoringImportsFromsToImportsAct.setStatusTip(self.trUtf8( 'Transform From imports to plain imports')) self.refactoringImportsFromsToImportsAct.setWhatsThis(self.trUtf8( @@ -335,10 +337,10 @@ self.actions.append(self.refactoringImportsFromsToImportsAct) self.refactoringImportsHandleLongAct = E5Action( - self.trUtf8('Handle Long Imports'), - self.trUtf8('Handle &Long Imports'), - 0, 0, - self, 'refactoring_organize_imports') + self.trUtf8('Handle Long Imports'), + self.trUtf8('Handle &Long Imports'), + 0, 0, + self, 'refactoring_organize_imports') self.refactoringImportsHandleLongAct.setStatusTip(self.trUtf8( 'Transform long import statements to look better')) self.refactoringImportsHandleLongAct.setWhatsThis(self.trUtf8( @@ -356,10 +358,10 @@ ##################################################### self.refactoringRestructureAct = E5Action( - self.trUtf8('Restructure'), - self.trUtf8('Res&tructure'), - 0, 0, - self, 'refactoring_restructure') + self.trUtf8('Restructure'), + self.trUtf8('Res&tructure'), + 0, 0, + self, 'refactoring_restructure') self.refactoringRestructureAct.setStatusTip(self.trUtf8( 'Restructure code')) self.refactoringRestructureAct.setWhatsThis(self.trUtf8( @@ -371,10 +373,10 @@ self.actions.append(self.refactoringRestructureAct) self.refactoringChangeSignatureAct = E5Action( - self.trUtf8('Change Method Signature'), - self.trUtf8('&Change Method Signature'), - 0, 0, - self, 'refactoring_change_method_signature') + self.trUtf8('Change Method Signature'), + self.trUtf8('&Change Method Signature'), + 0, 0, + self, 'refactoring_change_method_signature') self.refactoringChangeSignatureAct.setStatusTip(self.trUtf8( 'Change the signature of the selected method or function')) self.refactoringChangeSignatureAct.setWhatsThis(self.trUtf8( @@ -387,10 +389,10 @@ self.actions.append(self.refactoringChangeSignatureAct) self.refactoringInlineArgumentDefaultAct = E5Action( - self.trUtf8('Inline Argument Default'), - self.trUtf8('Inline &Argument Default'), - 0, 0, - self, 'refactoring_inline_argument_default') + self.trUtf8('Inline Argument Default'), + self.trUtf8('Inline &Argument Default'), + 0, 0, + self, 'refactoring_inline_argument_default') self.refactoringInlineArgumentDefaultAct.setStatusTip(self.trUtf8( 'Inline a parameters default value')) self.refactoringInlineArgumentDefaultAct.setWhatsThis(self.trUtf8( @@ -402,10 +404,10 @@ self.actions.append(self.refactoringInlineArgumentDefaultAct) self.refactoringTransformModuleAct = E5Action( - self.trUtf8('Transform Module to Package'), - self.trUtf8('Transform Module to Package'), - 0, 0, - self, 'refactoring_transform_module_to_package') + self.trUtf8('Transform Module to Package'), + self.trUtf8('Transform Module to Package'), + 0, 0, + self, 'refactoring_transform_module_to_package') self.refactoringTransformModuleAct.setStatusTip(self.trUtf8( 'Transform the current module to a package')) self.refactoringTransformModuleAct.setWhatsThis(self.trUtf8( @@ -417,10 +419,10 @@ self.actions.append(self.refactoringTransformModuleAct) self.refactoringEncapsulateAttributeAct = E5Action( - self.trUtf8('Encapsulate Attribute'), - self.trUtf8('Encap&sulate Attribute'), - 0, 0, - self, 'refactoring_encapsulate_attribute') + self.trUtf8('Encapsulate Attribute'), + self.trUtf8('Encap&sulate Attribute'), + 0, 0, + self, 'refactoring_encapsulate_attribute') self.refactoringEncapsulateAttributeAct.setStatusTip(self.trUtf8( 'Generate a getter/setter for an attribute')) self.refactoringEncapsulateAttributeAct.setWhatsThis(self.trUtf8( @@ -433,10 +435,10 @@ self.actions.append(self.refactoringEncapsulateAttributeAct) self.refactoringLocalVariableToAttributeAct = E5Action( - self.trUtf8('Local Variable to Attribute'), - self.trUtf8('Local Varia&ble to Attribute'), - 0, 0, - self, 'refactoring_local_variable_to_attribute') + self.trUtf8('Local Variable to Attribute'), + self.trUtf8('Local Varia&ble to Attribute'), + 0, 0, + self, 'refactoring_local_variable_to_attribute') self.refactoringLocalVariableToAttributeAct.setStatusTip(self.trUtf8( 'Change a local variable to an attribute')) self.refactoringLocalVariableToAttributeAct.setWhatsThis(self.trUtf8( @@ -448,10 +450,10 @@ self.actions.append(self.refactoringLocalVariableToAttributeAct) self.refactoringMethodToMethodObjectAct = E5Action( - self.trUtf8('Method To Method Object'), - self.trUtf8('Method To Method Ob&ject'), - 0, 0, - self, 'refactoring_method_to_methodobject') + self.trUtf8('Method To Method Object'), + self.trUtf8('Method To Method Ob&ject'), + 0, 0, + self, 'refactoring_method_to_methodobject') self.refactoringMethodToMethodObjectAct.setStatusTip(self.trUtf8( 'Transform a function or a method to a method object')) self.refactoringMethodToMethodObjectAct.setWhatsThis(self.trUtf8( @@ -466,10 +468,11 @@ ## Undo/Redo actions ##################################################### - self.refactoringUndoAct = E5Action(self.trUtf8('Undo'), - self.trUtf8('&Undo'), - 0, 0, - self, 'refactoring_undo') + self.refactoringUndoAct = E5Action( + self.trUtf8('Undo'), + self.trUtf8('&Undo'), + 0, 0, + self, 'refactoring_undo') self.refactoringUndoAct.setStatusTip(self.trUtf8( 'Undo the last refactoring')) self.refactoringUndoAct.setWhatsThis(self.trUtf8( @@ -480,10 +483,11 @@ self.__undo) self.actions.append(self.refactoringUndoAct) - self.refactoringRedoAct = E5Action(self.trUtf8('Redo'), - self.trUtf8('Re&do'), - 0, 0, - self, 'refactoring_redo') + self.refactoringRedoAct = E5Action( + self.trUtf8('Redo'), + self.trUtf8('Re&do'), + 0, 0, + self, 'refactoring_redo') self.refactoringRedoAct.setStatusTip(self.trUtf8( 'Redo the last refactoring')) self.refactoringRedoAct.setWhatsThis(self.trUtf8( @@ -494,11 +498,11 @@ self.__redo) self.actions.append(self.refactoringRedoAct) - self.refactoringUndoHistoryAct = \ - E5Action(self.trUtf8('Show Project Undo History'), - self.trUtf8('Show Project Undo History'), - 0, 0, - self, 'refactoring_show_project_undo_history') + self.refactoringUndoHistoryAct = E5Action( + self.trUtf8('Show Project Undo History'), + self.trUtf8('Show Project Undo History'), + 0, 0, + self, 'refactoring_show_project_undo_history') self.refactoringUndoHistoryAct.setStatusTip(self.trUtf8( 'Show the undo history of the project')) self.refactoringUndoHistoryAct.setWhatsThis(self.trUtf8( @@ -510,11 +514,11 @@ self.__showProjectUndoHistory) self.actions.append(self.refactoringUndoHistoryAct) - self.refactoringRedoHistoryAct = \ - E5Action(self.trUtf8('Show Project Redo History'), - self.trUtf8('Show Project Redo History'), - 0, 0, - self, 'refactoring_show_project_redo_history') + self.refactoringRedoHistoryAct = E5Action( + self.trUtf8('Show Project Redo History'), + self.trUtf8('Show Project Redo History'), + 0, 0, + self, 'refactoring_show_project_redo_history') self.refactoringRedoHistoryAct.setStatusTip(self.trUtf8( 'Show the redo history of the project')) self.refactoringRedoHistoryAct.setWhatsThis(self.trUtf8( @@ -526,11 +530,11 @@ self.__showProjectRedoHistory) self.actions.append(self.refactoringRedoHistoryAct) - self.refactoringUndoFileHistoryAct = \ - E5Action(self.trUtf8('Show Current File Undo History'), - self.trUtf8('Show Current File Undo History'), - 0, 0, - self, 'refactoring_show_file_undo_history') + self.refactoringUndoFileHistoryAct = E5Action( + self.trUtf8('Show Current File Undo History'), + self.trUtf8('Show Current File Undo History'), + 0, 0, + self, 'refactoring_show_file_undo_history') self.refactoringUndoFileHistoryAct.setStatusTip(self.trUtf8( 'Show the undo history of the current file')) self.refactoringUndoFileHistoryAct.setWhatsThis(self.trUtf8( @@ -542,11 +546,11 @@ self.__showFileUndoHistory) self.actions.append(self.refactoringUndoFileHistoryAct) - self.refactoringRedoFileHistoryAct = \ - E5Action(self.trUtf8('Show Current File Redo History'), - self.trUtf8('Show Current File Redo History'), - 0, 0, - self, 'refactoring_show_file_redo_history') + self.refactoringRedoFileHistoryAct = E5Action( + self.trUtf8('Show Current File Redo History'), + self.trUtf8('Show Current File Redo History'), + 0, 0, + self, 'refactoring_show_file_redo_history') self.refactoringRedoFileHistoryAct.setStatusTip(self.trUtf8( 'Show the redo history of the current file')) self.refactoringRedoFileHistoryAct.setWhatsThis(self.trUtf8( @@ -558,11 +562,11 @@ self.__showFileRedoHistory) self.actions.append(self.refactoringRedoFileHistoryAct) - self.refactoringClearHistoryAct = \ - E5Action(self.trUtf8('Clear History'), - self.trUtf8('Clear History'), - 0, 0, - self, 'refactoring_clear_history') + self.refactoringClearHistoryAct = E5Action( + self.trUtf8('Clear History'), + self.trUtf8('Clear History'), + 0, 0, + self, 'refactoring_clear_history') self.refactoringClearHistoryAct.setStatusTip(self.trUtf8( 'Clear the refactoring history')) self.refactoringClearHistoryAct.setWhatsThis(self.trUtf8( @@ -577,10 +581,11 @@ ## Query actions ##################################################### - self.queryReferencesAct = E5Action(self.trUtf8('Find occurrences'), - self.trUtf8('Find &Occurrences'), - 0, 0, - self, 'refactoring_find_occurrences') + self.queryReferencesAct = E5Action( + self.trUtf8('Find occurrences'), + self.trUtf8('Find &Occurrences'), + 0, 0, + self, 'refactoring_find_occurrences') self.queryReferencesAct.setStatusTip(self.trUtf8( 'Find occurrences of the highlighted object')) self.queryReferencesAct.setWhatsThis(self.trUtf8( @@ -592,10 +597,11 @@ self.__queryReferences) self.actions.append(self.queryReferencesAct) - self.queryDefinitionAct = E5Action(self.trUtf8('Find definition'), - self.trUtf8('Find &Definition'), - 0, 0, - self, 'refactoring_find_definition') + self.queryDefinitionAct = E5Action( + self.trUtf8('Find definition'), + self.trUtf8('Find &Definition'), + 0, 0, + self, 'refactoring_find_definition') self.queryDefinitionAct.setStatusTip(self.trUtf8( 'Find definition of the highlighted item')) self.queryDefinitionAct.setWhatsThis(self.trUtf8( @@ -608,10 +614,10 @@ self.actions.append(self.queryDefinitionAct) self.queryImplementationsAct = E5Action( - self.trUtf8('Find implementations'), - self.trUtf8('Find &Implementations'), - 0, 0, - self, 'refactoring_find_implementations') + self.trUtf8('Find implementations'), + self.trUtf8('Find &Implementations'), + 0, 0, + self, 'refactoring_find_implementations') self.queryImplementationsAct.setStatusTip(self.trUtf8( 'Find places where the selected method is overridden')) self.queryImplementationsAct.setWhatsThis(self.trUtf8( @@ -626,10 +632,11 @@ ## Various actions ##################################################### - self.refactoringEditConfigAct = E5Action(self.trUtf8('Configure Rope'), - self.trUtf8('&Configure Rope'), - 0, 0, - self, 'refactoring_edit_config') + self.refactoringEditConfigAct = E5Action( + self.trUtf8('Configure Rope'), + self.trUtf8('&Configure Rope'), + 0, 0, + self, 'refactoring_edit_config') self.refactoringEditConfigAct.setStatusTip(self.trUtf8( 'Open the rope configuration file')) self.refactoringEditConfigAct.setWhatsThis(self.trUtf8( @@ -641,10 +648,11 @@ self.refactoringEditConfigAct.setMenuRole(QAction.NoRole) self.actions.append(self.refactoringEditConfigAct) - self.refactoringHelpAct = E5Action(self.trUtf8('Rope help'), - self.trUtf8('Rope &Help'), - 0, 0, - self, 'refactoring_help') + self.refactoringHelpAct = E5Action( + self.trUtf8('Rope help'), + self.trUtf8('Rope &Help'), + 0, 0, + self, 'refactoring_help') self.refactoringHelpAct.setStatusTip(self.trUtf8( 'Show help about the rope refactorings')) self.refactoringHelpAct.setWhatsThis(self.trUtf8( @@ -656,10 +664,10 @@ self.actions.append(self.refactoringHelpAct) self.refactoringAllSoaAct = E5Action( - self.trUtf8('Analyse all modules'), - self.trUtf8('&Analyse all modules'), - 0, 0, - self, 'refactoring_analyze_all') + self.trUtf8('Analyse all modules'), + self.trUtf8('&Analyse all modules'), + 0, 0, + self, 'refactoring_analyze_all') self.refactoringAllSoaAct.setStatusTip(self.trUtf8( 'Perform static object analysis on all modules')) self.refactoringAllSoaAct.setWhatsThis(self.trUtf8( @@ -674,10 +682,10 @@ self.actions.append(self.refactoringAllSoaAct) self.updateConfigAct = E5Action( - self.trUtf8('Update Configuration'), - self.trUtf8('&Update Configuration'), - 0, 0, - self, 'refactoring_update_configuration') + self.trUtf8('Update Configuration'), + self.trUtf8('&Update Configuration'), + 0, 0, + self, 'refactoring_update_configuration') self.updateConfigAct.setStatusTip(self.trUtf8( 'Generates a new configuration file overwriting the current one.')) self.updateConfigAct.setWhatsThis(self.trUtf8( @@ -786,7 +794,8 @@ """ Private slot to show some info about rope. """ - E5MessageBox.about(self.__ui, + E5MessageBox.about( + self.__ui, self.trUtf8("About rope"), self.trUtf8("{0}\nVersion {1}\n\n{2}".format( rope.INFO, rope.VERSION, rope.COPYRIGHT))) @@ -798,7 +807,7 @@ @return flag indicating, that undoable changes are available (boolean) """ return self.__project is not None and \ - len(self.__project.history.undo_list) > 0 + len(self.__project.history.undo_list) > 0 def __canRedo(self): """ @@ -807,7 +816,7 @@ @return flag indicating, that redoable changes are available (boolean) """ return self.__project is not None and \ - len(self.__project.history.redo_list) > 0 + len(self.__project.history.redo_list) > 0 def __getFileUndoList(self, resource): """ @@ -893,8 +902,9 @@ if handle is not None: handle.reset() if str(type(err)).split()[-1][1:-2].split('.')[-1] == \ - 'ModuleSyntaxError': - res = E5MessageBox.warning(self.__ui, title, + 'ModuleSyntaxError': + res = E5MessageBox.warning( + self.__ui, title, self.trUtf8("Rope error: {0}").format(str(err)), E5MessageBox.Ok | E5MessageBox.Open) if res == E5MessageBox.Open: @@ -903,12 +913,14 @@ err.filename), err.lineno) else: - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Rope error: {0}").format(str(err))) def __getOffset(self, editor, line, index): - """ - Private method to get the offset into the text treating CRLF as ONE character. + r""" + Private method to get the offset into the text treating CRLF as ONE + character. Note: rope seems to convert all EOL styles to just \n. @@ -947,7 +959,7 @@ Private slot to handle the Rename Current Module action. """ self.__doRename(self.trUtf8('Rename Current Module'), - renameModule=True) + renameModule=True) def __doRename(self, title, isLocal=False, renameModule=False): """ @@ -966,9 +978,10 @@ if not renameModule and not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the declaration you want to rename" - " and try again.")) + " and try again.")) return if isLocal: @@ -985,7 +998,8 @@ line, index, line1, index1 = aw.getSelection() if line != line1: # selection span more than one line - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("The selection must not extend beyond" " one line.")) return @@ -1024,9 +1038,10 @@ title = self.trUtf8("Change Occurrences") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight an occurrence to be changed" - " and try again.")) + " and try again.")) return if not self.confirmBufferIsSaved(aw): @@ -1041,7 +1056,7 @@ self.__project, filename) try: renamer = rope.refactor.rename.ChangeOccurrences( - self.__project, resource, offset) + self.__project, resource, offset) except Exception as err: self.handleRopeError(err, title) return @@ -1074,6 +1089,7 @@ @param title title of the refactoring (string) @param kind kind of extraction to be done (string, "method" or "variable") + @exception Exception raised to indicate a wrong extraction method """ aw = e5App().getObject("ViewManager").activeWindow() @@ -1082,9 +1098,10 @@ if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the region of code you want to extract" - " and try again.")) + " and try again.")) return if not self.confirmBufferIsSaved(aw): @@ -1131,9 +1148,10 @@ title = self.trUtf8("Inline") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the local variable, method or parameter" - " you want to inline and try again.")) + " you want to inline and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1173,9 +1191,10 @@ title = self.trUtf8("Move Method") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the method to move" - " and try again.")) + " and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1197,8 +1216,8 @@ if isinstance(mover, rope.refactor.move.MoveGlobal): from MoveGlobalMethodDialog import MoveGlobalMethodDialog - self.dlg = MoveGlobalMethodDialog(self, title, mover, - self.__project, parent=self.__ui) + 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) @@ -1251,7 +1270,8 @@ title = self.trUtf8("Use Function") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight a global function and try again.")) return @@ -1292,9 +1312,10 @@ title = self.trUtf8("Introduce Factory Method") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the class to introduce a factory" - " method for and try again.")) + " method for and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1310,7 +1331,7 @@ try: introducer = \ rope.refactor.introduce_factory.IntroduceFactoryRefactoring( - self.__project, resource, offset) + self.__project, resource, offset) except Exception as err: self.handleRopeError(err, title) return @@ -1332,9 +1353,10 @@ title = self.trUtf8("Introduce Parameter") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the code for the new parameter" - " and try again.")) + " and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1349,7 +1371,7 @@ self.__project, filename) try: introducer = rope.refactor.introduce_parameter.IntroduceParameter( - self.__project, resource, offset) + self.__project, resource, offset) except Exception as err: self.handleRopeError(err, title) return @@ -1368,7 +1390,8 @@ Private slot to organize imports. """ from rope.refactor.importutils import ImportOrganizer - self.__doImports(self.trUtf8("Organize Imports"), + self.__doImports( + self.trUtf8("Organize Imports"), ImportOrganizer.organize_imports) def __importsExpandStar(self): @@ -1376,7 +1399,8 @@ Private slot to expand star imports. """ from rope.refactor.importutils import ImportOrganizer - self.__doImports(self.trUtf8("Expand Star Imports"), + self.__doImports( + self.trUtf8("Expand Star Imports"), ImportOrganizer.expand_star_imports) def __importsRelativeToAbsolute(self): @@ -1384,7 +1408,8 @@ Private slot to transform relative to absolute imports. """ from rope.refactor.importutils import ImportOrganizer - self.__doImports(self.trUtf8("Relative to Absolute"), + self.__doImports( + self.trUtf8("Relative to Absolute"), ImportOrganizer.relatives_to_absolutes) def __importsFromToImport(self): @@ -1392,7 +1417,8 @@ Private slot to transform from imports to plain imports. """ from rope.refactor.importutils import ImportOrganizer - self.__doImports(self.trUtf8("Froms to Imports"), + self.__doImports( + self.trUtf8("Froms to Imports"), ImportOrganizer.froms_to_imports) def __importsHandleLong(self): @@ -1400,12 +1426,16 @@ Private slot to handle long imports. """ from rope.refactor.importutils import ImportOrganizer - self.__doImports(self.trUtf8("Handle Long Imports"), + self.__doImports( + self.trUtf8("Handle Long Imports"), ImportOrganizer.handle_long_imports) def __doImports(self, title, method): """ Private method to perform the various imports refactorings. + + @param title title to be used for the import refactoring (string) + @param method method performing the import refactoring """ aw = e5App().getObject("ViewManager").activeWindow() @@ -1437,7 +1467,8 @@ if self.__e5project.isDirty(): self.__e5project.saveProject() else: - E5MessageBox.information(self.__ui, title, + E5MessageBox.information( + self.__ui, title, self.trUtf8("The selected refactoring did not produce" " any change.")) except Exception as err: @@ -1468,9 +1499,10 @@ title = self.trUtf8("Change Method Signature") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the method or function to change" - " and try again.")) + " and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1508,9 +1540,10 @@ title = self.trUtf8("Inline Argument Default") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the method or function to inline" - " a parameter's default and try again.")) + " a parameter's default and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1576,9 +1609,10 @@ title = self.trUtf8("Encapsulate Attribute") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the attribute to encapsulate" - " and try again.")) + " and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1633,9 +1667,10 @@ title = self.trUtf8("Local Variable to Attribute") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the local variable to make an attribute" - " and try again.")) + " and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1673,9 +1708,10 @@ title = self.trUtf8("Replace Method With Method Object") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the method or function to convert" - " and try again.")) + " and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1710,11 +1746,12 @@ """ title = self.trUtf8("Undo refactoring") history = self.__project.history - res = E5MessageBox.yesNo(None, + res = E5MessageBox.yesNo( + None, title, - self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""")\ - .format(Utilities.html_encode( - history.undo_list[-1].description))) + self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""") + .format(Utilities.html_encode( + history.undo_list[-1].description))) if res: if not self.confirmAllBuffersSaved(): return @@ -1739,11 +1776,12 @@ """ title = self.trUtf8("Redo refactoring") history = self.__project.history - res = E5MessageBox.yesNo(None, + res = E5MessageBox.yesNo( + None, title, - self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""")\ - .format(Utilities.html_encode( - history.redo_list[-1].description))) + self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""") + .format(Utilities.html_encode( + history.redo_list[-1].description))) if res: if not self.confirmAllBuffersSaved(): return @@ -1820,7 +1858,8 @@ """ Private slot to clear the redo and undo lists. """ - res = E5MessageBox.yesNo(None, + res = E5MessageBox.yesNo( + None, self.trUtf8("Clear History"), self.trUtf8("""Do you really want to clear the undo""" """ and redo history?""")) @@ -1843,9 +1882,10 @@ title = self.trUtf8("Find Occurrences") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the class, method, function or variable" - " to search for and try again.")) + " to search for and try again.")) return if not self.confirmAllBuffersSaved(): @@ -1876,15 +1916,16 @@ self.dlg = MatchesDialog(self.__ui, True) self.dlg.show() for occurrence in occurrences: - self.dlg.addEntry(occurrence.resource, - occurrence.lineno, occurrence.unsure) + self.dlg.addEntry( + occurrence.resource, occurrence.lineno, occurrence.unsure) else: - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("No occurrences found.")) def __queryDefinition(self): """ - Private slot to handle the Find Definition action + Private slot to handle the Find Definition action. """ aw = e5App().getObject("ViewManager").activeWindow() @@ -1894,10 +1935,11 @@ title = self.trUtf8("Find &Definition") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the class, method, function or" - " variable reference to search definition for and" - " try again.")) + " variable reference to search definition for and" + " try again.")) return if not self.confirmAllBuffersSaved(): @@ -1923,7 +1965,8 @@ self.dlg.show() self.dlg.addEntry(location.resource, location.lineno) else: - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("No matching definition found.")) def __queryImplementations(self): @@ -1938,7 +1981,8 @@ title = self.trUtf8("Find Implementations") if not aw.hasSelectedText(): # no selection available - E5MessageBox.warning(self.__ui, title, + E5MessageBox.warning( + self.__ui, title, self.trUtf8("Highlight the method to search for" " and try again.")) return @@ -1952,8 +1996,8 @@ import rope.contrib.findit from ProgressHandle import ProgressHandle - resource = rope.base.libutils.path_to_resource(self.__project, - filename) + resource = rope.base.libutils.path_to_resource( + self.__project, filename) handle = ProgressHandle(title, True, self.__ui) handle.show() QApplication.processEvents() @@ -1970,11 +2014,11 @@ self.dlg = MatchesDialog(self.__ui, True) self.dlg.show() for occurrence in occurrences: - self.dlg.addEntry(occurrence.resource, - occurrence.lineno, occurrence.unsure) + self.dlg.addEntry( + occurrence.resource, occurrence.lineno, occurrence.unsure) else: - E5MessageBox.warning(self.__ui, title, - self.trUtf8("No occurrences found.")) + E5MessageBox.warning( + self.__ui, title, self.trUtf8("No occurrences found.")) ##################################################### ## Various actions @@ -1994,12 +2038,14 @@ self.__editor.show() self.__editor.editorSaved.connect(self.__configChanged) else: - E5MessageBox.critical(self.__ui, + E5MessageBox.critical( + self.__ui, self.trUtf8("Configure Rope"), self.trUtf8("""The Rope configuration file '{0}' does""" """ not exist.""").format(configfile)) else: - E5MessageBox.critical(self.__ui, + E5MessageBox.critical( + self.__ui, self.trUtf8("Configure Rope"), self.trUtf8("""The Rope admin directory does not exist.""")) @@ -2007,7 +2053,8 @@ """ Private slot to update the configuration file. """ - res = E5MessageBox.yesNo(self.__ui, + res = E5MessageBox.yesNo( + self.__ui, self.trUtf8("Update Configuration"), self.trUtf8("""Shall rope's current configuration be replaced """ """by a new default configuration?""")) @@ -2022,11 +2069,12 @@ self.__configChanged() self.__editConfig() except IOError as err: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8("Update Configuration"), self.trUtf8("""<p>The configuration could not be""" - """ updated.</p><p>Reason: {0}</p>""")\ - .format(str(err))) + """ updated.</p><p>Reason: {0}</p>""") + .format(str(err))) def __showRopeHelp(self): """ @@ -2046,7 +2094,8 @@ Private slot to perform SOA on all modules. """ title = self.trUtf8("Analyse all modules") - res = E5MessageBox.yesNo(self.__ui, + res = E5MessageBox.yesNo( + self.__ui, title, self.trUtf8("""This action might take some time. """ """Do you really want to perform SOA?""")) @@ -2056,10 +2105,11 @@ handle.show() QApplication.processEvents() try: - rope.base.libutils.analyze_modules(self.__project, - task_handle=handle) + rope.base.libutils.analyze_modules( + self.__project, task_handle=handle) handle.reset() - E5MessageBox.information(self.__ui, + E5MessageBox.information( + self.__ui, title, self.trUtf8("""Static object analysis (SOA) done. """ """SOA database updated.""")) @@ -2091,8 +2141,8 @@ """ import rope.base.project self.__project.close() - self.__project = rope.base.project.Project(self.__projectpath, - fscommands=self.__fsCommands) + self.__project = rope.base.project.Project( + self.__projectpath, fscommands=self.__fsCommands) def __defaultConfig(self): """ @@ -2131,8 +2181,8 @@ if self.__projectLanguage in ["Python3"]: import rope.base.project - self.__project = rope.base.project.Project(self.__projectpath, - fscommands=self.__fsCommands) + self.__project = rope.base.project.Project( + self.__projectpath, fscommands=self.__fsCommands) for act in self.actions: act.setEnabled(True) @@ -2186,7 +2236,8 @@ """ Public method to refresh modified editors. - @param reference to the Changes object (rope.base.change.ChangeSet) + @param changes reference to the ChangeSet object + (rope.base.change.ChangeSet) """ vm = e5App().getObject("ViewManager")