197 """ |
197 """ |
198 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno) |
198 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno) |
199 VisibilityMixin.__init__(self) |
199 VisibilityMixin.__init__(self) |
200 |
200 |
201 |
201 |
202 # TODO: extract scan function (see pyclbr) |
|
203 def readmodule_ex(module, path=None): |
202 def readmodule_ex(module, path=None): |
204 """ |
203 """ |
205 Read a CORBA IDL file and return a dictionary of classes, functions and |
204 Read a CORBA IDL file and return a dictionary of classes, functions and |
206 modules. |
205 modules. |
207 |
206 |
227 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, fullpath) |
223 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, fullpath) |
228 if f: |
224 if f: |
229 f.close() |
225 f.close() |
230 if type not in SUPPORTED_TYPES: |
226 if type not in SUPPORTED_TYPES: |
231 # not CORBA IDL source, can't do anything with this module |
227 # not CORBA IDL source, can't do anything with this module |
232 _modules[module] = dictionary |
228 _modules[module] = {} |
233 return dictionary |
229 return {} |
234 |
230 |
235 _modules[module] = dictionary |
|
236 classstack = [] # stack of (class, indent) pairs |
|
237 indent = 0 |
|
238 try: |
231 try: |
239 src = Utilities.readEncodedFile(file)[0] |
232 src = Utilities.readEncodedFile(file)[0] |
240 except (UnicodeError, IOError): |
233 except (UnicodeError, IOError): |
241 # can't do anything with this module |
234 # can't do anything with this module |
242 _modules[module] = dictionary |
235 _modules[module] = {} |
243 return dictionary |
236 return {} |
|
237 |
|
238 _modules[module] = scan(src, file, module) |
|
239 return _modules[module] |
|
240 |
|
241 |
|
242 def scan(src, file, module): |
|
243 """ |
|
244 Public method to scan the given source text. |
|
245 |
|
246 @param src source text to be scanned |
|
247 @type str |
|
248 @param file file name associated with the source text |
|
249 @type str |
|
250 @param module module name associated with the source text |
|
251 @type str |
|
252 @return dictionary containing the extracted data |
|
253 @rtype dict |
|
254 """ |
244 # convert eol markers the Python style |
255 # convert eol markers the Python style |
245 src = src.replace("\r\n", "\n").replace("\r", "\n") |
256 src = src.replace("\r\n", "\n").replace("\r", "\n") |
246 |
257 |
|
258 dictionary = {} |
|
259 dict_counts = {} |
|
260 |
|
261 classstack = [] # stack of (class, indent) pairs |
|
262 indent = 0 |
|
263 |
247 lineno, last_lineno_pos = 1, 0 |
264 lineno, last_lineno_pos = 1, 0 |
248 lastGlobalEntry = None |
265 lastGlobalEntry = None |
249 cur_obj = None |
266 cur_obj = None |
250 i = 0 |
267 i = 0 |
251 while True: |
268 while True: |