Exemplo n.º 1
0
        def slow_search(self, fmris, manifest_func, excludes):
                """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."""

                for pfmri in list(fmris()):
                        fmri_str = pfmri.get_fmri(anarchy=True,
                            include_scheme=False)
                        if not (self.pkg_name_wildcard or
                            self.pkg_name_match(fmri_str)):
                                continue
                        manf = manifest_func(pfmri)
                        fast_update_dict = {}
                        fast_update_res = []
                        glob = self._glob
                        term = self._term
                        case_sensitive = self._case_sensitive

                        if not case_sensitive:
                                glob = True

                        search_dict = manifest.Manifest.search_dict(manf,
                            return_line=True, excludes=excludes)
                        for tmp in search_dict:
                                tok, at, st, fv = tmp
                                if not (self.action_type_wildcard or
                                    at == self.action_type) or \
                                    not (self.key_wildcard or st == self.key):
                                        continue
                                if tok not in fast_update_dict:
                                        fast_update_dict[tok] = []
                                fast_update_dict[tok].append((at, st, fv,
                                    fmri_str, search_dict[tmp]))
                        if glob:
                                keys = fast_update_dict.keys()
                                matches = choose(keys, term, case_sensitive)
                                fast_update_res = [
                                    fast_update_dict[m] for m in matches
                                ]
                        else:
                                if term in fast_update_dict:
                                        fast_update_res.append(
                                            fast_update_dict[term])
                        for sub_list in fast_update_res:
                                for at, st, fv, fmri_str, line_list in sub_list:
                                        for l in line_list:
                                                yield at, st, fmri_str, fv, l
        def slow_search(self, fmris, manifest_func, excludes):
                """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."""

                for pfmri in list(fmris()):
                        fmri_str = pfmri.get_fmri(anarchy=True,
                            include_scheme=False)
                        if not (self.pkg_name_wildcard or
                            self.pkg_name_match(fmri_str)):
                                continue
                        manf = manifest_func(pfmri)
                        fast_update_dict = {}
                        fast_update_res = []
                        glob = self._glob
                        term = self._term
                        case_sensitive = self._case_sensitive

                        if not case_sensitive:
                                glob = True

                        search_dict = manifest.Manifest.search_dict(manf,
                            return_line=True, excludes=excludes)
                        for tmp in search_dict:
                                tok, at, st, fv = tmp
                                if not (self.action_type_wildcard or
                                    at == self.action_type) or \
                                    not (self.key_wildcard or st == self.key):
                                        continue
                                if tok not in fast_update_dict:
                                        fast_update_dict[tok] = []
                                fast_update_dict[tok].append((at, st, fv,
                                    fmri_str, search_dict[tmp]))
                        if glob:
                                keys = fast_update_dict.keys()
                                matches = choose(keys, term, case_sensitive)
                                fast_update_res = [
                                    fast_update_dict[m] for m in matches
                                ]
                        else:
                                if term in fast_update_dict:
                                        fast_update_res.append(
                                            fast_update_dict[term])
                        for sub_list in fast_update_res:
                                for at, st, fv, fmri_str, line_list in sub_list:
                                        for l in line_list:
                                                yield at, st, fmri_str, fv, l
Exemplo n.º 3
0
        def _search_fast_update(self, manifest_func, excludes):
                """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."""

                assert self._data_main_dict.get_file_handle() is not None

                glob = self._glob
                term = self._term
                case_sensitive = self._case_sensitive

                if not case_sensitive:
                        glob = True
                        
                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.
                for fmri_str in self._data_fast_add._set:
                        if not (self.pkg_name_wildcard or
                            self.pkg_name_match(fmri_str)):
                                continue
                        f = fmri.PkgFmri(fmri_str)
                        path = manifest_func(f)
                        search_dict = manifest.Manifest.search_dict(path,
                            return_line=True, excludes=excludes)
                        for tmp in search_dict:
                                tok, at, st, fv = tmp
                                if not (self.action_type_wildcard or
                                    at == self.action_type) or \
                                    not (self.key_wildcard or st == self.key):
                                        continue
                                if tok not in fast_update_dict:
                                        fast_update_dict[tok] = []
                                fast_update_dict[tok].append((at, st, fv,
                                    fmri_str, search_dict[tmp]))
                if glob:
                        keys = fast_update_dict.keys()
                        matches = choose(keys, term, case_sensitive)
                        fast_update_res = [
                            fast_update_dict[m] for m in matches
                        ]
                        
                else:
                        if term in fast_update_dict:
                                fast_update_res.append(fast_update_dict[term])
                return fast_update_res
        def _search_fast_update(self, manifest_func, excludes):
                """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."""

                assert self._data_main_dict.get_file_handle() is not None

                glob = self._glob
                term = self._term
                case_sensitive = self._case_sensitive

                if not case_sensitive:
                        glob = True
                        
                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.
                for fmri_str in self._data_fast_add._set:
                        if not (self.pkg_name_wildcard or
                            self.pkg_name_match(fmri_str)):
                                continue
                        f = fmri.PkgFmri(fmri_str)
                        path = manifest_func(f)
                        search_dict = manifest.Manifest.search_dict(path,
                            return_line=True, excludes=excludes)
                        for tmp in search_dict:
                                tok, at, st, fv = tmp
                                if not (self.action_type_wildcard or
                                    at == self.action_type) or \
                                    not (self.key_wildcard or st == self.key):
                                        continue
                                if tok not in fast_update_dict:
                                        fast_update_dict[tok] = []
                                fast_update_dict[tok].append((at, st, fv,
                                    fmri_str, search_dict[tmp]))
                if glob:
                        keys = fast_update_dict.keys()
                        matches = choose(keys, term, case_sensitive)
                        fast_update_res = [
                            fast_update_dict[m] for m in matches
                        ]
                        
                else:
                        if term in fast_update_dict:
                                fast_update_res.append(fast_update_dict[term])
                return fast_update_res