* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/pkgcorepm/, gentoopm/basepm/
@ 2011-07-25 17:06 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-07-25 17:06 UTC (permalink / raw
To: gentoo-commits
commit: 1c8e7024ab015abfa6d192406d846b4129f0daca
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 16:43:29 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 16:43:29 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=1c8e7024
PkgCore: implement package contents grabbing.
---
gentoopm/basepm/contents.py | 33 +++++++++++++++++++++++++++++++++
gentoopm/pkgcorepm/contents.py | 17 +++++++++++++++++
gentoopm/pkgcorepm/pkg.py | 5 +++++
3 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/gentoopm/basepm/contents.py b/gentoopm/basepm/contents.py
new file mode 100644
index 0000000..68a91b6
--- /dev/null
+++ b/gentoopm/basepm/contents.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+import os.path
+from abc import abstractmethod, abstractproperty
+
+from gentoopm.util import ABCObject
+
+class PMPackageContents(ABCObject):
+ """
+ A base class for package contents (files installed by a package).
+ """
+
+ @abstractmethod
+ def __iter__(self):
+ """
+ Iterate over files and directories installed by the package.
+ """
+ pass
+
+ @abstractmethod
+ def __contains__(self, path):
+ """
+ Check whether the path given is installed by the package.
+
+ @param path: the path to check
+ @type path: string
+ @return: whether the path exists in package contents
+ @rtype: bool
+ """
+ pass
diff --git a/gentoopm/pkgcorepm/contents.py b/gentoopm/pkgcorepm/contents.py
new file mode 100644
index 0000000..9416f3d
--- /dev/null
+++ b/gentoopm/pkgcorepm/contents.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+# vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from gentoopm.basepm.contents import PMPackageContents
+
+class PkgCorePackageContents(PMPackageContents):
+ def __init__(self, cont):
+ self._cont = cont
+
+ def __iter__(self):
+ for f in self._cont:
+ yield f.location
+
+ def __contains__(self, path):
+ return path in self._cont
diff --git a/gentoopm/pkgcorepm/pkg.py b/gentoopm/pkgcorepm/pkg.py
index 94ed58e..dff02ed 100644
--- a/gentoopm/pkgcorepm/pkg.py
+++ b/gentoopm/pkgcorepm/pkg.py
@@ -9,6 +9,7 @@ from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
PMPackageState
from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
from gentoopm.pkgcorepm.atom import PkgCoreAtom, PkgCorePackageKey
+from gentoopm.pkgcorepm.contents import PkgCorePackageContents
from gentoopm.util import SpaceSepTuple
class PkgCorePackageSet(PMPackageSet):
@@ -118,6 +119,10 @@ class PkgCoreInstalledPackage(PkgCorePackage, PMInstalledPackage):
return SpaceSepTuple(l)
+ @property
+ def contents(self):
+ return PkgCorePackageContents(self._pkg.contents)
+
def __lt__(self, other):
if not isinstance(other, PkgCorePackage):
raise TypeError('Unable to compare %s against %s' % \
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/pkgcorepm/, gentoopm/basepm/
@ 2011-07-25 17:06 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-07-25 17:06 UTC (permalink / raw
To: gentoo-commits
commit: b64ac5001dd090bfd04025ad49e8a75fcd5c9aef
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 16:57:15 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 17:06:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=b64ac500
PkgCore: introduce base PMContentObj.
---
gentoopm/basepm/contents.py | 9 ++++++++-
gentoopm/pkgcorepm/contents.py | 7 ++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/gentoopm/basepm/contents.py b/gentoopm/basepm/contents.py
index 68a91b6..b173ebf 100644
--- a/gentoopm/basepm/contents.py
+++ b/gentoopm/basepm/contents.py
@@ -6,7 +6,14 @@
import os.path
from abc import abstractmethod, abstractproperty
-from gentoopm.util import ABCObject
+from gentoopm.util import ABCObject, StringCompat
+
+class PMContentObj(StringCompat):
+ def __init__(self, path):
+ self._path = os.path.normpath(path)
+
+ def __str__(self):
+ return self._path
class PMPackageContents(ABCObject):
"""
diff --git a/gentoopm/pkgcorepm/contents.py b/gentoopm/pkgcorepm/contents.py
index 9416f3d..4617123 100644
--- a/gentoopm/pkgcorepm/contents.py
+++ b/gentoopm/pkgcorepm/contents.py
@@ -3,7 +3,8 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
-from gentoopm.basepm.contents import PMPackageContents
+from gentoopm.basepm.contents import PMPackageContents, \
+ PMContentObj
class PkgCorePackageContents(PMPackageContents):
def __init__(self, cont):
@@ -11,7 +12,7 @@ class PkgCorePackageContents(PMPackageContents):
def __iter__(self):
for f in self._cont:
- yield f.location
+ yield PMContentObj(f.location)
def __contains__(self, path):
- return path in self._cont
+ return str(path) in self._cont
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/pkgcorepm/, gentoopm/basepm/
@ 2011-09-09 21:13 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2011-09-09 21:13 UTC (permalink / raw
To: gentoo-commits
commit: 8b1eaf1b904b8a42a5220196d20500f23b38ee33
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 9 21:07:58 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Sep 9 21:07:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=8b1eaf1b
Introduce an interface and pkgcore implem for getting package maintainers.
---
gentoopm/basepm/pkg.py | 80 +++++++++++++++++++++++++++++++++++++++++++++
gentoopm/pkgcorepm/pkg.py | 30 ++++++++++++++++-
2 files changed, 109 insertions(+), 1 deletions(-)
diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
index 3ad2774..db3e707 100644
--- a/gentoopm/basepm/pkg.py
+++ b/gentoopm/basepm/pkg.py
@@ -93,6 +93,77 @@ class PMUseFlag(ABCObject, StringCompat):
"""
pass
+class PMPackageMaintainer(ABCObject, StringCompat):
+ """
+ A base class for a package maintainer.
+ """
+
+ def __new__(self, email, name = None):
+ """
+ Instantiate the actual string. Requires other props prepared
+ beforehand.
+
+ @param email: maintainer's e-mail address
+ @type email: string
+ @param name: maintainer's real name
+ @type name: string/C{None}
+ """
+
+ ret = ['<%s>' % email]
+ if name is not None:
+ ret.insert(0, name)
+
+ ret = StringCompat.__new__(self, ' '.join(ret))
+ ret._name = name
+ ret._email = email
+ return ret
+
+ @property
+ def name(self):
+ """
+ Maintainer's real name.
+
+ @type: string/C{None}
+ """
+ return self._name
+
+ @property
+ def email(self):
+ """
+ Maintainer's e-mail address.
+
+ @type: string
+ """
+ return self._email
+
+ @abstractproperty
+ def description(self):
+ """
+ Detailed maintainership description.
+
+ @type: string/C{None}
+ """
+ pass
+
+class PMPackageHerd(PMPackageMaintainer):
+ """
+ A helper class for herd maintainers.
+ """
+
+ def __new__(self, name):
+ """
+ Instantiate for the named herd.
+
+ @param name: name of the herd
+ @type name: string
+ """
+ return PMPackageMaintainer.__new__(self,
+ '%s@gentoo.org' % name)
+
+ @property
+ def description(self):
+ return None
+
class PMPackage(PMAtom, FillMissingComparisons):
"""
An abstract class representing a single, uniquely-identified package
@@ -273,6 +344,15 @@ class PMPackage(PMAtom, FillMissingComparisons):
pass
@abstractproperty
+ def maintainers(self):
+ """
+ Get the package maintainer list.
+
+ @type: tuple(L{PMPackageMaintainer})
+ """
+ pass
+
+ @abstractproperty
def slotted_atom(self):
"""
Return an atom matching all packages in the same slot as the package.
diff --git a/gentoopm/pkgcorepm/pkg.py b/gentoopm/pkgcorepm/pkg.py
index 8782433..6ac88f9 100644
--- a/gentoopm/pkgcorepm/pkg.py
+++ b/gentoopm/pkgcorepm/pkg.py
@@ -5,7 +5,7 @@
from ..basepm.pkg import PMPackage, PMPackageDescription, \
PMInstalledPackage, PMInstallablePackage, PMBoundPackageKey, \
- PMPackageState, PMUseFlag
+ PMPackageState, PMUseFlag, PMPackageMaintainer, PMPackageHerd
from ..basepm.pkgset import PMPackageSet, PMFilteredPackageSet
from ..util import SpaceSepTuple, SpaceSepFrozenSet
@@ -72,6 +72,30 @@ class PkgCoreUseSet(SpaceSepFrozenSet):
# XXX, incorrect flags?
return PkgCoreUseFlag(k, self._use)
+class PkgCorePackageMaintainer(PMPackageMaintainer):
+ def __new__(self, m):
+ ret = PMPackageMaintainer.__new__(self, m.email, m.name)
+ ret._m = m
+ return ret
+
+ @property
+ def description(self):
+ return self._m.description
+
+class PkgCorePackageHerd(PMPackageHerd):
+ pass
+
+class PkgCoreMaintainerTuple(tuple):
+ def __new__(self, maints, herds):
+ def _iter_maints():
+ for m in maints:
+ yield PkgCorePackageMaintainer(m)
+ for h in herds:
+ if h != 'no-herd':
+ yield PkgCorePackageHerd(h)
+
+ return tuple.__new__(self, _iter_maints())
+
class PkgCorePackage(PMPackage, PkgCoreAtom):
def __init__(self, pkg, repo_index = 0):
self._pkg = pkg
@@ -110,6 +134,10 @@ class PkgCorePackage(PMPackage, PkgCoreAtom):
return PkgCoreUseSet(self._pkg.iuse, self._pkg.use)
@property
+ def maintainers(self):
+ return PkgCoreMaintainerTuple(self._pkg.maintainers, self._pkg.herds)
+
+ @property
def slotted_atom(self):
return PkgCoreAtom(self._pkg.slotted_atom)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-09 21:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-09 21:13 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/pkgcorepm/, gentoopm/basepm/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2011-07-25 17:06 Michał Górny
2011-07-25 17:06 Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox