示例#1
0
    def __init__(self, db, cache, icons, icon_size=48,
        global_icon_cache=False):
        GObject.GObject.__init__(self)
        self.db = db
        self.cache = cache

        # get all categories
        cat_parser = CategoriesParser(db)
        self.all_categories = cat_parser.parse_applications_menu(
            softwarecenter.paths.APP_INSTALL_PATH)

        # reviews stats loader
        self.review_loader = get_review_loader(cache, db)

        # icon jazz
        self.icons = icons
        self.icon_size = icon_size

        # cache the 'missing icon' used in the treeview for apps without an
        # icon
        self._missing_icon = icons.load_icon(Icons.MISSING_APP, icon_size, 0)
        if global_icon_cache:
            self.icon_cache = _app_icon_cache
        else:
            self.icon_cache = {}
def get_test_categories(db):
    import softwarecenter.paths
    from softwarecenter.db.categories import CategoriesParser
    parser = CategoriesParser(db)
    cats = parser.parse_applications_menu(
        softwarecenter.paths.APP_INSTALL_PATH)
    return cats
    def __init__(self,
                 db,
                 cache,
                 icons,
                 icon_size=48,
                 global_icon_cache=False):
        GObject.GObject.__init__(self)
        self.db = db
        self.cache = cache

        # get all categories
        cat_parser = CategoriesParser(db)
        self.all_categories = cat_parser.parse_applications_menu(
            softwarecenter.paths.APP_INSTALL_PATH)

        # reviews stats loader
        self.review_loader = get_review_loader(cache, db)

        # icon jazz
        self.icons = icons
        self.icon_size = icon_size

        self._missing_icon = None  # delay this until actually needed
        if global_icon_cache:
            self.icon_cache = _app_icon_cache
        else:
            self.icon_cache = {}
示例#4
0
    def __init__(self, cache, db, icons,
                 apps_filter, apps_limit=0):
        CategoriesView.__init__(self, cache, db, icons, apps_filter,
                                apps_limit=0)
        self.top_rated = None
        self.exhibit_banner = None

        # sections
        self.departments = None
        self.appcount = None

        # get categories
        self.categories_parser = CategoriesParser(db)
        self.categories = self.categories_parser.parse_applications_menu()

        # build before connecting the signals to avoid race
        self.build()

        # ensure that on db-reopen we refresh the whats-new titles
        self.db.connect("reopen", self._on_db_reopen)

        # ensure that updates to the stats are reflected in the UI
        self.reviews_loader = get_review_loader(self.cache)
        self.reviews_loader.connect(
            "refresh-review-stats-finished", self._on_refresh_review_stats)
示例#5
0
 def _get_query_for_category(self, category):
     cat_parser = CategoriesParser(self.db)
     categories = cat_parser.parse_applications_menu(APP_INSTALL_PATH)
     for c in categories:
         if category == c.untranslated_name:
             query = c.query
             return query
     return False
 def test_category_dynamic_categories(self, mock_get_region_cached):
     mock_get_region_cached.return_value = {
         "countrycode": "us",
     }
     parser = CategoriesParser(self.db)
     cats = parser.parse_applications_menu("./data/")
     cat = get_category_by_name(cats, 'Dynamic')
     self.assertEqual("%s" % cat.query,
                      "Xapian::Query((<alldocuments> AND XTregion::us))")
示例#7
0
 def setUp(self):
     cache = get_pkg_info()
     cache.open()
     xapian_base_path = XAPIAN_BASE_PATH
     pathname = os.path.join(xapian_base_path, "xapian")
     self.db = StoreDatabase(pathname, cache)
     self.db.open()
     self.catview = CategoriesParser(self.db)
     self.catview.db = self.db
     self.cats = self.catview.parse_applications_menu('/usr/share/app-install')
 def test_recommends_in_category_category(self, AgentMockCls):
     # ensure we use the same instance in test and code
     parser = CategoriesParser(self.db)
     cats = parser.parse_applications_menu("./data")
     # "2" is a multimedia query
     #     see ./test/data/desktop/software-center.menu
     recommends_cat = RecommendedForYouCategory(cats[2])
     # ensure we get a query when the callback is called
     recommends_cat._recommend_me_result(
         None, make_recommender_agent_recommend_me_dict())
     recommendations_in_cat = recommends_cat.get_documents(self.db)
     print recommendations_in_cat
     self.assertNotEqual(recommendations_in_cat, [])
示例#9
0
 def __init__(self, parent=None):
     super(CategoriesModel, self).__init__()
     self._categories = []
     roles = dict(enumerate(CategoriesModel.COLUMNS))
     self.setRoleNames(roles)
     pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")
     # FIXME: move this into app
     cache = get_pkg_info()
     db = StoreDatabase(pathname, cache)
     db.open()
     # /FIXME
     self.catparser = CategoriesParser(db)
     self._categories = self.catparser.parse_applications_menu()
 def __init__(self, parent=None):
     super(PkgListModel, self).__init__()
     self._docs = []
     roles = dict(enumerate(PkgListModel.COLUMNS))
     self.setRoleNames(roles)
     self._query = ""
     self._category = ""
     pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")
     self.cache = get_pkg_info()
     self.db = StoreDatabase(pathname, self.cache)
     self.db.open(use_axi=False)
     self.backend = get_install_backend()
     self.backend.connect("transaction-progress-changed",
                          self._on_backend_transaction_progress_changed)
     self.reviews = get_review_loader(self.cache)
     # FIXME: get this from a parent
     self._catparser = CategoriesParser(self.db)
     self._categories = self._catparser.parse_applications_menu(
         '/usr/share/app-install')
示例#11
0
文件: utils.py 项目: sti-lyneos/shop
def get_test_categories(db):
    parser = CategoriesParser(db)
    cats = parser.parse_applications_menu()
    return cats
 def setUpClass(cls):
     cls.db = get_test_db()
     cls.parser = CategoriesParser(cls.db)
     cls.cats = cls.parser.parse_applications_menu("./data/")
 def setUp(self):
     self.db = get_test_db()
     parser = CategoriesParser(self.db)
     self.cats = parser.parse_applications_menu('/usr/share/app-install')