当前位置: 首页>>代码示例>>Python>>正文


Python imp.get_suffixes方法代码示例

本文整理汇总了Python中imp.get_suffixes方法的典型用法代码示例。如果您正苦于以下问题:Python imp.get_suffixes方法的具体用法?Python imp.get_suffixes怎么用?Python imp.get_suffixes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imp的用法示例。


在下文中一共展示了imp.get_suffixes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_msvcrt

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def find_msvcrt():
        """Return the name of the VC runtime dll"""
        version = _get_build_version()
        if version is None:
            # better be safe than sorry
            return None
        if version <= 6:
            clibname = 'msvcrt'
        else:
            clibname = 'msvcr%d' % (version * 10)

        # If python was built with in debug mode
        import imp
        if imp.get_suffixes()[0][0] == '_d.pyd':
            clibname += 'd'
        return clibname+'.dll' 
开发者ID:glmcdona,项目名称:meddle,代码行数:18,代码来源:util.py

示例2: find_module_in_dir

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def find_module_in_dir(self, name, dir, allow_packages=1):
        if dir is None:
            return self.find_builtin_module(name)
        if allow_packages:
            fullname = self.hooks.path_join(dir, name)
            if self.hooks.path_isdir(fullname):
                stuff = self.find_module_in_dir("__init__", fullname, 0)
                if stuff:
                    file = stuff[0]
                    if file: file.close()
                    return None, fullname, ('', '', PKG_DIRECTORY)
        for info in self.hooks.get_suffixes():
            suff, mode, type = info
            fullname = self.hooks.path_join(dir, name+suff)
            try:
                fp = self.hooks.openfile(fullname, mode)
                return fp, fullname, info
            except self.hooks.openfile_error:
                pass
        return None 
开发者ID:glmcdona,项目名称:meddle,代码行数:22,代码来源:ihooks.py

示例3: getsourcefile

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def getsourcefile(object):
    """Return the filename that can be used to locate an object's source.
    Return None if no way can be identified to get the source.
    """
    filename = getfile(object)
    if string.lower(filename[-4:]) in ('.pyc', '.pyo'):
        filename = filename[:-4] + '.py'
    for suffix, mode, kind in imp.get_suffixes():
        if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix:
            # Looks like a binary file.  We want to only return a text file.
            return None
    if os.path.exists(filename):
        return filename
    # only return a non-existent filename if the module has a PEP 302 loader
    if hasattr(getmodule(object, filename), '__loader__'):
        return filename
    # or it is in the linecache
    if filename in linecache.cache:
        return filename 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:inspect.py

示例4: find_msvcrt

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def find_msvcrt():
        #************************************************************
        # FIXME: For GCC(mingw) runtime don't depend from compiler
        # version ;). We may use -D__MSVCRT_VERSION__ to detect which
        # verion is requested by user, but the name of the library
        # to be default.
        # As example WXP is with version 7.0 of msvcrt.dll.
        # Anyway since _get_build_version return 6 in most(standard)
        # cases this method will return msvcrt{d}. May be not so bad.
        #************************************************************
        """Return the name of the VC runtime dll"""
        version = _get_build_version()
        if version is None:
            # better be safe than sorry
            return None
        if version <= 6:
            clibname = 'msvcrt'
        else:
            clibname = 'msvcr%d' % (version * 10)

        # If python was built with in debug mode
        import imp
        if imp.get_suffixes()[0][0] == '_d.pyd':
            clibname += 'd'
        return clibname+'.dll' 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:27,代码来源:util.py

示例5: listmodules

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def listmodules(self, allnames):
        modules = {}
        suffixes = imp.get_suffixes()
        sorted = []
        for suff, mode, flag in suffixes:
            i = -len(suff)
            for name in allnames[:]:
                normed_name = os.path.normcase(name)
                if normed_name[i:] == suff:
                    mod_name = name[:i]
                    if mod_name not in modules:
                        modules[mod_name] = None
                        sorted.append((normed_name, name))
                        allnames.remove(name)
        sorted.sort()
        return sorted 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:18,代码来源:PathBrowser.py

示例6: _visit_pyfiles

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def _visit_pyfiles(list, dirname, names):
    """Helper for getFilesForName()."""
    # get extension for python source files
    if not globals().has_key('_py_ext'):
        global _py_ext
        _py_ext = [triple[0] for triple in imp.get_suffixes()
                   if triple[2] == imp.PY_SOURCE][0]

    # don't recurse into CVS directories
    if 'CVS' in names:
        names.remove('CVS')

    # add all *.py files to list
    list.extend(
        [os.path.join(dirname, file) for file in names
         if os.path.splitext(file)[1] == _py_ext]
        ) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:19,代码来源:pygettext.py

示例7: getmoduleinfo

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def getmoduleinfo(path):
    """Get the module name, suffix, mode, and module type for a given file."""
    warnings.warn('inspect.getmoduleinfo() is deprecated', DeprecationWarning,
                  2)
    filename = os.path.basename(path)
    suffixes = [(-len(suffix), suffix, mode, mtype)
                    for suffix, mode, mtype in 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) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:13,代码来源:inspect.py

示例8: GeneratePythonPaths

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def GeneratePythonPaths(*p):
  """Generate all valid filenames for the given file.

  Args:
    p: Positional args are the folders to the file and finally the file
       without a suffix.

  Returns:
    A list of strings representing the given path to a file with each valid
      suffix for this python build.
  """
  suffixes = imp.get_suffixes()
  return [os.path.join(*p) + s for s, m, t in suffixes] 
开发者ID:elsigh,项目名称:browserscope,代码行数:15,代码来源:dev_appserver_import_hook.py

示例9: get_abi3_suffix

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def get_abi3_suffix():
    """Return the file extension for an abi3-compliant Extension()"""
    for suffix, _, _ in (s for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION):
        if '.abi3' in suffix:  # Unix
            return suffix
        elif suffix == '.pyd':  # Windows
            return suffix 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:9,代码来源:build_ext.py

示例10: find_all_submodules

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def find_all_submodules(self, m):
        if not m.__path__:
            return
        modules = {}
        # 'suffixes' used to be a list hardcoded to [".py", ".pyc", ".pyo"].
        # But we must also collect Python extension modules - although
        # we cannot separate normal dlls from Python extensions.
        suffixes = []
        for triple in imp.get_suffixes():
            suffixes.append(triple[0])
        for dir in m.__path__:
            try:
                names = os.listdir(dir)
            except os.error:
                self.msg(2, "can't list directory", dir)
                continue
            for name in names:
                mod = None
                for suff in suffixes:
                    n = len(suff)
                    if name[-n:] == suff:
                        mod = name[:-n]
                        break
                if mod and mod != "__init__":
                    modules[mod] = mod
        return modules.keys() 
开发者ID:glmcdona,项目名称:meddle,代码行数:28,代码来源:modulefinder.py

示例11: get_suffixes

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def get_suffixes(self):
        return self.rexec.get_suffixes() 
开发者ID:glmcdona,项目名称:meddle,代码行数:4,代码来源:rexec.py

示例12: getmoduleinfo

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def getmoduleinfo(path):
    """Get the module name, suffix, mode, and module type for a given file."""
    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) 
开发者ID:glmcdona,项目名称:meddle,代码行数:12,代码来源:inspect.py

示例13: get_suffixes

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def get_suffixes(self): return imp.get_suffixes() 
开发者ID:glmcdona,项目名称:meddle,代码行数:3,代码来源:ihooks.py

示例14: IsDebug

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def IsDebug():
    """Return "_d" if we're running a debug version.

    This is to be used within DLL names when locating them.
    """
    import imp
    for suffix_item in imp.get_suffixes():
        if suffix_item[0]=='_d.pyd':
            return '_d'
    return '' 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:regsetup.py

示例15: test_imp_basic

# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_suffixes [as 别名]
def test_imp_basic(self):
        magic = imp.get_magic()
        suffixes = imp.get_suffixes()
        self.assertTrue(isinstance(suffixes, list))
        for suffix in suffixes:
            self.assertTrue(isinstance(suffix, tuple))
            self.assertEqual(len(suffix), 3)
        self.assertTrue((".py", "U", 1) in suffixes) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_imp.py


注:本文中的imp.get_suffixes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。