Example #1
0
 def isSystemWideImport( self, importString ):
     " Provides a path to the system wide import or None "
     # Systemwide modules may not have a path if it is a
     # built-in module, or to have a path to an .so library
     try:
         path = getSystemWideModules()[ importString ]
         if path is None:
             return True, None
         if path.endswith( ".py" ):
             return True, path
         if path.endswith( ".py3" ):
             return True, path
         return True, None
     except:
         return False, None
Example #2
0
def resolveImports( basePath, imports ):
    " Resolves a list of imports "
    specificModules = getProjectSpecificModules( basePath )
    systemwideModules = getSystemWideModules()

    result = []
    for item in imports:
        try:
            path = specificModules[ item ]
            if path is not None:
                if os.path.isdir( path ):
                    path += os.path.sep + "__init__.py"
                    if not os.path.exists( path ):
                        path += "3"
                        if not os.path.exists( path ):
                            continue
                else:
                    if not path.endswith( ".py" ) and \
                       not path.endswith( ".py3" ):
                        continue
                result.append( [ item, path ] )
            continue
        except:
            pass

        try:
            path = systemwideModules[ item ]
            if path is not None:
                if os.path.isdir( path ):
                    path += os.path.sep + "__init__.py"
                    if not os.path.exists( path ):
                        path += "3"
                        if not os.path.exists( path ):
                            continue
                else:
                    if not path.endswith( ".py" ) and \
                       not path.endswith( ".py3" ):
                        continue
                result.append( [ item, path ] )
        except:
            pass

    return result