8 """ |
8 """ |
9 |
9 |
10 import sys |
10 import sys |
11 import os |
11 import os |
12 import json |
12 import json |
|
13 import contextlib |
13 |
14 |
14 from PyQt5.QtCore import ( |
15 from PyQt5.QtCore import ( |
15 pyqtSlot, Qt, QMetaObject, QRegularExpression, QSortFilterProxyModel, |
16 pyqtSlot, Qt, QMetaObject, QRegularExpression, QSortFilterProxyModel, |
16 QProcess, QProcessEnvironment |
17 QProcess, QProcessEnvironment |
17 ) |
18 ) |
94 ed = vm.getOpenEditor(self.srcFile) |
95 ed = vm.getOpenEditor(self.srcFile) |
95 if ed and not vm.checkDirty(ed): |
96 if ed and not vm.checkDirty(ed): |
96 self.__initError = True |
97 self.__initError = True |
97 return |
98 return |
98 |
99 |
99 try: |
100 with contextlib.suppress(ImportError): |
100 splitExt = os.path.splitext(self.srcFile) |
101 splitExt = os.path.splitext(self.srcFile) |
101 exts = [splitExt[1]] if len(splitExt) == 2 else None |
102 exts = [splitExt[1]] if len(splitExt) == 2 else None |
102 from Utilities import ModuleParser |
103 from Utilities import ModuleParser |
103 self.__module = ModuleParser.readModule( |
104 self.__module = ModuleParser.readModule( |
104 self.srcFile, extensions=exts, caching=False) |
105 self.srcFile, extensions=exts, caching=False) |
105 except ImportError: |
|
106 pass |
|
107 |
106 |
108 if self.__module is not None: |
107 if self.__module is not None: |
109 self.filenameEdit.setText(self.srcFile) |
108 self.filenameEdit.setText(self.srcFile) |
110 |
109 |
111 classesList = [] |
110 classesList = [] |