本文整理汇总了Python中config.Configuration.small_collection_languages方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.small_collection_languages方法的具体用法?Python Configuration.small_collection_languages怎么用?Python Configuration.small_collection_languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.small_collection_languages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_default_lanes
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import small_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)
示例2: make_lanes_default
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import small_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)