def getmoduleinfo(path):
    filename = os.path.basename(path)
    suffixes = map(lambda info:
                   (-len(info[0]), info[0], info[1], info[2]),
                    imp.get_suffixes())
    suffixes.sort() # try longest suffixes first, in case they overlap
    for neglen, suffix, mode, mtype in suffixes:
        if filename[neglen:] == suffix:
            return ModuleInfo(filename[:neglen], suffix, mode, mtype)
Get the module name, suffix, mode, and module type for a given file.
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/inspect.py/getmoduleinfo