本文整理汇总了Python中softwarecenter.db.enquire.AppEnquire.get_documents方法的典型用法代码示例。如果您正苦于以下问题:Python AppEnquire.get_documents方法的具体用法?Python AppEnquire.get_documents怎么用?Python AppEnquire.get_documents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类softwarecenter.db.enquire.AppEnquire
的用法示例。
在下文中一共展示了AppEnquire.get_documents方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_documents
# 需要导入模块: from softwarecenter.db.enquire import AppEnquire [as 别名]
# 或者: from softwarecenter.db.enquire.AppEnquire import get_documents [as 别名]
def get_documents(self, db):
""" return the database docids for the given category """
enq = AppEnquire(db._aptcache, db)
app_filter = AppFilter(db, db._aptcache)
if "available-only" in self.flags:
app_filter.set_available_only(True)
if "not-installed-only" in self.flags:
app_filter.set_not_installed_only(True)
enq.set_query(self.query,
limit=self.item_limit,
filter=app_filter,
sortmode=self.sortmode,
nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
nonblocking_load=False)
return enq.get_documents()
示例2: _ceibal_get_docs
# 需要导入模块: from softwarecenter.db.enquire import AppEnquire [as 别名]
# 或者: from softwarecenter.db.enquire.AppEnquire import get_documents [as 别名]
def _ceibal_get_docs(self):
""" return the database docids for the given category """
enq = AppEnquire(self.db._aptcache, self.db)
app_filter = AppFilter(self.db, self.db._aptcache)
app_filter.set_available_only(True)
#app_filter.set_not_installed_only(True)
p = "http://apt.ceibal.edu.uy/recommendations/list.json"
data = json.load(urllib2.urlopen(p))
query = get_query_for_pkgnames(data['packages'])
enq.set_query(query,
limit=20,
filter=app_filter,
sortmode=0,
nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
nonblocking_load=False)
return enq.get_documents()
示例3: _get_toprated_category_content
# 需要导入模块: from softwarecenter.db.enquire import AppEnquire [as 别名]
# 或者: from softwarecenter.db.enquire.AppEnquire import get_documents [as 别名]
def _get_toprated_category_content(self):
toprated_cat = get_category_by_name(self.categories,
u"Top Rated") # unstranslated name
if toprated_cat is None:
LOG.warn("No 'toprated' category found!!")
return None, []
enq = AppEnquire(self.cache, self.db)
app_filter = AppFilter(self.db, self.cache)
enq.set_query(toprated_cat.query,
limit=TOP_RATED_CAROUSEL_LIMIT,
sortmode=toprated_cat.sortmode,
filter=app_filter,
nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
nonblocking_load=False)
if not hasattr(self, "helper"):
self.helper = AppPropertiesHelper(self.db,
self.cache,
self.icons)
return toprated_cat, enq.get_documents()
示例4: _get_new_category_content
# 需要导入模块: from softwarecenter.db.enquire import AppEnquire [as 别名]
# 或者: from softwarecenter.db.enquire.AppEnquire import get_documents [as 别名]
def _get_new_category_content(self):
whatsnew_cat = get_category_by_name(self.categories,
u"What\u2019s New") # unstranslated name
if whatsnew_cat is None:
LOG.warn("No 'new' category found!!")
return None, []
enq = AppEnquire(self.cache, self.db)
app_filter = AppFilter(self.db, self.cache)
app_filter.set_available_only(True)
app_filter.set_not_installed_only(True)
enq.set_query(whatsnew_cat.query,
limit=8,
filter=app_filter,
sortmode=SortMethods.BY_CATALOGED_TIME,
nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
nonblocking_load=False)
if not hasattr(self, "helper"):
self.helper = AppPropertiesHelper(self.db,
self.cache,
self.icons)
return whatsnew_cat, enq.get_documents()
示例5: SubCategoryViewGtk
# 需要导入模块: from softwarecenter.db.enquire import AppEnquire [as 别名]
# 或者: from softwarecenter.db.enquire.AppEnquire import get_documents [as 别名]
class SubCategoryViewGtk(CategoriesViewGtk):
def __init__(self, datadir, desktopdir, cache, db, icons,
apps_filter, apps_limit=0, root_category=None):
CategoriesViewGtk.__init__(self, datadir, desktopdir, cache, db, icons,
apps_filter, apps_limit)
# state
self._built = False
# data
self.root_category = root_category
self.enquire = AppEnquire(self.cache, self.db)
self.properties_helper = AppPropertiesHelper(
self.db, self.cache, self.icons)
# sections
self.current_category = None
self.departments = None
self.top_rated = None
self.recommended_for_you_in_cat = None
self.appcount = None
# widgetry
self.vbox.set_margin_left(StockEms.MEDIUM - 2)
self.vbox.set_margin_right(StockEms.MEDIUM - 2)
self.vbox.set_margin_top(StockEms.MEDIUM)
return
def _get_sub_top_rated_content(self, category):
app_filter = AppFilter(self.db, self.cache)
self.enquire.set_query(category.query,
limit=TOP_RATED_CAROUSEL_LIMIT,
sortmode=SortMethods.BY_TOP_RATED,
filter=app_filter,
nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
nonblocking_load=False)
return self.enquire.get_documents()
@wait_for_apt_cache_ready # be consistent with new apps
def _update_sub_top_rated_content(self, category):
self.top_rated.remove_all()
# FIXME: should this be m = "%s %s" % (_(gettext text), header text) ??
# TRANSLATORS: %s is a category name, like Internet or Development
# Tools
m = _('Top Rated %(category)s') % {
'category': GObject.markup_escape_text(self.header)}
self.top_rated_frame.set_header_label(m)
docs = self._get_sub_top_rated_content(category)
self._add_tiles_to_flowgrid(docs, self.top_rated,
TOP_RATED_CAROUSEL_LIMIT)
return
def _append_sub_top_rated(self):
self.top_rated = FlowableGrid()
self.top_rated.set_row_spacing(6)
self.top_rated.set_column_spacing(6)
self.top_rated_frame = FramedHeaderBox()
self.top_rated_frame.pack_start(self.top_rated, True, True, 0)
self.vbox.pack_start(self.top_rated_frame, False, True, 0)
return
def _update_recommended_for_you_in_cat_content(self, category):
if (self.recommended_for_you_in_cat and
self.recommended_for_you_in_cat.get_parent()):
self.vbox.remove(self.recommended_for_you_in_cat)
self.recommended_for_you_in_cat = RecommendationsPanelCategory(
self,
category)
# only show the panel in the categories view when the user
# is opted in to the recommender service
# FIXME: this is needed vs. a simple hide() on the widget because
# we do a show_all on the view
if self.recommended_for_you_in_cat.recommender_agent.is_opted_in():
self.vbox.pack_start(self.recommended_for_you_in_cat,
False, False, 0)
def _update_subcat_departments(self, category, num_items):
self.departments.remove_all()
# set the subcat header
m = "<b><big>%s</big></b>"
self.subcat_label.set_markup(m % GObject.markup_escape_text(
self.header))
# sort Category.name's alphabetically
sorted_cats = categories_sorted_by_name(self.categories)
enquire = xapian.Enquire(self.db.xapiandb)
app_filter = AppFilter(self.db, self.cache)
for cat in sorted_cats:
# add the subcategory if and only if it is non-empty
enquire.set_query(cat.query)
if len(enquire.get_mset(0, 1)):
tile = CategoryTile(cat.name, cat.iconname)
tile.connect('clicked', self.on_category_clicked, cat)
self.departments.add_child(tile)
# partialy work around a (quite rare) corner case
if num_items == 0:
enquire.set_query(xapian.Query(xapian.Query.OP_AND,
category.query,
#.........这里部分代码省略.........