Utilities/ClassBrowsers/__init__.py

changeset 2779
4d433896b6d6
parent 2302
f29e9405c851
child 2847
1843ef6e2656
child 2965
d133c7edd88a
equal deleted inserted replaced
2776:43b8060a4b44 2779:4d433896b6d6
23 23
24 PY_SOURCE = imp.PY_SOURCE 24 PY_SOURCE = imp.PY_SOURCE
25 PTL_SOURCE = 128 25 PTL_SOURCE = 128
26 RB_SOURCE = 129 26 RB_SOURCE = 129
27 IDL_SOURCE = 130 27 IDL_SOURCE = 130
28 JS_SOURCE = 131
28 29
29 SUPPORTED_TYPES = [PY_SOURCE, PTL_SOURCE, RB_SOURCE, IDL_SOURCE] 30 SUPPORTED_TYPES = [PY_SOURCE, PTL_SOURCE, RB_SOURCE, IDL_SOURCE, JS_SOURCE]
30 31
31 __extensions = { 32 __extensions = {
32 "IDL": [".idl"], 33 "IDL": [".idl"],
33 "Python": [".py", ".pyw", ".ptl"], # currently not used 34 "Python": [".py", ".pyw", ".ptl"], # currently not used
34 "Ruby": [".rb"], 35 "Ruby": [".rb"],
36 "JavaScript": [".js"],
35 } 37 }
36 38
37 39
38 def readmodule(module, path=[], isPyFile=False): 40 def readmodule(module, path=[], isPyFile=False):
39 ''' 41 '''
54 idlclbr._modules.clear() 56 idlclbr._modules.clear()
55 elif ext in __extensions["Ruby"]: 57 elif ext in __extensions["Ruby"]:
56 from . import rbclbr 58 from . import rbclbr
57 dict = rbclbr.readmodule_ex(module, path) 59 dict = rbclbr.readmodule_ex(module, path)
58 rbclbr._modules.clear() 60 rbclbr._modules.clear()
61 elif ext in __extensions["JavaScript"]:
62 from . import jsclbr
63 dict = jsclbr.readmodule_ex(module, path)
64 jsclbr._modules.clear()
59 elif ext in Preferences.getPython("PythonExtensions") or \ 65 elif ext in Preferences.getPython("PythonExtensions") or \
60 ext in Preferences.getPython("Python3Extensions") or \ 66 ext in Preferences.getPython("Python3Extensions") or \
61 isPyFile: 67 isPyFile:
62 from . import pyclbr 68 from . import pyclbr
63 dict = pyclbr.readmodule_ex(module, path, isPyFile=isPyFile) 69 dict = pyclbr.readmodule_ex(module, path, isPyFile=isPyFile)
100 pathname = os.path.join(p, name) 106 pathname = os.path.join(p, name)
101 if os.path.exists(pathname): 107 if os.path.exists(pathname):
102 return (open(pathname), pathname, (ext, 'r', IDL_SOURCE)) 108 return (open(pathname), pathname, (ext, 'r', IDL_SOURCE))
103 raise ImportError 109 raise ImportError
104 110
111 elif ext in __extensions["JavaScript"]:
112 for p in path: # only search in path
113 pathname = os.path.join(p, name)
114 if os.path.exists(pathname):
115 return (open(pathname), pathname, (ext, 'r', JS_SOURCE))
116 raise ImportError
117
105 elif ext == '.ptl': 118 elif ext == '.ptl':
106 for p in path: # only search in path 119 for p in path: # only search in path
107 pathname = os.path.join(p, name) 120 pathname = os.path.join(p, name)
108 if os.path.exists(pathname): 121 if os.path.exists(pathname):
109 return (open(pathname), pathname, (ext, 'r', PTL_SOURCE)) 122 return (open(pathname), pathname, (ext, 'r', PTL_SOURCE))

eric ide

mercurial