當前位置: 首頁>>代碼示例>>Python>>正文


Python machinery.SOURCE_SUFFIXES屬性代碼示例

本文整理匯總了Python中importlib.machinery.SOURCE_SUFFIXES屬性的典型用法代碼示例。如果您正苦於以下問題:Python machinery.SOURCE_SUFFIXES屬性的具體用法?Python machinery.SOURCE_SUFFIXES怎麽用?Python machinery.SOURCE_SUFFIXES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在importlib.machinery的用法示例。


在下文中一共展示了machinery.SOURCE_SUFFIXES屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_package

# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import SOURCE_SUFFIXES [as 別名]
def load_package(name, path):
    """**DEPRECATED**"""
    if os.path.isdir(path):
        extensions = (machinery.SOURCE_SUFFIXES[:] +
                      machinery.BYTECODE_SUFFIXES[:])
        for extension in extensions:
            path = os.path.join(path, '__init__'+extension)
            if os.path.exists(path):
                break
        else:
            raise ValueError('{!r} is not a package'.format(path))
    spec = util.spec_from_file_location(name, path,
                                        submodule_search_locations=[])
    if name in sys.modules:
        return _exec(spec, sys.modules[name])
    else:
        return _load(spec) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:19,代碼來源:imp.py

示例2: load_package

# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import SOURCE_SUFFIXES [as 別名]
def load_package(name, path):
    """**DEPRECATED**"""
    if os.path.isdir(path):
        extensions = (machinery.SOURCE_SUFFIXES[:] +
                      machinery.BYTECODE_SUFFIXES[:])
        for extension in extensions:
            init_path = os.path.join(path, '__init__' + extension)
            if os.path.exists(init_path):
                path = init_path
                break
        else:
            raise ValueError('{!r} is not a package'.format(path))
    spec = util.spec_from_file_location(name, path,
                                        submodule_search_locations=[])
    if name in sys.modules:
        return _exec(spec, sys.modules[name])
    else:
        return _load(spec) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:20,代碼來源:imp.py

示例3: get_suffixes

# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import SOURCE_SUFFIXES [as 別名]
def get_suffixes():
    warnings.warn('imp.get_suffixes() is deprecated; use the constants '
                  'defined on importlib.machinery instead',
                  DeprecationWarning, 2)
    extensions = [(s, 'rb', C_EXTENSION) for s in machinery.EXTENSION_SUFFIXES]
    source = [(s, 'U', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES]
    bytecode = [(s, 'rb', PY_COMPILED) for s in machinery.BYTECODE_SUFFIXES]

    return extensions + source + bytecode 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:11,代碼來源:imp.py

示例4: load_package

# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import SOURCE_SUFFIXES [as 別名]
def load_package(name, path):
    msg = ('imp.load_package() is deprecated; use either '
           'importlib.machinery.SourceFileLoader() or '
           'importlib.machinery.SourcelessFileLoader() instead')
    warnings.warn(msg, DeprecationWarning, 2)
    if os.path.isdir(path):
        extensions = (machinery.SOURCE_SUFFIXES[:] +
                      machinery.BYTECODE_SUFFIXES[:])
        for extension in extensions:
            path = os.path.join(path, '__init__'+extension)
            if os.path.exists(path):
                break
        else:
            raise ValueError('{!r} is not a package'.format(path))
    return _bootstrap.SourceFileLoader(name, path).load_module(name) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:17,代碼來源:imp.py

示例5: get_suffixes

# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import SOURCE_SUFFIXES [as 別名]
def get_suffixes():
    """**DEPRECATED**"""
    extensions = [(s, 'rb', C_EXTENSION) for s in machinery.EXTENSION_SUFFIXES]
    source = [(s, 'r', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES]
    bytecode = [(s, 'rb', PY_COMPILED) for s in machinery.BYTECODE_SUFFIXES]

    return extensions + source + bytecode 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:9,代碼來源:imp.py


注:本文中的importlib.machinery.SOURCE_SUFFIXES屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。