6 """ |
6 """ |
7 Module implementing the editor outline model. |
7 Module implementing the editor outline model. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
|
11 import contextlib |
11 |
12 |
12 from PyQt5.QtCore import QCoreApplication, QModelIndex |
13 from PyQt5.QtCore import QCoreApplication, QModelIndex |
13 |
14 |
14 from UI.BrowserModel import ( |
15 from UI.BrowserModel import ( |
15 BrowserModel, BrowserItem, BrowserClassItem, BrowserCodingItem, |
16 BrowserModel, BrowserItem, BrowserClassItem, BrowserCodingItem, |
104 for key in keys: |
105 for key in keys: |
105 if key.startswith("@@"): |
106 if key.startswith("@@"): |
106 # special treatment done later |
107 # special treatment done later |
107 continue |
108 continue |
108 cl = dictionary[key] |
109 cl = dictionary[key] |
109 try: |
110 with contextlib.suppress(AttributeError): |
110 if cl.module == self.__module: |
111 if cl.module == self.__module: |
111 node = BrowserClassItem( |
112 node = BrowserClassItem( |
112 parentItem, cl, self.__filename) |
113 parentItem, cl, self.__filename) |
113 self._addItem(node, parentItem) |
114 self._addItem(node, parentItem) |
114 except AttributeError: |
|
115 pass |
|
116 if ( |
115 if ( |
117 "@@Coding@@" in keys and |
116 "@@Coding@@" in keys and |
118 Preferences.getEditor("SourceOutlineShowCoding") |
117 Preferences.getEditor("SourceOutlineShowCoding") |
119 ): |
118 ): |
120 node = BrowserCodingItem( |
119 node = BrowserCodingItem( |