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


Python compare.version_dict函数代码示例

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


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

示例1: version_sidebar

def version_sidebar(request, form_data, facets):
    appver = ""
    # If appver is in the request, we read it cleaned via form_data.
    if "appver" in request.GET or form_data.get("appver"):
        appver = form_data.get("appver")

    app = unicode(request.APP.pretty)
    exclude_versions = getattr(request.APP, "exclude_versions", [])
    # L10n: {0} is an application, such as Firefox. This means "any version of
    # Firefox."
    rv = [FacetLink(_(u"Any {0}").format(app), dict(appver="any"), not appver)]
    vs = [dict_from_int(f["term"]) for f in facets["appversions"]]

    # Insert the filtered app version even if it's not a facet.
    av_dict = version_dict(appver)

    if av_dict and av_dict not in vs and av_dict["major"]:
        vs.append(av_dict)

    # Valid versions must be in the form of `major.minor`.
    vs = set((v["major"], v["minor1"] if v["minor1"] not in (None, 99) else 0) for v in vs)
    versions = ["%s.%s" % v for v in sorted(vs, reverse=True)]

    for version, floated in zip(versions, map(float, versions)):
        if floated not in exclude_versions and floated > request.APP.min_display_version:
            rv.append(FacetLink("%s %s" % (app, version), dict(appver=version), appver == version))
    return rv
开发者ID:vinu76jsr,项目名称:zamboni,代码行数:27,代码来源:views.py

示例2: version_sidebar

def version_sidebar(request, form_data, facets):
    appver = ''
    # If appver is in the request, we read it cleaned via form_data.
    if 'appver' in request.GET or form_data.get('appver'):
        appver = form_data.get('appver')

    app = unicode(request.APP.pretty)
    exclude_versions = getattr(request.APP, 'exclude_versions', [])
    # L10n: {0} is an application, such as Firefox. This means "any version of
    # Firefox."
    rv = [FacetLink(_(u'Any {0}').format(app), dict(appver='any'), not appver)]
    vs = [dict_from_int(f['term']) for f in facets['appversions']]

    # Insert the filtered app version even if it's not a facet.
    av_dict = version_dict(appver)

    if av_dict and av_dict not in vs and av_dict['major']:
        vs.append(av_dict)

    # Valid versions must be in the form of `major.minor`.
    vs = set((v['major'], v['minor1'] if v['minor1'] not in (None, 99) else 0)
             for v in vs)
    versions = ['%s.%s' % v for v in sorted(vs, reverse=True)]

    for version, floated in zip(versions, map(float, versions)):
        if (floated not in exclude_versions
                and floated > request.APP.min_display_version):
            rv.append(FacetLink('%s %s' % (app, version), dict(appver=version),
                                appver == version))
    return rv
开发者ID:jvillalobos,项目名称:olympia,代码行数:30,代码来源:views.py

示例3: test_version_dict

def test_version_dict():
    eq_(version_dict('5.0'),
        {'major': 5,
         'minor1': 0,
         'minor2': None,
         'minor3': None,
         'alpha': None,
         'alpha_ver': None,
         'pre': None,
         'pre_ver': None})
开发者ID:Sancus,项目名称:zamboni,代码行数:10,代码来源:tests.py

示例4: test_version_dict

def test_version_dict():
    eq_(
        version_dict("5.0"),
        {
            "major": 5,
            "minor1": 0,
            "minor2": None,
            "minor3": None,
            "alpha": None,
            "alpha_ver": None,
            "pre": None,
            "pre_ver": None,
        },
    )
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:14,代码来源:tests.py

示例5: version_sidebar

def version_sidebar(request, query, facets):
    appver = query.get('appver')
    app = unicode(request.APP.pretty)
    exclude_versions = getattr(request.APP, 'exclude_versions', [])
    # L10n: {0} is an application, such as Firefox. This means "any version of
    # Firefox."
    rv = [FacetLink(_(u'Any {0}').format(app), dict(appver=''), not appver)]
    vs = [dict_from_int(f['term']) for f in facets['appversions']]

    # Insert the filtered app version even if it's not a facet.
    av_dict = version_dict(appver)
    if av_dict and av_dict not in vs and av_dict['major']:
        vs.append(av_dict)

    vs = set((v['major'], v['minor1'] if v['minor1'] != 99 else 0) for v in vs)
    versions = ['%s.%s' % v for v in sorted(vs, reverse=True)]

    for version, floated in zip(versions, map(float, versions)):
        if (floated not in exclude_versions
            and floated > request.APP.min_display_version):
            rv.append(FacetLink('%s %s' % (app, version), dict(appver=version),
                                appver == version))
    return rv
开发者ID:LucianU,项目名称:zamboni,代码行数:23,代码来源:views.py

示例6: __init__

 def __init__(self, *args, **kwargs):
     super(AppVersion, self).__init__(*args, **kwargs)
     # Add all the major, minor, ..., version attributes to the object.
     self.__dict__.update(compare.version_dict(self.version or ''))
开发者ID:bebef1987,项目名称:zamboni,代码行数:4,代码来源:models.py


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