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


Python Spec.versions方法代码示例

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


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

示例1: get_matching_versions

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import versions [as 别名]
def get_matching_versions(specs, **kwargs):
    """Get a spec for EACH known version matching any spec in the list."""
    matching = []
    for spec in specs:
        pkg = spec.package

        # Skip any package that has no known versions.
        if not pkg.versions:
            tty.msg("No safe (checksummed) versions for package %s" % pkg.name)
            continue

        num_versions = kwargs.get('num_versions', 0)
        matching_spec = []
        for i, v in enumerate(reversed(sorted(pkg.versions))):
            # Generate no more than num_versions versions for each spec.
            if num_versions and i >= num_versions:
                break

            # Generate only versions that satisfy the spec.
            if v.satisfies(spec.versions):
                s = Spec(pkg.name)
                s.versions = VersionList([v])
                s.variants = spec.variants.copy()
                # This is needed to avoid hanging references during the
                # concretization phase
                s.variants.spec = s
                matching_spec.append(s)

        if not matching_spec:
            tty.warn("No known version matches spec: %s" % spec)
        matching.extend(matching_spec)

    return matching
开发者ID:alfredo-gimenez,项目名称:spack,代码行数:35,代码来源:mirror.py

示例2: get_matching_versions

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import versions [as 别名]
def get_matching_versions(specs, **kwargs):
    """Get a spec for EACH known version matching any spec in the list."""
    matching = []
    for spec in specs:
        pkg = spec.package

        # Skip any package that has no known versions.
        if not pkg.versions:
            tty.msg("No safe (checksummed) versions for package %s." % pkg.name)
            continue

        num_versions = kwargs.get('num_versions', 0)
        for i, v in enumerate(reversed(sorted(pkg.versions))):
            # Generate no more than num_versions versions for each spec.
            if num_versions and i >= num_versions:
                break

            # Generate only versions that satisfy the spec.
            if v.satisfies(spec.versions):
                s = Spec(pkg.name)
                s.versions = VersionList([v])
                matching.append(s)

    return matching
开发者ID:AaronTHolt,项目名称:spack,代码行数:26,代码来源:mirror.py


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