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


Python Library.add方法代码示例

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


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

示例1: package

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import add [as 别名]
def package(name, type, title, order, layer, library, require):
    global _libraries, _packages

    sm = getGlobalSiteManager()

    # create marker interface
    marker = _libraries.get((library, type))
    if marker is None:
        uid = str(random.randint(0, 9999999))
        marker = InterfaceClass('IPackage%s'%uid, (interface.Interface,),
                                __doc__='Package: %s' %name,
                                __module__='zojax.resourcepackage')
        _libraries[(library, type)] = marker

    # check if package already registered
    packageInfo = None
    for (_layer, _library, _type), _packageInfo in _packages.items():
        if _library == library and layer.isOrExtends(_layer) and _type == type:
            packageInfo = _packageInfo
    if packageInfo is not None:
        # register library
        if library:
            lib = sm.queryUtility(ILibrary, name=library)
            if lib is None:
                lib = Library(library)
                handler('registerUtility', lib, ILibrary, library)

            lib.add(name, require)

        return

    # create package
    package = getUtility(IPackageFactory, type)(name, order, title)
    interface.directlyProvides(package, marker)

    factory = Factory(package)

    # register resource
    sm.registerAdapter(factory, (layer, ), interface.Interface, name)
    sm.registerAdapter(factory, (layer, ), IPackage, name)

    # register package info
    packageInfo = PackageInfo(library, layer, marker, package)
    _packages[(layer, library, type)] = packageInfo

    # register library
    if library:
        lib = sm.queryUtility(ILibrary, name=library)
        if lib is None:
            lib = Library(library)
            handler('registerUtility', lib, ILibrary, library)

        lib.add(name, require)
开发者ID:Zojax,项目名称:zojax.resourcepackage,代码行数:55,代码来源:zcml.py


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