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


Python StoreDatabase.get_docs_from_query方法代码示例

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


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

示例1: _get_apps_for_category

# 需要导入模块: from softwarecenter.db.database import StoreDatabase [as 别名]
# 或者: from softwarecenter.db.database.StoreDatabase import get_docs_from_query [as 别名]
 def _get_apps_for_category(self, category):
     query = get_query_for_category(self.db, category)
     if not query:
         LOG.warn("_get_apps_for_category: received invalid category")
         return []
     
     pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")
     db = StoreDatabase(pathname, self.cache)
     db.open()
     docs = db.get_docs_from_query(query)
     
     #from the db docs, return a list of pkgnames
     applist = []
     for doc in docs:
         applist.append(db.get_pkgname(doc))
     return applist
开发者ID:cs2c,项目名称:AppStream,代码行数:18,代码来源:__init__.py

示例2: PkgListModel

# 需要导入模块: from softwarecenter.db.database import StoreDatabase [as 别名]
# 或者: from softwarecenter.db.database.StoreDatabase import get_docs_from_query [as 别名]

#.........这里部分代码省略.........
        if role == "_pkgname":
            return pkgname 
        elif role == "_appname":
            return appname
        elif role == "_summary":
            return unicode(self.db.get_summary(doc))
        elif role == "_installed":
            if not pkgname in self.cache:
                return False
            return self.cache[pkgname].is_installed
        elif role == "_description":
            if not pkgname in self.cache:
                return ""
            return self.cache[pkgname].description
        elif role == "_icon":
            iconname = self.db.get_iconname(doc)
            return self._findIcon(iconname)
        elif role == "_ratings_average":
            stats = self.reviews.get_review_stats(Application(appname, pkgname))
            if stats:
                return stats.ratings_average
            return 0
        elif role == "_ratings_total":
            stats = self.reviews.get_review_stats(Application(appname, pkgname))
            if stats:
                return stats.ratings_total
            return 0
        elif role == "_installremoveprogress":
            if pkgname in self.backend.pending_transactions:
                return self.backend.pending_transactions[pkgname].progress
            return -1
        return None

    # helper
    def _on_backend_transaction_progress_changed(self, backend, pkgname, progress):
        column = self.COLUMNS.index("_installremoveprogress")
        # FIXME: instead of the entire model, just find the row that changed
        top = self.createIndex(0, column)
        bottom = self.createIndex(self.rowCount()-1, column)
        self.dataChanged.emit(top, bottom)

    def _findIcon(self, iconname):
        path = "/usr/share/icons/Humanity/categories/32/applications-other.svg"
        for ext in ["svg", "png", ".xpm"]:
            p = "/usr/share/app-install/icons/%s" % iconname
            if os.path.exists(p+ext):
                path = "file://%s" % p+ext
                break
        return path
        
    def clear(self):
        self.beginRemoveRows(QModelIndex(), 0, self.rowCount()-1)
        self._docs = []
        self.endRemoveRows()

    def _runQuery(self, querystr):
        self.clear()
        docs = self.db.get_docs_from_query(
            str(querystr), start=0, end=500, category=self._category)
        self.beginInsertRows(QModelIndex(), len(docs), len(docs))
        self._docs = docs
        self.endInsertRows()

    # install/remove interface (for qml)
    @Slot(str)
    def installPackage(self, pkgname):
        appname = ""
        iconname = ""
        self.backend.install(pkgname, appname, iconname)
    @Slot(str)
    def removePackage(self, pkgname):
        appname = ""
        iconname = ""
        self.backend.remove(pkgname, appname, iconname)

    # searchQuery property (for qml )
    def getSearchQuery(self):
        return self._query
    def setSearchQuery(self, query):
        self._query = query
        self._runQuery(query)
    searchQueryChanged = QtCore.Signal()
    searchQuery = Property(unicode, getSearchQuery, setSearchQuery, notify=searchQueryChanged)

    # allow to refine searches for specific categories
    @Slot(str)
    def setCategory(self, catname):
        # empty category resets it
        if not catname:
            self._category = None
        else:
            # search for the category
            for cat in self._categories:
                if cat.name == catname:
                    self._category = cat
                    break
            else:
                raise Exception("Can not find category '%s'" % catname)
        # and trigger a query
        self._runQuery(self._query)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:104,代码来源:pkglist.py


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