예제 #1
0
파일: misc.py 프로젝트: houseofsuns/pkgcore
class nodeps_repo(object):

    """
    repository wrapper that returns wrapped pkgs via
    :obj:`MutatedPkg` that have their depends/rdepends/post_rdepends wiped
    """

    default_depends = default_rdepends = default_post_rdepends = DepSet()

    def __init__(self, repo):
        """
        :param repo: repository to wrap
        """
        self.raw_repo = repo

    def itermatch(self, *a, **kwds):
        return (MutatedPkg(
            x, overrides={"depends": self.default_depends,
                          "rdepends": self.default_rdepends,
                          "post_rdepends": self.default_post_rdepends}
            )
            for x in self.raw_repo.itermatch(*a, **kwds))

    def match(self, *a, **kwds):
        return list(self.itermatch(*a, **kwds))

    __getattr__ = GetAttrProxy("raw_repo")

    def __iter__(self):
        return self.itermatch(packages.AlwaysTrue)
예제 #2
0
파일: misc.py 프로젝트: pombreda/pkgcore
 def __init__(self,
              cpv,
              eapi="0",
              slot="0",
              subslot=None,
              iuse=(),
              use=(),
              repo=FakeRepo(),
              restrict='',
              keywords=None):
     if isinstance(repo, str):
         repo = FakeRepo(repo)
     elif isinstance(repo, (tuple, list)) and len(repo) < 3:
         repo = FakeRepo(*repo)
     FakePkgBase.__init__(self, cpv, repo=factory(repo))
     if keywords is not None:
         object.__setattr__(self, "keywords", set(keywords))
     object.__setattr__(self, "slot", str(slot))
     if subslot is None:
         subslot = slot
     object.__setattr__(self, "subslot", subslot)
     object.__setattr__(self, "restrict", DepSet.parse(restrict, str))
     object.__setattr__(self, "fetchables", [])
     object.__setattr__(self, "use", set(use))
     object.__setattr__(self, "iuse", set(iuse))
     object.__setattr__(self, 'eapi_obj', get_eapi(eapi, False))
예제 #3
0
파일: misc.py 프로젝트: shen390s/pkgcore
class nodeps_repo:
    """Repository wrapper that returns wrapped pkgs with deps wiped."""

    default_bdepend = default_depend = default_rdepend = default_pdepend = DepSet(
    )

    def __init__(self, repo):
        """
        :param repo: repository to wrap
        """
        self.raw_repo = repo

    def itermatch(self, *a, **kwds):
        return (MutatedPkg(x,
                           overrides={
                               "bdepend": self.default_bdepend,
                               "depend": self.default_depend,
                               "rdepend": self.default_rdepend,
                               "pdepend": self.default_pdepend
                           }) for x in self.raw_repo.itermatch(*a, **kwds))

    def match(self, *a, **kwds):
        return list(self.itermatch(*a, **kwds))

    __getattr__ = GetAttrProxy("raw_repo")
    __dir__ = DirProxy("raw_repo")

    def __iter__(self):
        return self.itermatch(packages.AlwaysTrue)
예제 #4
0
파일: misc.py 프로젝트: veelai/pkgcore
 def __init__(self, cpv, slot=0, iuse=(), use=(), repo=FakeRepo(), restrict=''):
     if isinstance(repo, str):
         repo = FakeRepo(repo)
     elif isinstance(repo, (tuple, list)) and len(repo) < 3:
         repo = FakeRepo(*repo)
     FakePkgBase.__init__(self, cpv, repo=factory(repo))
     object.__setattr__(self, "slot", str(slot))
     object.__setattr__(self, "restrict", DepSet.parse(restrict, str))
     object.__setattr__(self, "use", set(use))
     object.__setattr__(self, "iuse", set(iuse))
예제 #5
0
파일: misc.py 프로젝트: chutz/pkgcore
 def __init__(self, cpv, eapi="0", slot="0", subslot=None, iuse=(), use=(),
              repo=FakeRepo(), restrict='', keywords=None):
     if isinstance(repo, str):
         repo = FakeRepo(repo)
     elif isinstance(repo, (tuple, list)) and len(repo) < 3:
         repo = FakeRepo(*repo)
     FakePkgBase.__init__(self, cpv, repo=factory(repo))
     if keywords is not None:
         object.__setattr__(self, "keywords", set(keywords))
     object.__setattr__(self, "slot", str(slot))
     if subslot is None:
         subslot = slot
     object.__setattr__(self, "subslot", subslot)
     object.__setattr__(self, "restrict", DepSet.parse(restrict, str))
     object.__setattr__(self, "fetchables", [])
     object.__setattr__(self, "use", set(use))
     object.__setattr__(self, "iuse", set(iuse))
     object.__setattr__(self, 'eapi_obj', get_eapi(eapi, False))
예제 #6
0
파일: virtual.py 프로젝트: shen390s/pkgcore
class InjectedPkg(pkg_base.wrapper):

    __slots__ = (
        "bdepend",
        "depend",
        "rdepend",
        "pdepend",
        "repo",
        "repo_id",
        "built",
        "versioned_atom",
        "unversioned_atom",
        "data",
    )
    default_bdepend = default_depend = default_rdepend = default_pdepend = DepSet(
    )
    package_is_real = False
    is_supported = True

    def __init__(self, raw_pkg, repo, data=None):
        pkg_base.wrapper.__init__(self, raw_pkg)
        object.__setattr__(self, "repo", repo)
        object.__setattr__(self, "repo_id", repo.repo_id)
        object.__setattr__(self, "built", repo.livefs)
        object.__setattr__(self, "versioned_atom", self._raw_pkg)
        object.__setattr__(self, "unversioned_atom", self._raw_pkg.key)
        object.__setattr__(self, "bdepend", self.default_bdepend)
        object.__setattr__(self, "depend", self.default_depend)
        object.__setattr__(self, "rdepend", self.default_rdepend)
        object.__setattr__(self, "pdepend", self.default_pdepend)
        object.__setattr__(self, "data", data)

    @property
    def use(self):
        if self._raw_pkg.use is None:
            return ()
        return self._raw_pkg.use

    def __cmp__(self, other):
        if isinstance(other, InjectedPkg):
            other = other._raw_pkg
        elif isinstance(other, pkg_base.base):
            other = other.versioned_atom
        if self._raw_pkg.intersects(other):
            return 0
        return cmp(self._raw_pkg, other)

    def __eq__(self, other):
        if isinstance(other, InjectedPkg):
            other = other._raw_pkg
        elif isinstance(other, pkg_base.base):
            other = other.versioned_atom
        return self._raw_pkg.intersects(other)

    def __ne__(self, other):
        if isinstance(other, InjectedPkg):
            other = other._raw_pkg
        elif isinstance(other, pkg_base.base):
            other = other.versioned_atom
        return not self._raw_pkg.intersects(other)

    def __str__(self):
        return f'injected restriction pkg: {self._raw_pkg}'

    def __repr__(self):
        return "<%s cpv=%r @%#8x>" % (self.__class__, self.cpvstr, id(self))

    def __hash__(self):
        return hash(self._raw_pkg)