#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
import os
import sys
import threading
import itertools
pass
"""This class exists so that the classes the parent class query parser
uses to build the AST are the ones defined in this module and not the
parent class's module. This is done so that a single query parser can
be shared between the client and server modules but will construct an
AST using the appropriate classes."""
tmp = {}
# Because many classes do not have client specific modifications, they
# simply subclass the parent module's classes.
pass
return []
return
return "(a AND b)"
else:
return "<(a AND b)>"
"""Makes this node return packages instead of actions.
Returns None because no changes need to be made to the tree."""
return None
if not lcv:
if not rcv:
"""This class handles raising the exception if the search was conducted
without using indexes. It yields all results, then raises the
exception."""
"""Return whether slow search has been used."""
return self.__use_slow_search
"""Set whether slow search has been used."""
"""This function provides the necessary information to the AST
so that a search can be performed."""
**kwargs)
"""This function performs performs local client side search.
If slow search was used, then after all results have been
returned, it raises SlowSearchUsed."""
yield i
raise api_errors.SlowSearchUsed()
"""This class handles the client specific search logic for searching
for a base query term."""
__client_dict_locks = {}
_global_data_dict = {}
self._impl_fmri_to_path = None
self._data_fast_remove = None
self.full_fmri_hash = None
self._data_fast_add = None
return
# Setup default global dictionary for this index path.
# Client search needs to account for the packages which have
# been installed or removed since the last time the indexes
# were rebuilt. Add client-specific global data dictionaries
# for this index path.
# This lock is used so that only one instance of a term query
# object is ever modifying the class wide variable for this
# index.
"""This function provides the necessary information to the AST
so that a search can be performed.
The "gen_installed_pkg_names" parameter is a function which
returns a generator function which iterates over the names of
the installed packages in the image.
The "get_use_slow_search" parameter is a function that returns
whether slow search has been used.
The "set_use_slow_search" parameter is a function that sets
whether slow search was used."""
try:
try:
**kwargs)
# Take local copies of the client-only
# dictionaries so that if another thread
# changes the shared data structure, this
# instance's objects won't be affected.
except se.NoIndexException:
# If no index was found, the slower version of
# search will be used.
finally:
"""This function performs performs local client side search.
The "restriction" parameter is a generator over the results that
another branch of the AST has already found. If it exists,
those results are treated as the domain for search. If it does
not exist, search uses the set of actions from installed
packages as the domain.
The "fmris" parameter is a function which produces an object
which iterates over the names of installed fmris.
The "manifest_func" parameter is a function which takes a fmri
and returns a path to the manifest for that fmri.
The "excludes" parameter is a list of the variants defined for
this image."""
if restriction:
elif not self.get_use_slow_search():
try:
except se.IncorrectIndexFileHash:
raise \
base_res = \
client_res = \
return it
else:
"""This function removes any results from the generator "res"
(the search results) that are actions from packages known to
have been removed from the image since the last time the index
was built."""
return (
(p_str, o, a, s, f)
for p_str, o, a, s, f
in res
)
"""This function searches the packages which have been
installed since the last time the index was rebuilt.
The "manifest_func" parameter is a function which maps fmris to
the path to their manifests.
The "excludes" paramter is a list of variants defined in the
image."""
if not case_sensitive:
fast_update_dict = {}
fast_update_res = []
# self._data_fast_add holds the names of the fmris added
# since the last time the index was rebuilt.
if not (self.pkg_name_wildcard or
continue
path = manifest_func(f)
for tmp in search_dict:
if not (self.action_type_wildcard or
continue
if tok not in fast_update_dict:
fast_update_dict[tok] = []
if glob:
fast_update_res = [
fast_update_dict[m] for m in matches
]
else:
if term in fast_update_dict:
return fast_update_res
"""This function transforms the output of _search_fast_update
to match that of _search_internal."""
for sub_list in fast_update_res:
for l in line_list:
"""This function performs search when no prebuilt index is
available.
The "fmris" parameter is a generator function which iterates
over the packages to be searched.
The "manifest_func" parameter is a function which maps fmris to
the path to their manifests.
The "excludes" parameter is a list of variants defined in the
image."""
if not (self.pkg_name_wildcard or
continue
fast_update_dict = {}
fast_update_res = []
if not case_sensitive:
for tmp in search_dict:
if not (self.action_type_wildcard or
continue
if tok not in fast_update_dict:
fast_update_dict[tok] = []
if glob:
fast_update_res = [
fast_update_dict[m] for m in matches
]
else:
if term in fast_update_dict:
for sub_list in fast_update_res:
for l in line_list:
"""Legacy function used to search indexes which have a pkg
directory with fmri offset information instead of the
fmri_offsets.v1 file. This function is in this subclass to
translate the error from a search_error to an api_error."""
try:
except se.InconsistentIndexException as e:
raise api_errors.InconsistentIndexException(e)
if (not self.action_type_wildcard and
return False
return True