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


Python Configuration.large_collection_languages方法代码示例

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


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

示例1: create_default_lanes

# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import large_collection_languages [as 别名]
def create_default_lanes(_db, library):
    """Reset the lanes for the given library to the default.

    The database will have the following top-level lanes for
    each large-collection:
    'Adult Fiction', 'Adult Nonfiction', 'Young Adult Fiction',
    'Young Adult Nonfiction', and 'Children'.
    Each lane contains additional sublanes.
    If an NYT integration is configured, there will also be a
    'Best Sellers' top-level lane.

    If there are any small- or tiny-collection languages, the database
    will also have a top-level lane called 'World Languages'. The
    'World Languages' lane will have a sublane for every small- and
    tiny-collection languages. The small-collection languages will
    have "Adult Fiction", "Adult Nonfiction", and "Children/YA"
    sublanes; the tiny-collection languages will not have any sublanes.

    If run on a Library that already has Lane configuration, this can
    be an extremely destructive method. All new Lanes will be visible
    and all Lanes based on CustomLists (but not the CustomLists
    themselves) will be destroyed.

    """
    # Delete existing lanes.
    for lane in _db.query(Lane).filter(Lane.library_id==library.id):
        _db.delete(lane)

    top_level_lanes = []

    # Hopefully this library is configured with explicit guidance as
    # to how the languages should be set up.
    large = Configuration.large_collection_languages(library) or []
    small = Configuration.small_collection_languages(library) or []
    tiny = Configuration.tiny_collection_languages(library) or []

    # If there are no language configuration settings, we can estimate
    # the current collection size to determine the lanes.
    if not large and not small and not tiny:
        estimates = library.estimated_holdings_by_language()
        large, small, tiny = _lane_configuration_from_collection_sizes(estimates)
    priority = 0
    for language in large:
        priority = create_lanes_for_large_collection(_db, library, language, priority=priority)

    create_world_languages_lane(_db, library, small, tiny, priority)
开发者ID:NYPL-Simplified,项目名称:circulation,代码行数:48,代码来源:lanes.py

示例2: make_lanes_default

# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import large_collection_languages [as 别名]
def make_lanes_default(_db):
    """Create the default layout of lanes for the server configuration."""

    # The top-level LaneList includes a hidden lane for each
    # large-collection language with a number of displayed 
    # sublanes: 'Adult Fiction', 'Adult Nonfiction',
    # 'Young Adult Fiction', 'Young Adult Nonfiction', and 'Children'
    # sublanes. These sublanes contain additional sublanes.
    #
    # The top-level LaneList also includes a sublane named after each
    # small-collection language. Each such sublane contains "Adult
    # Fiction", "Adult Nonfiction", and "Children/YA" sublanes.
    #
    # Finally the top-level LaneList includes an "Other Languages" sublane
    # which covers all other languages. This lane contains "Adult Fiction",
    # "Adult Nonfiction", and "Children/YA" sublanes.
    seen_languages = set()

    top_level_lanes = []

    def language_list(x):
        if isinstance(language_set, basestring):
            return x.split(',')
        return x

    for language_set in Configuration.large_collection_languages():
        languages = language_list(language_set)
        seen_languages = seen_languages.union(set(languages))
        top_level_lanes.extend(lanes_for_large_collection(_db, language_set))

    for language_set in Configuration.small_collection_languages():
        languages = language_list(language_set)
        seen_languages = seen_languages.union(set(languages))
        top_level_lanes.append(lane_for_small_collection(_db, language_set))

    top_level_lanes.append(lane_for_other_languages(_db, seen_languages))

    return LaneList.from_description(_db, None, top_level_lanes)
开发者ID:datalogics-tsmith,项目名称:circulation,代码行数:40,代码来源:lanes.py


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