def get_best_selector(self, sack, forms=None): # :api kwargs = {'allow_globs': True} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: sltr = dnf.selector.Selector(sack) s = self._nevra_to_selector(sltr, nevra) if len(s.matches()) > 0: return s reldep = first(self.subj.reldep_possibilities_real(sack)) if reldep: sltr = dnf.selector.Selector(sack) dep = str(reldep) s = sltr.set(provides=dep) if len(s.matches()) > 0: return s if self.filename_pattern: sltr = dnf.selector.Selector(sack) key = "file__glob" if is_glob_pattern(self.pattern) else "file" return sltr.set(**{key: self.pattern}) sltr = dnf.selector.Selector(sack) return sltr
def get_best_query(self, sack, with_provides=True, forms=None): # :api pat = self.subj.pattern kwargs = {'allow_globs': True, 'icase': self.icase} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: q = self._nevra_to_filters(sack.query(), nevra) if q: return q if with_provides: reldeps = self.subj.reldep_possibilities_real(sack, icase=self.icase) reldep = first(reldeps) if reldep: q = sack.query().filter(provides=reldep) if q: return q if self.filename_pattern: return sack.query().filter_autoglob(file=pat) return sack.query().filter(empty=True)
def get_best_selector(self, sack, forms=None): # :api kwargs = {'allow_globs': True} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: return self._nevra_to_selector(dnf.selector.Selector(sack), nevra) reldep = first(self.subj.reldep_possibilities_real(sack)) if reldep: dep = str(reldep) return dnf.selector.Selector(sack).set(provides=dep) return None
def get_best_selector(self, sack, forms=None): # :api kwargs = {'allow_globs' : True} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: return self._nevra_to_selector(dnf.selector.Selector(sack), nevra) reldep = first(self.subj.reldep_possibilities_real(sack)) if reldep: dep = str(reldep) return dnf.selector.Selector(sack).set(provides=dep) return None
def get_best_selector(self, sack, forms=None): kwargs = {'allow_globs' : True} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: return self._nevra_to_selector(dnf.selector.Selector(sack), nevra) reldep = first(self.subj.reldep_possibilities_real(sack)) if reldep: # we can not handle full Reldeps dep = str(reldep) assert(not (set(dep) & set("<=>"))) return dnf.selector.Selector(sack).set(provides=str(reldep)) return None
def get_best_selector(self, sack, forms=None, obsoletes=True): # :api kwargs = {'allow_globs': True} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) sltr = dnf.selector.Selector(sack) if nevra: q = self._nevra_to_filters(sack.query(), nevra).filter(arch__neq="src") if q: if obsoletes and nevra._has_just_name(): q = q.union(sack.query().filter(obsoletes=q)) return sltr.set(pkg=q) if not forms: q = sack.query()._filterm(provides__glob=self._pattern) if q: return sltr.set(pkg=q) if self._filename_pattern: return sltr.set(pkg=sack.query()._filterm( file__glob=self._pattern)) return sltr
def _has_nevra_just_name(self, sack, forms=None): kwargs = {'allow_globs': True, 'icase': self.icase} if forms is not None: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: return nevra._has_just_name() return False
def get_best_selector(self, sack, forms=None): # :api sltr = dnf.selector.Selector(sack) kwargs = {"allow_globs": True} if self.filename_pattern: key = "file__glob" if is_glob_pattern(self.pattern) else "file" return sltr.set(**{key: self.pattern}) if forms: kwargs["form"] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: return self._nevra_to_selector(sltr, nevra) if is_glob_pattern(self.pattern): return sltr.set(provides__glob=self.pattern) reldep = first(self.subj.reldep_possibilities_real(sack)) if reldep: dep = str(reldep) return sltr.set(provides=dep) return sltr
def get_best_selectors(self, sack, forms=None): if not self.filename_pattern and is_glob_pattern(self.pattern): nevras = self.subj.nevra_possibilities_real(sack, allow_globs=True) nevra = first(nevras) if nevra and nevra.name: sltrs = [] pkgs = self._nevra_to_filters(sack.query(), nevra) for pkg_name in {pkg.name for pkg in pkgs}: exp_name = self.pattern.replace(nevra.name, pkg_name, 1) sltrs.append(Subject(exp_name).get_best_selector(sack, forms)) return sltrs return [self.get_best_selector(sack, forms)]
def get_best_query(self, sack, with_provides=True, forms=None): # :api pat = self._pattern kwargs = {'allow_globs': True, 'icase': self.icase} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: q = self._nevra_to_filters(sack.query(), nevra) if q: return q if not forms: if with_provides: q = sack.query()._filterm(provides__glob=self._pattern) if q: return q if self._filename_pattern: return sack.query().filter(file__glob=pat) return sack.query().filter(empty=True)
def get_best_query(self, sack, with_provides=True, forms=None): # :api pat = self._pattern kwargs = {'allow_globs': True, 'icase': self.icase} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) if nevra: q = self._nevra_to_filters(sack.query(), nevra) if q: return q if with_provides: q = sack.query()._filterm(provides__glob=self._pattern) if q: return q if self._filename_pattern: return sack.query().filter(file__glob=pat) return sack.query().filter(empty=True)
def get_best_selector(self, sack, forms=None): # :api kwargs = {'allow_globs': True} if forms: kwargs['form'] = forms nevra = first(self.subj.nevra_possibilities_real(sack, **kwargs)) sltr = dnf.selector.Selector(sack) if nevra: q = self._nevra_to_filters(sack.query(), nevra) if q: if nevra._has_just_name(): q = q.union(sack.query().filter(obsoletes=q)) return sltr.set(pkg=q) q = sack.query()._filterm(provides__glob=self._pattern) if q: return sltr.set(pkg=q) if self._filename_pattern: return sltr.set(pkg=sack.query()._filterm(file__glob=self._pattern)) return sltr
def is_arch_specified(self, sack): nevra = first( self.subj.nevra_possibilities_real(sack, allow_globs=True)) if nevra and nevra.arch: return is_glob_pattern(nevra.arch) return False
def is_arch_specified(self, sack): nevra = first(self.subj.nevra_possibilities_real(sack, allow_globs=True)) if nevra and nevra.arch: return is_glob_pattern(nevra.arch) return False