26 # Start-Of-Header |
26 # Start-Of-Header |
27 name = "Radon Metrics Plugin" |
27 name = "Radon Metrics Plugin" |
28 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
28 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
29 autoactivate = True |
29 autoactivate = True |
30 deactivateable = True |
30 deactivateable = True |
31 version = "0.1.0" |
31 version = "0.2.0" |
32 className = "RadonMetricsPlugin" |
32 className = "RadonMetricsPlugin" |
33 packageName = "RadonMetrics" |
33 packageName = "RadonMetrics" |
34 shortDescription = "Code metrics plugin using radon package" |
34 shortDescription = "Code metrics plugin using radon package" |
35 longDescription = ( |
35 longDescription = ( |
36 """This plug-in implements dialogs to show various code metrics. These""" |
36 """This plug-in implements dialogs to show various code metrics. These""" |
618 )) |
618 )) |
619 act.triggered.connect(self.__editorCyclomaticComplexity) |
619 act.triggered.connect(self.__editorCyclomaticComplexity) |
620 self.__editorMetricsActs.append(act) |
620 self.__editorMetricsActs.append(act) |
621 |
621 |
622 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu) |
622 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu) |
|
623 e5App().getObject("Project").projectClosed.connect( |
|
624 self.__projectClosed) |
623 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ |
625 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ |
624 .showMenu.connect(self.__projectBrowserShowMenu) |
626 .showMenu.connect(self.__projectBrowserShowMenu) |
625 e5App().getObject("ViewManager").editorOpenedEd.connect( |
627 e5App().getObject("ViewManager").editorOpenedEd.connect( |
626 self.__editorOpened) |
628 self.__editorOpened) |
627 e5App().getObject("ViewManager").editorClosedEd.connect( |
629 e5App().getObject("ViewManager").editorClosedEd.connect( |
636 """ |
638 """ |
637 Public method to deactivate this plug-in. |
639 Public method to deactivate this plug-in. |
638 """ |
640 """ |
639 e5App().getObject("Project").showMenu.disconnect( |
641 e5App().getObject("Project").showMenu.disconnect( |
640 self.__projectShowMenu) |
642 self.__projectShowMenu) |
|
643 e5App().getObject("Project").projectClosed.disconnect( |
|
644 self.__projectClosed) |
641 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ |
645 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ |
642 .showMenu.disconnect(self.__projectBrowserShowMenu) |
646 .showMenu.disconnect(self.__projectBrowserShowMenu) |
643 e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
647 e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
644 self.__editorOpened) |
648 self.__editorOpened) |
645 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
649 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
842 for file in project.pdata["SOURCES"] |
846 for file in project.pdata["SOURCES"] |
843 if file.endswith( |
847 if file.endswith( |
844 tuple(Preferences.getPython("Python3Extensions")) + |
848 tuple(Preferences.getPython("Python3Extensions")) + |
845 tuple(Preferences.getPython("PythonExtensions")))] |
849 tuple(Preferences.getPython("PythonExtensions")))] |
846 |
850 |
847 from RadonMetrics.RawMetricsDialog import RawMetricsDialog |
851 if self.__projectRawMetricsDialog is None: |
848 self.__projectRawMetricsDialog = RawMetricsDialog(self) |
852 from RadonMetrics.RawMetricsDialog import RawMetricsDialog |
|
853 self.__projectRawMetricsDialog = RawMetricsDialog(self) |
849 self.__projectRawMetricsDialog.show() |
854 self.__projectRawMetricsDialog.show() |
850 self.__projectRawMetricsDialog.prepare(files, project) |
855 self.__projectRawMetricsDialog.prepare(files, project) |
851 |
856 |
852 def __projectBrowserRawMetrics(self): |
857 def __projectBrowserRawMetrics(self): |
853 """ |
858 """ |
865 try: |
870 try: |
866 fn = itm.fileName() |
871 fn = itm.fileName() |
867 except AttributeError: |
872 except AttributeError: |
868 fn = itm.dirName() |
873 fn = itm.dirName() |
869 |
874 |
870 from RadonMetrics.RawMetricsDialog import RawMetricsDialog |
875 if self.__projectBrowserRawMetricsDialog is None: |
871 self.__projectBrowserRawMetricsDialog = RawMetricsDialog(self) |
876 from RadonMetrics.RawMetricsDialog import RawMetricsDialog |
|
877 self.__projectBrowserRawMetricsDialog = RawMetricsDialog(self) |
872 self.__projectBrowserRawMetricsDialog.show() |
878 self.__projectBrowserRawMetricsDialog.show() |
873 self.__projectBrowserRawMetricsDialog.start(fn) |
879 self.__projectBrowserRawMetricsDialog.start(fn) |
874 |
880 |
875 def __editorRawMetrics(self): |
881 def __editorRawMetrics(self): |
876 """ |
882 """ |
878 menu. |
884 menu. |
879 """ |
885 """ |
880 editor = e5App().getObject("ViewManager").activeWindow() |
886 editor = e5App().getObject("ViewManager").activeWindow() |
881 if editor is not None: |
887 if editor is not None: |
882 if editor.checkDirty() and editor.getFileName() is not None: |
888 if editor.checkDirty() and editor.getFileName() is not None: |
883 from RadonMetrics.RawMetricsDialog import RawMetricsDialog |
889 if self.__editorRawMetricsDialog is None: |
884 self.__editorRawMetricsDialog = RawMetricsDialog(self) |
890 from RadonMetrics.RawMetricsDialog import RawMetricsDialog |
|
891 self.__editorRawMetricsDialog = RawMetricsDialog(self) |
885 self.__editorRawMetricsDialog.show() |
892 self.__editorRawMetricsDialog.show() |
886 self.__editorRawMetricsDialog.start(editor.getFileName()) |
893 self.__editorRawMetricsDialog.start(editor.getFileName()) |
887 |
894 |
888 ################################################################## |
895 ################################################################## |
889 ## Maintainability index calculations |
896 ## Maintainability index calculations |
901 for file in project.pdata["SOURCES"] |
908 for file in project.pdata["SOURCES"] |
902 if file.endswith( |
909 if file.endswith( |
903 tuple(Preferences.getPython("Python3Extensions")) + |
910 tuple(Preferences.getPython("Python3Extensions")) + |
904 tuple(Preferences.getPython("PythonExtensions")))] |
911 tuple(Preferences.getPython("PythonExtensions")))] |
905 |
912 |
906 from RadonMetrics.MaintainabilityIndexDialog import \ |
913 if self.__projectMIDialog is None: |
907 MaintainabilityIndexDialog |
914 from RadonMetrics.MaintainabilityIndexDialog import \ |
908 self.__projectMIDialog = MaintainabilityIndexDialog(self) |
915 MaintainabilityIndexDialog |
|
916 self.__projectMIDialog = MaintainabilityIndexDialog(self) |
909 self.__projectMIDialog.show() |
917 self.__projectMIDialog.show() |
910 self.__projectMIDialog.prepare(files, project) |
918 self.__projectMIDialog.prepare(files, project) |
911 |
919 |
912 def __projectBrowserMaintainabilityIndex(self): |
920 def __projectBrowserMaintainabilityIndex(self): |
913 """ |
921 """ |
925 try: |
933 try: |
926 fn = itm.fileName() |
934 fn = itm.fileName() |
927 except AttributeError: |
935 except AttributeError: |
928 fn = itm.dirName() |
936 fn = itm.dirName() |
929 |
937 |
930 from RadonMetrics.MaintainabilityIndexDialog import \ |
938 if self.__projectBrowserMIDialog is None: |
931 MaintainabilityIndexDialog |
939 from RadonMetrics.MaintainabilityIndexDialog import \ |
932 self.__projectBrowserMIDialog = MaintainabilityIndexDialog(self) |
940 MaintainabilityIndexDialog |
|
941 self.__projectBrowserMIDialog = MaintainabilityIndexDialog(self) |
933 self.__projectBrowserMIDialog.show() |
942 self.__projectBrowserMIDialog.show() |
934 self.__projectBrowserMIDialog.start(fn) |
943 self.__projectBrowserMIDialog.start(fn) |
935 |
944 |
936 def __editorMaintainabilityIndex(self): |
945 def __editorMaintainabilityIndex(self): |
937 """ |
946 """ |
939 show menu. |
948 show menu. |
940 """ |
949 """ |
941 editor = e5App().getObject("ViewManager").activeWindow() |
950 editor = e5App().getObject("ViewManager").activeWindow() |
942 if editor is not None: |
951 if editor is not None: |
943 if editor.checkDirty() and editor.getFileName() is not None: |
952 if editor.checkDirty() and editor.getFileName() is not None: |
944 from RadonMetrics.MaintainabilityIndexDialog import \ |
953 if self.__editorMIDialog is None: |
945 MaintainabilityIndexDialog |
954 from RadonMetrics.MaintainabilityIndexDialog import \ |
946 self.__editorMIDialog = MaintainabilityIndexDialog(self) |
955 MaintainabilityIndexDialog |
|
956 self.__editorMIDialog = MaintainabilityIndexDialog(self) |
947 self.__editorMIDialog.show() |
957 self.__editorMIDialog.show() |
948 self.__editorMIDialog.start(editor.getFileName()) |
958 self.__editorMIDialog.start(editor.getFileName()) |
949 |
959 |
950 ################################################################## |
960 ################################################################## |
951 ## Cyclomatic complexity calculations |
961 ## Cyclomatic complexity calculations |
1035 """ Studio)</li>""" |
1045 """ Studio)</li>""" |
1036 """<li><b>McCabe's complexity</b>, i.e. cyclomatic""" |
1046 """<li><b>McCabe's complexity</b>, i.e. cyclomatic""" |
1037 """ complexity</li>""" |
1047 """ complexity</li>""" |
1038 """</ul></p>""" |
1048 """</ul></p>""" |
1039 ).format(__version__)) |
1049 ).format(__version__)) |
|
1050 |
|
1051 ################################################################## |
|
1052 ## Project handling methods |
|
1053 ################################################################## |
|
1054 |
|
1055 def __projectClosed(self): |
|
1056 """ |
|
1057 Private slot to handle closing a project. |
|
1058 """ |
|
1059 self.__projectCCDialog and self.__projectCCDialog.clear() |
|
1060 self.__projectMIDialog and self.__projectMIDialog.clear() |
|
1061 self.__projectRawMetricsDialog and \ |
|
1062 self.__projectRawMetricsDialog.clear() |