Пример #1
0
def importModule(name,
                 loctype='COMMON_STATIC',
                 level=None,
                 localizedSite=None,
                 localizationUser=None):
    """
    Takes a name (filename and localization path) and the localization type and finds the 
    file and overrides it, and returns the module
    
    Args:
            name : the name and path of the file in localization
            loctype : a string representation of the localization type
            level : a string representation of the localization level (BASE, SITE, etc.)
            localizedSite: the site that localization information should be
                retrieved for (if applicable)
            localizationUser: the user that localization information should
                be retrieved for (if applicable)
    
    Returns:
            a module that has all the correct methods after being overridden
    """
    if not JEP_AVAILABLE:
        if localizationHost is None:
            localizationHost = THRIFT_HOST

        if localizationPort is None:
            localizationPort = THRIFT_PORT

        return PythonOverriderPure.importModule(name, localizationHost,
                                                localizationPort,
                                                localizedSite,
                                                localizationUser, loctype,
                                                level)

    pathManager = PathManager()
    tieredFiles = pathManager.getTieredLocalizationFile(loctype, name)
    availableLevels = pathManager.getAvailableLevels()
    levels = PythonOverriderCore._buildLocalizationLevelsList(
        availableLevels, level)

    lfiles = []
    for _level in levels:
        if _level in tieredFiles:
            lfiles.append(tieredFiles[_level].getPath())
    themodule = PythonOverriderCore._internalOverride(lfiles)
    return themodule