7634:8c3d033e5044 | 7635:0cdead130a81 |
---|---|
22 import importlib.machinery | 22 import importlib.machinery |
23 import re | 23 import re |
24 | 24 |
25 import Utilities | 25 import Utilities |
26 from functools import reduce | 26 from functools import reduce |
27 import Preferences | |
28 | 27 |
29 __all__ = ["Module", "Class", "Function", "Attribute", "RbModule", | 28 __all__ = ["Module", "Class", "Function", "Attribute", "RbModule", |
30 "readModule", "getTypeFromTypeName"] | 29 "readModule", "getTypeFromTypeName"] |
31 | 30 |
32 TABWIDTH = 4 | 31 TABWIDTH = 4 |
37 RB_SOURCE = 129 | 36 RB_SOURCE = 129 |
38 | 37 |
39 SUPPORTED_TYPES = [PY_SOURCE, PTL_SOURCE, RB_SOURCE] | 38 SUPPORTED_TYPES = [PY_SOURCE, PTL_SOURCE, RB_SOURCE] |
40 TYPE_MAPPING = { | 39 TYPE_MAPPING = { |
41 "Python": PY_SOURCE, | 40 "Python": PY_SOURCE, |
42 "Python2": PY_SOURCE, | |
43 "Python3": PY_SOURCE, | 41 "Python3": PY_SOURCE, |
44 "MicroPython": PY_SOURCE, | 42 "MicroPython": PY_SOURCE, |
45 "Ruby": RB_SOURCE, | 43 "Ruby": RB_SOURCE, |
46 } | 44 } |
47 | 45 |
1272 Public method to get the type of the module's source. | 1270 Public method to get the type of the module's source. |
1273 | 1271 |
1274 @return type of the modules's source (string) | 1272 @return type of the modules's source (string) |
1275 """ | 1273 """ |
1276 if self.type in [PY_SOURCE, PTL_SOURCE]: | 1274 if self.type in [PY_SOURCE, PTL_SOURCE]: |
1277 py3ExtList = Preferences.getDebugger("Python3Extensions").split() | 1275 moduleType = "Python3" |
1278 if self.file.endswith(tuple(py3ExtList)): | |
1279 moduleType = "Python3" | |
1280 else: | |
1281 moduleType = "Python2" | |
1282 elif self.type == RB_SOURCE: | 1276 elif self.type == RB_SOURCE: |
1283 moduleType = "Ruby" | 1277 moduleType = "Ruby" |
1284 else: | 1278 else: |
1285 moduleType = "" | 1279 moduleType = "" |
1286 return moduleType | 1280 return moduleType |