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


Python plugin.get_plugins函数代码示例

本文整理汇总了Python中smqtk.utils.plugin.get_plugins函数的典型用法代码示例。如果您正苦于以下问题:Python get_plugins函数的具体用法?Python get_plugins怎么用?Python get_plugins使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_descriptor_element_impls

def get_descriptor_element_impls(reload_modules=False):
    """
    Discover and return discovered ``DescriptorElement`` classes. Keys in the
    returned map are the names of the discovered classes, and the paired values
    are the actual class type objects.

    We search for implementation classes in:
        - modules next to this file this function is defined in (ones that begin
          with an alphanumeric character),
        - python modules listed in the environment variable ``DESCRIPTOR_ELEMENT_PATH``
            - This variable should contain a sequence of python module
              specifications, separated by the platform specific PATH separator
              character (``;`` for Windows, ``:`` for unix)

    Within a module we first look for a helper variable by the name
    ``DESCRIPTOR_ELEMENT_CLASS``, which can either be a single class object or
    an iterable of class objects, to be specifically exported. If the variable
    is set to None, we skip that module and do not import anything. If the
    variable is not present, we look at attributes defined in that module for
    classes that descend from the given base class type. If none of the above
    are found, or if an exception occurs, the module is skipped.

    :param reload_modules: Explicitly reload discovered modules from source.
    :type reload_modules: bool

    :return: Map of discovered class object of type ``DescriptorElement``
        whose keys are the string names of the classes.
    :rtype: dict[str, type]

    """
    this_dir = os.path.abspath(os.path.dirname(__file__))
    env_var = "DESCRIPTOR_ELEMENT_PATH"
    helper_var = "DESCRIPTOR_ELEMENT_CLASS"
    return plugin.get_plugins(__name__, this_dir, env_var, helper_var,
                              DescriptorElement, reload_modules)
开发者ID:msarahan,项目名称:SMQTK,代码行数:35,代码来源:__init__.py

示例2: get_descriptor_element_impls

def get_descriptor_element_impls():
    """
    Discover and return Descriptor implementation classes found in the plugin
    directory. Keys in the returned map are the names of the discovered classes
    and the paired values are the actual class type objects.

    We look for modules (directories or files) that start with and alphanumeric
    character ('_' prefixed files/directories are hidden, but not recommended).

    Within a module, we first look for a helper variable by the name
    ``DESCRIPTOR_ELEMENT_CLASS``, which can either be a single class object or
    an iterable of class objects, to be exported. If the variable is set to
    None, we skip that module and do not import anything. If the variable is not
    present, we look for a class by the same na e and casing as the module's
    name. If neither are found, the module is skipped.

    :return: Map of discovered class objects of type ``DescriptorElement`` whose
        keys are the string names of the classes.
    :rtype: dict[str, type]

    """
    import os
    from smqtk.utils.plugin import get_plugins

    this_dir = os.path.abspath(os.path.dirname(__file__))
    helper_var = "DESCRIPTOR_ELEMENT_CLASS"
    return get_plugins(__name__, this_dir, helper_var, DescriptorElement)
开发者ID:kod3r,项目名称:SMQTK,代码行数:27,代码来源:__init__.py

示例3: get_descriptor_generator_impls

def get_descriptor_generator_impls(reload_modules=False):
    """
    Discover and return ``DescriptorGenerator`` classes found in the given
    plugin search directory. Keys in the returned map are the names of the
    discovered classes, and the paired values are the actual class type objects.

    We look for modules (directories or files) that start with an alphanumeric
    character ('_' prefixed files/directories are hidden, but not recommended).

    Within a module we first look for a helper variable by the name
    ``DESCRIPTOR_GENERATOR_CLASS``, which can either be a single class object or
    an iterable of class objects, to be exported. If the variable is set to
    None, we skip that module and do not import anything. If the variable is not
    present, we look for a class by the same name and casing as the module. If
    neither are found, the module is skipped.

    :param reload_modules: Explicitly reload discovered modules from source.
    :type reload_modules: bool

    :return: Map of discovered class object of type ``DescriptorGenerator``
        whose keys are the string names of the classes.
    :rtype: dict[str, type]

    """
    from smqtk.utils.plugin import get_plugins
    this_dir = os.path.abspath(os.path.dirname(__file__))
    env_var = "DESCRIPTOR_GENERATOR_PATH"
    helper_var = "DESCRIPTOR_GENERATOR_CLASS"
    return get_plugins(__name__, this_dir, env_var, helper_var,
                       DescriptorGenerator, reload_modules=reload_modules)
开发者ID:kfieldho,项目名称:SMQTK,代码行数:30,代码来源:__init__.py

示例4: get_catalysts

def get_catalysts():
    """
    Discover and return Catalyst classes found in the given plugin search
    directory. Keys in the returned map are the names of the discovered classes,
    and the paired values are the actual class type objects.

    We look for modules (directories or files) that start with an alphanumeric
    character ('_' prefixed files/directories are hidden, but not recommended).

    Within a module we first look for a helper variable by the name
    ``CATALYST_CLASS``, which can either be a single class object or an iterable
    of class objects, to be exported. If the variable is set to None, we skip
    that module and do not import anything. If the variable is not present, we
    look for a class by the same name and casing as the module. If neither are
    found, the module is skipped.

    :return: Map of discovered class object of type ``Catalyst`` whose keys are
        the string names of the classes.
    :rtype: dict of (str, type)

    """
    from smqtk.utils.plugin import get_plugins
    this_dir = os.path.abspath(os.path.dirname(__file__))
    helper_var = "CATALYST_CLASS"
    return get_plugins(__name__, this_dir, helper_var, Catalyst)
开发者ID:jonathan-owens,项目名称:SMQTK,代码行数:25,代码来源:__init__.py

示例5: get_code_index_impls

def get_code_index_impls(reload_modules=False):
    """
    Discover and return small-code index implementation classes found in the
    plugin directory.
    Keys in the returned map are the names of the discovered implementations and
    the paired values are the actual class type objects.

    We look for modules (directories or files) that start with and alphanumeric
    character ('_' prefixed files/directories are hidden, but not recommended).

    Within a module, we first look for a helper variable by the name
    ``CODE_INDEX_CLASS``, which can either be a single class object or
    an iterable of class objects, to be exported. If the variable is set to
    None, we skip that module and do not import anything. If the variable is not
    present, we look for a class by the same na e and casing as the module's
    name. If neither are found, the module is skipped.

    :param reload_modules: Explicitly reload discovered modules from source.
    :type reload_modules: bool

    :return: Map of discovered class objects of type ``CodeIndex`` whose
        keys are the string names of the classes.
    :rtype: dict[str, type]

    """
    import os.path as osp
    from smqtk.utils.plugin import get_plugins

    this_dir = osp.abspath(osp.dirname(__file__))
    helper_var = 'CODE_INDEX_CLASS'
    fltr = lambda cls: cls.is_usable()
    return get_plugins(__name__, this_dir, helper_var, CodeIndex, fltr,
                       reload_modules)
开发者ID:mrG7,项目名称:SMQTK,代码行数:33,代码来源:__init__.py

示例6: get_web_applications

def get_web_applications(reload_modules=False):
    """
    Discover and return SmqtkWebApp implementation classes found in the plugin
    directory. Keys in the returned map are the names of the discovered classes
    and the paired values are the actual class type objects.

    We look for modules (directories or files) that start with and alphanumeric
    character ('_' prefixed files/directories are hidden, but not recommended).

    Within a module, we first look for a helper variable by the name
    ``APPLICATION_CLASS``, which can either be a single class object or
    an iterable of class objects, to be exported. If the variable is set to
    None, we skip that module and do not import anything. If the variable is not
    present, we look for a class by the same na e and casing as the module's
    name. If neither are found, the module is skipped.

    :param reload_modules: Explicitly reload discovered modules from source.
    :type reload_modules: bool

    :return: Map of discovered class objects of type ``SmqtkWebApp`` whose
        keys are the string names of the classes.
    :rtype: dict[str, type]

    """
    import os
    from smqtk.utils.plugin import get_plugins

    this_dir = os.path.abspath(os.path.dirname(__file__))
    env_var = "APPLICATION_PATH"
    helper_var = "APPLICATION_CLASS"
    return get_plugins(__name__, this_dir, env_var, helper_var, SmqtkWebApp,
                       reload_modules=reload_modules)
开发者ID:msarahan,项目名称:SMQTK,代码行数:32,代码来源:__init__.py

示例7: get_classifier_impls

def get_classifier_impls(reload_modules=False, sub_interface=None):
    """
    Discover and return discovered ``Classifier`` classes. Keys in the returned
    map are the names of the discovered classes, and the paired values are the
    actual class type objects.

    We search for implementation classes in:
        - modules next to this file this function is defined in (ones that
          begin with an alphanumeric character),
        - python modules listed in the environment variable
          :envvar:`CLASSIFIER_PATH`
            - This variable should contain a sequence of python module
              specifications, separated by the platform specific PATH separator
              character (``;`` for Windows, ``:`` for unix)

    Within a module we first look for a helper variable by the name
    ``CLASSIFIER_CLASS``, which can either be a single class object or an
    iterable of class objects, to be specifically exported. If the variable is
    set to None, we skip that module and do not import anything. If the
    variable is not present, we look at attributes defined in that module for
    classes that descend from the given base class type. If none of the above
    are found, or if an exception occurs, the module is skipped.

    :param reload_modules: Explicitly reload discovered modules from source.
    :type reload_modules: bool

    :param sub_interface: Only return implementations that also descend from
        the given sub-interface. The given interface must also descend from
        :class:`Classifier`.

    :return: Map of discovered class object of type :class:`Classifier`
        whose keys are the string names of the classes.
    :rtype: dict[str, type]

    """
    this_dir = os.path.abspath(os.path.dirname(__file__))
    env_var = "CLASSIFIER_PATH"
    helper_var = "CLASSIFIER_CLASS"
    if sub_interface is None:
        base_class = Classifier
    else:
        assert issubclass(sub_interface, Classifier), \
            "The given sub-interface type must descend from `Classifier`."
        base_class = sub_interface
    # __package__ resolves to the containing module of this module, or
    # `smqtk.algorithms.classifier` in this case.
    return plugin.get_plugins(__package__, this_dir, env_var, helper_var,
                              base_class, reload_modules=reload_modules)
开发者ID:Kitware,项目名称:SMQTK,代码行数:48,代码来源:_get_impls.py

示例8: get_nn_index_impls

def get_nn_index_impls(reload_modules=False):
    """
    Discover and return ``NearestNeighborsIndex`` implementation classes found
    in the given plugin search directory. Keys in the returned map are the names
    of the discovered classes, and the paired values are the actual class type
    objects.

    We look for modules (directories or files) that start with an alphanumeric
    character ('_' prefixed files/directories are hidden, but not recommended).

    Within a module we first look for a helper variable by the name
    ``NN_INDEX_CLASS``, which can either be a single class object or
    an iterable of class objects, to be exported. If the variable is set to
    None, we skip that module and do not import anything. If the variable is not
    present, we look for a class by the same name and casing as the module. If
    neither are found, the module is skipped.

    :param reload_modules: Explicitly reload discovered modules from source.
    :type reload_modules: bool

    :return: Map of discovered class object of type ``NearestNeighborsIndex``
        whose keys are the string names of the classes.
    :rtype: dict of (str, type)

    """
    from smqtk.utils.plugin import get_plugins
    import os
    this_dir = os.path.abspath(os.path.dirname(__file__))
    helper_var = "NN_INDEX_CLASS"

    def class_filter(cls):
        log = logging.getLogger('.'.join([__name__,
                                          'get_nn_index_impls',
                                          'class_filter']))
        if not cls.is_usable():
            log.warn("Class type '%s' not usable, filtering out.",
                     cls.__name__)
            return False
        return True

    return get_plugins(__name__, this_dir, helper_var, NearestNeighborsIndex,
                       class_filter, reload_modules)
开发者ID:mrG7,项目名称:SMQTK,代码行数:42,代码来源:__init__.py

示例9: get_dummy_plugins

 def get_dummy_plugins(cls):
     return get_plugins(cls.INTERNAL_PLUGIN_MOD_PATH,
                        cls.INTERNAL_PLUGIN_DIR, cls.ENV_VAR,
                        cls.HELP_VAR, DummyInterface)
开发者ID:Kitware,项目名称:SMQTK,代码行数:4,代码来源:test_plugin_get.py


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