63
63
for item in categories_str.split(";"):
65
65
categories.append(item)
66
except (NoOptionError, KeyError):
70
70
def desktopf(self):
71
71
""" return the file that the AppInfo comes from """
73
class AptCachePkgParser(AppInfoParserBase):
74
""" parser that fakes a Application from a pkg-record
75
Useful for special repositories like "Whats New"
78
MAPPING = { 'Name' : 'AppName',
81
# map from requested key to a static data element
82
STATIC_DATA = { 'Type' : 'Application',
85
def __init__(self, pkg):
87
self.origin = "apt-cache"
88
def _apply_mapping(self, key):
89
if key.startswith("X-AppInstall-"):
90
key = key[len("X-AppInstall-"):]
91
if key in self.MAPPING:
92
return self.MAPPING[key]
94
def get_desktop(self, key):
95
key = self._apply_mapping(key)
97
if key in self.STATIC_DATA:
98
return self.STATIC_DATA[key]
99
# we always excpect a AppName, if there is none, fake one
100
if key == "AppName" and not "AppName" in self.pkg.candidate.record:
102
return self.pkg.candidate.record[key]
103
def has_option_desktop(self, key):
104
# strip away bogus prefixes
105
if key.startswith("X-AppInstall-"):
106
key = key[len("X-AppInstall-"):]
107
if key in self.STATIC_DATA:
109
return self._apply_mapping(key) in self.pkg.candidate.record
73
114
class DesktopTagSectionParser(AppInfoParserBase):
74
115
def __init__(self, tag_section, tagfile):
75
116
self.tag_section = tag_section
166
207
def update(db, cache, datadir=APP_INSTALL_PATH):
167
208
update_from_app_install_data(db, cache, datadir)
168
209
update_from_var_lib_apt_lists(db, cache)
210
update_from_apt_cache_for_whats_new_repo(db, cache)
169
211
# add db global meta-data
170
212
logger.debug("adding popcon_max_desktop '%s'" % popcon_max)
171
213
db.set_metadata("popcon_max_desktop", xapian.sortable_serialise(float(popcon_max)))
215
def update_from_apt_cache_for_whats_new_repo(db, cache):
217
SPECIAL_ORIGINS_THAT_ARE_CONSIDERED_APPS = (
218
"Application Review Board PPA",
222
if not pkg.candidate:
224
for origin in pkg.candidate.origins:
225
# FIXME: make this configuration
226
if (origin.label in SPECIAL_ORIGINS_THAT_ARE_CONSIDERED_APPS and
228
parser = AptCachePkgParser(pkg)
229
index_app_info_from_parser(parser, db, cache)
173
231
def update_from_var_lib_apt_lists(db, cache, listsdir=None):
174
232
""" index the files in /var/lib/apt/lists/*AppInfo """