393 self.importedNames[name] = [lineno] |
395 self.importedNames[name] = [lineno] |
394 else: |
396 else: |
395 self.importedNames[name].append(lineno) |
397 self.importedNames[name].append(lineno) |
396 |
398 |
397 |
399 |
398 def readmodule_ex(module, path=None, isTypeFile=False): |
400 def readmodule_ex(module, searchPath=None, isTypeFile=False): |
399 """ |
401 """ |
400 Read a module file and return a dictionary of classes. |
402 Read a module file and return a dictionary of classes. |
401 |
403 |
402 Search for MODULE in PATH and sys.path, read and parse the |
404 Search for MODULE in PATH and sys.path, read and parse the |
403 module and return a dictionary with one entry for each class |
405 module and return a dictionary with one entry for each class |
404 found in the module. |
406 found in the module. |
405 |
407 |
406 @param module name of the module file |
408 @param module name of the module file |
407 @type str |
409 @type str |
408 @param path path the module should be searched in |
410 @param searchPath path the module should be searched in |
409 @type list of str |
411 @type list of str |
410 @param isTypeFile flag indicating a file of this type |
412 @param isTypeFile flag indicating a file of this type |
411 @type bool |
413 @type bool |
412 @return the resulting dictionary |
414 @return the resulting dictionary |
413 @rtype dict |
415 @rtype dict |
414 """ |
416 """ |
415 # search the path for the module |
417 fsInterface = ericApp().getObject("EricServer").getServiceInterface("FileSystem") |
416 path = [] if path is None else path[:] |
418 |
417 f = None |
419 if searchPath and FileSystemUtilities.isRemoteFileName(searchPath[0]): |
418 if f is None: |
420 type = ClassBrowsers.determineSourceType(module, isTypeFile) |
419 fullpath = path[:] + sys.path[:] |
421 file = fsInterface.join(searchPath[0], module) |
|
422 else: |
|
423 # search the path for the module |
|
424 searchPath = [] if searchPath is None else searchPath[:] |
|
425 fullpath = searchPath[:] + sys.path[:] |
420 f, file, (suff, mode, type) = ClassBrowsers.find_module( |
426 f, file, (suff, mode, type) = ClassBrowsers.find_module( |
421 module, fullpath, isTypeFile |
427 module, fullpath, isTypeFile |
422 ) |
428 ) |
423 if f: |
429 if f: |
424 f.close() |
430 f.close() |
|
431 |
425 if type not in SUPPORTED_TYPES: |
432 if type not in SUPPORTED_TYPES: |
426 # not Python source, can't do anything with this module |
433 # not Python source, can't do anything with this module |
427 return {} |
434 return {} |
428 |
435 |
429 try: |
436 try: |
430 src = Utilities.readEncodedFile(file)[0] |
437 if FileSystemUtilities.isRemoteFileName(file): |
|
438 src = fsInterface.readEncodedFile(file)[0] |
|
439 else: |
|
440 src = Utilities.readEncodedFile(file)[0] |
431 except (OSError, UnicodeError): |
441 except (OSError, UnicodeError): |
432 # can't do anything with this module |
442 # can't do anything with this module |
433 return {} |
443 return {} |
434 |
444 |
435 return scan(src, file, module) |
445 return scan(src, file, module) |