def get_application_by_name(self,pkgname): #print "get_application_by_name:", pkgname if pkgname == "brasero": return None if not pkgname: return None if self.cat_list is None: return None # # print("self.cat_list111",self.cat_list) for (catname, cat) in list(self.cat_list.items()): #get app in cat which init in uksc startup app = cat.get_application_byname(pkgname) if app is not None and app.package is not None: return app if(Globals.ADVANCED_SEARCH): pkg = self.get_package_by_name(pkgname) if pkg is not None and pkg.candidate is not None: #get app from cache and add it to cat when app not in cat displayname_cn = pkgname app = Application(pkgname, displayname_cn, cat, self.apt_cache) app.orig_name = app.name app.orig_summary = app.summary app.orig_description = app.description app.displayname = app.name app.summary = app.summary app.description = app.description app.from_ukscdb = False # if("Accessories" in self.cat_list.keys()): # cat = self.cat_list["Accessories"] # cat.apps[pkgname] = app return app return None
def get_category_apps_from_db(self,cat,catdir=""): lists = self.appmgr.db.query_category_apps(cat) apps = {} for item in lists: #pkgname = UnicodeToAscii(item[0]) pkgname = item[0] displayname_cn = item[1] if pkgname == "brasero": continue if pkgname in list(Globals.ALL_APPS.keys()): apps[pkgname] = Globals.ALL_APPS[pkgname] else: app = Application(pkgname,displayname_cn, cat, self.apt_cache) if app.package and app.package.candidate: #if there has special information in db, get them #get_category_apps_from_db: 0 0 #display_name, summary, description, rating_average,rating_total,review_total,download_total app.from_ukscdb = True app.orig_name = app.name#zx2015.01.26 app.orig_summary = app.summary app.orig_description = app.description appinfo = self.appmgr.db.query_application(pkgname) app.displayname = appinfo[0] app.summary = appinfo[1] app.description = appinfo[2] rating_average = appinfo[3] rating_total = appinfo[4] review_total = appinfo[5] app.downloadcount = appinfo[7] # rank = appinfo[6] # # if CheckChineseWords(app.summary) is False and CheckChineseWordsForUnicode(summary) is True: # if summary is not None and summary != 'None': # app.summary = summary # # if CheckChineseWords(app.description) is False and CheckChineseWordsForUnicode(description) is True: # if description is not None and summary != 'None': # app.description = description if rating_average is not None: app.ratings_average = float(rating_average) if rating_total is not None: app.ratings_total = int(rating_total) if review_total is not None: app.review_total = int(review_total) # if rank is not None: # app.rank = int(rank) apps[pkgname] = app Globals.ALL_APPS[pkgname] = app #make sure there is only one app with the same pkgname even it may belongs to other category return apps
def get_category_apps_from_db(self,cat,catdir=""): list = self.db.query_category_apps(cat) apps = {} for item in list: pkgname = UnicodeToAscii(item[0]) displayname = item[1] # print "get_category_apps_from_db:",pkgname app = Application(pkgname,displayname, cat, self.apt_cache) if app.package: apps[pkgname] = app #if there has special information in db, get them #get_category_apps_from_db: 0 0 #display_name, summary, description, rating_average,rating_total,review_total,download_total appinfo = self.db.query_application(pkgname) summary = appinfo[1] description = appinfo[2] rating_average = appinfo[3] rating_total = appinfo[4] review_total = appinfo[5] # rank = appinfo[6] # if CheckChineseWords(app.summary) is False and CheckChineseWordsForUnicode(summary) is True: if summary is not None and summary != 'None': app.summary = summary # if CheckChineseWords(app.description) is False and CheckChineseWordsForUnicode(description) is True: if description is not None and summary != 'None': app.description = description if rating_average is not None: app.ratings_average = float(rating_average) if rating_total is not None: app.ratings_total = int(rating_total) if review_total is not None: app.review_total = int(review_total) # if rank is not None: # app.rank = int(rank) return apps