86
def index_name(doc, name, term_generator):
87
""" index the name of the application """
88
doc.add_value(XAPIAN_VALUE_APPNAME, name)
89
doc.add_term("AA"+name)
90
w = globals()["WEIGHT_DESKTOP_NAME"]
91
term_generator.index_text_without_positions(name, w)
86
93
def update(db, cache, datadir=APP_INSTALL_PATH):
87
94
" index the desktop files in $datadir/desktop/*.desktop "
88
95
term_generator = xapian.TermGenerator()
105
112
logging.debug("duplicated name '%s' (%s)" % (name, desktopf))
107
114
doc.set_data(name)
108
doc.add_value(XAPIAN_VALUE_APPNAME, name)
109
doc.add_term("AA"+name)
115
index_name(doc, name, term_generator)
110
116
# check if we should ignore this file
111
117
if parser.has_option_desktop("X-AppInstall-Ignore"):
112
118
ignore = parser.get_desktop("X-AppInstall-Ignore")
161
167
doc.add_value(XAPIAN_VALUE_POPCON,
162
168
xapian.sortable_serialise(popcon))
163
169
popcon_max = max(popcon_max, popcon)
164
171
# comment goes into the summary data if there is one,
165
# other wise we try GenericName
172
# other wise we try GenericName and if nothing else,
173
# the summary of the package
166
174
if parser.has_option_desktop("Comment"):
167
175
s = parser.get_desktop("Comment")
168
176
doc.add_value(XAPIAN_VALUE_SUMMARY, s)
178
186
term_generator.index_text_without_positions(pkgname, WEIGHT_APT_PKGNAME)
180
188
# now add search data from the desktop file
181
for key in ["Name","Generic Name","Comment"]:
189
for key in ["GenericName","Comment"]:
182
190
if not parser.has_option_desktop(key):
184
192
s = parser.get_desktop(key)
185
193
w = globals()["WEIGHT_DESKTOP_"+key.replace(" ","").upper()]
186
term_generator.index_text_without_positions(s)
194
term_generator.index_text_without_positions(s, w)
187
195
# add data from the apt cache
188
196
if pkgname in cache and cache[pkgname].candidate:
189
197
s = cache[pkgname].candidate.summary
190
198
term_generator.index_text_without_positions(s, WEIGHT_APT_SUMMARY)
191
199
s = cache[pkgname].candidate.description
192
200
term_generator.index_text_without_positions(s, WEIGHT_APT_DESCRIPTION)
201
for origin in cache[pkgname].candidate.origins:
202
doc.add_term("XOA"+origin.archive)
203
doc.add_term("XOC"+origin.component)
204
doc.add_term("XOL"+origin.label)
205
doc.add_term("XOO"+origin.origin)
206
doc.add_term("XOS"+origin.site)
193
208
# add our keywords (with high priority)
194
209
if parser.has_option_desktop("X-AppInstall-Keywords"):
195
210
keywords = parser.get_desktop("X-AppInstall-Keywords")