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


Python missing.get_subclasses函数代码示例

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


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

示例1: avail_job_backends

def avail_job_backends(check_usable=True):
    """
    Return all known job execution backends.
    """
    import_available_modules('easybuild.tools.job')
    class_dict = dict([(x.__name__, x) for x in get_subclasses(JobBackend)])
    return class_dict
开发者ID:cyiops,项目名称:easybuild-framework,代码行数:7,代码来源:backend.py

示例2: avail_package_naming_schemes

def avail_package_naming_schemes():
    """
    Returns the list of valed naming schemes that are in the easybuild.package.package_naming_scheme namespace
    """
    import_available_modules('easybuild.tools.package.package_naming_scheme')
    class_dict = dict([(x.__name__, x) for x in get_subclasses(PackageNamingScheme)])
    return class_dict
开发者ID:jgphpc,项目名称:easybuild-framework,代码行数:7,代码来源:utilities.py

示例3: what_sched

def what_sched(requested):
    """Return the scheduler class """

    def sched_to_key(klass):
        """Return key for specified scheduler class which can be used for sorting."""
        # use lowercase class name for sorting
        key = klass.__name__.lower()
        # prefix key for SLURM scheduler class with '_'
        # this is done to consider SLURM before PBS, since $PBS* environment variables may be defined in SLURM job env
        if key == 'slurm':
            key = '_' + key

        return key

    # exclude Coupler class which also is a subclass of Sched, since it's not an actual scheduler
    found_sched = sorted([c for c in get_subclasses(Sched) if c.__name__ != 'Coupler'], key=sched_to_key)

    # Get local scheduler
    local_sched = get_local_sched(found_sched)

    # first, try to use the scheduler that was requested
    if requested:
        for sched in found_sched:
            if sched._is_sched_for(requested):
                return sched, found_sched
        LOGGER.warn("%s scheduler was requested, but mympirun failed to find an implementation", requested)

    # next, try to use the scheduler defined by environment variables
    for sched in found_sched:
        if sched.SCHED_ENVIRON_NODE_INFO in os.environ and sched.SCHED_ENVIRON_ID in os.environ:
            return sched, found_sched

    # If that fails, try to force the local scheduler
    LOGGER.debug("No scheduler found in environment, trying local")
    return local_sched, found_sched
开发者ID:hpcugent,项目名称:vsc-mympirun,代码行数:35,代码来源:sched.py

示例4: get_convert_class

def get_convert_class(class_name):
    """Return the Convert class with specified class name class_name"""
    res = [x for x in nub(get_subclasses(Convert)) if x.__name__ == class_name]
    if len(res) == 1:
        return res[0]
    else:
        raise EasyBuildError("More than one Convert subclass found for name %s: %s", class_name, res)
开发者ID:LiangFr,项目名称:easybuild-framework,代码行数:7,代码来源:convert.py

示例5: pingpongfactory

    def pingpongfactory(pptype, comm, p, log):
        """a factory for creating PingPong objects"""

        for cls in get_subclasses(PingPongSR, include_base_class=True):
            if "PingPong%s" % pptype == cls.__name__:
                return cls(comm, p, log)
        raise KeyError
开发者ID:stdweird,项目名称:mympingpong,代码行数:7,代码来源:pingpongers.py

示例6: get_format_version_classes

def get_format_version_classes(version=None):
    """Return the (usable) subclasses from EasyConfigFormat that have a matching version."""
    all_classes = get_subclasses(EasyConfigFormat)
    if version is None:
        return all_classes
    else:
        return [x for x in all_classes if x.VERSION == version and x.USABLE]
开发者ID:akesandgren,项目名称:easybuild-framework,代码行数:7,代码来源:format.py

示例7: what_sched

def what_sched(requested):
    """Return the scheduler class """

    # import all modules in this dir: http://stackoverflow.com/a/16853487
    for loader, modulename, _ in pkgutil.walk_packages([os.path.dirname(__file__)]):
        loader.find_module(modulename).load_module(modulename)

    found_sched = get_subclasses(Sched)

    # first, try to use the scheduler that was requested
    if requested:
        for sched in found_sched:
            if sched._is_sched_for(requested):
                return sched, found_sched
        LOGGER.warn("%s scheduler was requested, but mympirun failed to find an implementation", requested)

    # next, try to use the scheduler defined by environment variables
    for sched in found_sched:
        if sched.SCHED_ENVIRON_ID in os.environ:
            return sched, found_sched

    # If that fails, try to force the local scheduler
    for sched in found_sched:
        LOGGER.debug("No scheduler found in environment, trying local")
        if sched._is_sched_for("local"):
            return sched, found_sched


    # if there is no local scheduler, return None
    return None, found_sched
开发者ID:Iepoev,项目名称:vsc-mympirun,代码行数:30,代码来源:sched.py

示例8: whatMPI

def whatMPI(name):
    """
    Return the scriptname and the MPI class
    """
    fullscriptname = os.path.abspath(name)
    scriptname = os.path.basename(fullscriptname)

    found_mpi = get_subclasses(MPI)

    # check on scriptname
    for mpi in found_mpi:
        if mpi._is_mpiscriptname_for(scriptname):
            stripfake()  # mandatory before return at this point
            return scriptname, mpi, found_mpi

    # not called through alias
    # stripfake is in which
    mpirunname = which(['mpirun'])
    if mpirunname is None:
        return None, None, found_mpi

    for mpi in found_mpi:
        if mpi._is_mpirun_for(mpirunname):
            return scriptname, mpi, found_mpi

    # return found mpirunname
    return mpirunname, None, found_mpi
开发者ID:wpoely86,项目名称:vsc-mympirun,代码行数:27,代码来源:mpi.py

示例9: get_convert_class

def get_convert_class(class_name):
    """Return the Convert class with specified class name class_name"""
    res = [x for x in nub(get_subclasses(Convert)) if x.__name__ == class_name]
    if len(res) == 1:
        return res[0]
    else:
        _log.error('More then one Convert subclass found for name %s: %s' % (class_name, res))
开发者ID:JackPerdue,项目名称:easybuild-framework,代码行数:7,代码来源:convert.py

示例10: search_toolchain

def search_toolchain(name):
    """
    Obtain a Toolchain instance for the toolchain with specified name, next to a list of available toolchains.
    :param name: toolchain name
    :return: Toolchain instance (or None), found_toolchains
    """

    package = easybuild.tools.toolchain
    check_attr_name = '%s_PROCESSED' % TC_CONST_PREFIX

    if not hasattr(package, check_attr_name) or not getattr(package, check_attr_name):
        # import all available toolchains, so we know about them
        tc_modules = import_available_modules('easybuild.toolchains')

        # make sure all defined toolchain constants are available in toolchain module
        tc_const_re = re.compile('^%s(.*)$' % TC_CONST_PREFIX)
        for tc_mod in tc_modules:
            # determine classes imported in this module
            mod_classes = []
            for elem in [getattr(tc_mod, x) for x in dir(tc_mod)]:
                if hasattr(elem, '__module__'):
                    # exclude the toolchain class defined in that module
                    if not tc_mod.__file__ == sys.modules[elem.__module__].__file__:
                        _log.debug("Adding %s to list of imported classes used for looking for constants" % elem.__name__)
                        mod_classes.append(elem)

            # look for constants in modules of imported classes, and make them available
            for mod_class_mod in [sys.modules[mod_class.__module__] for mod_class in mod_classes]:
                for elem in dir(mod_class_mod):
                    res = tc_const_re.match(elem)
                    if res:
                        tc_const_name = res.group(1)
                        tc_const_value = getattr(mod_class_mod, elem)
                        _log.debug("Found constant %s ('%s') in module %s, adding it to %s",
                                   tc_const_name, tc_const_value, mod_class_mod.__name__, package.__name__)
                        if hasattr(package, tc_const_name):
                            cur_value = getattr(package, tc_const_name)
                            if not tc_const_value == cur_value:
                                raise EasyBuildError("Constant %s.%s defined as '%s', can't set it to '%s'.",
                                                     package.__name__, tc_const_name, cur_value, tc_const_value)
                        else:
                            setattr(package, tc_const_name, tc_const_value)

        # indicate that processing of toolchain constants is done, so it's not done again
        setattr(package, check_attr_name, True)
    else:
        _log.debug("Skipping importing of toolchain modules, processing of toolchain constants is already done.")

    # obtain all subclasses of toolchain
    found_tcs = nub(get_subclasses(Toolchain))

    # filter found toolchain subclasses based on whether they can be used a toolchains
    found_tcs = [tc for tc in found_tcs if tc._is_toolchain_for(None)]

    for tc in found_tcs:
        if tc._is_toolchain_for(name):
            return tc, found_tcs

    return None, found_tcs
开发者ID:hpcugent,项目名称:easybuild-framework,代码行数:59,代码来源:utilities.py

示例11: what_licenses

def what_licenses():
    """Return a dict of License subclasses names and license instances"""
    res = {}
    for lic in get_subclasses(License):
        if lic.HIDDEN:
            continue
        res[lic.__name__] = lic

    return res
开发者ID:ULHPC,项目名称:easybuild-framework,代码行数:9,代码来源:licenses.py

示例12: avail_modules_tools

def avail_modules_tools():
    """
    Return all known modules tools.
    """
    class_dict = dict([(x.__name__, x) for x in get_subclasses(ModulesTool)])
    # filter out legacy Modules class
    if 'Modules' in class_dict:
        del class_dict['Modules']
    return class_dict
开发者ID:JensTimmerman,项目名称:easybuild-framework,代码行数:9,代码来源:modules.py

示例13: get_job

    def get_job(classname, options):
        """
        This is a job factory.

        Returns an instance of classname initialized with options
        """
        for cls in get_subclasses(Job):
            if cls._is_job_for(classname):
                return cls(options)
        getLogger().error("No job class found for %s", classname)
开发者ID:ehiggs,项目名称:hanythingondemand,代码行数:10,代码来源:job.py

示例14: avail_repositories

def avail_repositories(check_useable=True):
    """
    Return all available repositories.
        check_useable: boolean, if True, only return usable repositories
    """
    class_dict = dict([(x.__name__, x) for x in get_subclasses(Repository) if x.USABLE or not check_useable])

    if not 'FileRepository' in class_dict:
        _log.error('avail_repositories: FileRepository missing from list of repositories')

    return class_dict
开发者ID:damienfrancois,项目名称:easybuild-framework,代码行数:11,代码来源:repository.py

示例15: avail_repositories

def avail_repositories(check_useable=True):
    """
    Return all available repositories.
        check_useable: boolean, if True, only return usable repositories
    """
    import_available_modules('easybuild.tools.repository')

    class_dict = dict([(x.__name__, x) for x in get_subclasses(Repository) if x.USABLE or not check_useable])

    if not 'FileRepository' in class_dict:
        raise EasyBuildError("avail_repositories: FileRepository missing from list of repositories")

    return class_dict
开发者ID:ULHPC,项目名称:easybuild-framework,代码行数:13,代码来源:repository.py


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