* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/paludispm/
@ 2011-07-07 15:55 Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2011-07-07 15:55 UTC (permalink / raw
To: gentoo-commits
commit: 0411159cece7017e714c2ba8298b0962f1a7be88
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 7 15:56:34 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 7 15:56:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=0411159c
Support creating atoms in portage & paludis.
---
gentoopm/paludispm/__init__.py | 4 ++--
gentoopm/paludispm/atom.py | 20 ++++++++++++++++++--
gentoopm/portagepm/__init__.py | 4 ++--
gentoopm/portagepm/atom.py | 27 +++++++++++++++++++++++++--
4 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/gentoopm/paludispm/__init__.py b/gentoopm/paludispm/__init__.py
index 3a70297..060eb2b 100644
--- a/gentoopm/paludispm/__init__.py
+++ b/gentoopm/paludispm/__init__.py
@@ -3,7 +3,7 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
-import paludis
+import functools, paludis
from gentoopm.basepm import PackageManager
from gentoopm.paludispm.atom import PaludisAtom
@@ -30,4 +30,4 @@ class PaludisPM(PackageManager):
@property
def Atom(self):
- return PaludisAtom
+ return functools.partial(PaludisAtom, pm = self)
diff --git a/gentoopm/paludispm/atom.py b/gentoopm/paludispm/atom.py
index 541470a..5e1949d 100644
--- a/gentoopm/paludispm/atom.py
+++ b/gentoopm/paludispm/atom.py
@@ -3,7 +3,23 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
+import paludis
+
from gentoopm.basepm.atom import PMAtom
-class PkgCoreAtom(PMAtom):
- pass
+class PaludisAtom(PMAtom):
+ def __init__(self, s, pm):
+ try:
+ self._atom = paludis.parse_user_package_dep_spec(
+ s, pm._env,
+ paludis.UserPackageDepSpecOptions(),
+ paludis.Filter.All())
+ except (paludis.BadVersionOperatorError, paludis.PackageDepSpecError):
+ raise ValueError('Incorrect atom: %s' % s)
+ except paludis.AmbiguousPackageNameError:
+ raise KeyError('Ambiguous atom: %s' % s)
+ except paludis.NoSuchPackageError:
+ raise KeyError('Unable to expand atom: %s' % s)
+
+ def __contains__(self, pkg):
+ raise NotImplementedError('Direct atom matching not implemented in Paludis')
diff --git a/gentoopm/portagepm/__init__.py b/gentoopm/portagepm/__init__.py
index 2ee6bf9..4b1887a 100644
--- a/gentoopm/portagepm/__init__.py
+++ b/gentoopm/portagepm/__init__.py
@@ -3,7 +3,7 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
-import os
+import functools, os
from portage import create_trees
from gentoopm.basepm import PackageManager
@@ -32,4 +32,4 @@ class PortagePM(PackageManager):
@property
def Atom(self):
- return PortageAtom
+ return functools.partial(PortageAtom, pm = self)
diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index 541470a..5c5ca69 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -3,7 +3,30 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
+import portage.exception as pe
+from portage.dbapi.dep_expand import dep_expand
+from portage.dep import Atom, match_from_list
+from portage.versions import catsplit
+
from gentoopm.basepm.atom import PMAtom
-class PkgCoreAtom(PMAtom):
- pass
+class PortageAtom(PMAtom):
+ def __init__(self, s, pm):
+ try:
+ a = dep_expand(s, mydb = pm._portdb,
+ settings = pm._portdb.settings)
+ except pe.AmbiguousPackageName:
+ raise KeyError('Ambiguous atom: %s' % s)
+ except pe.InvalidAtom:
+ raise ValueError('Incorrect atom: %s' % s)
+
+ if catsplit(a.cp)[0] == 'null':
+ raise KeyError('Unable to expand atom: %s' % s)
+ self._atom = a
+
+ def __contains__(self, pkg):
+ # SLOT matching requires metadata so delay it.
+ if not match_from_list(self._atom, [pkg.id]):
+ return False
+ return not self._atom.slot \
+ or self._atom.slot == pkg.metadata.SLOT
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/paludispm/
@ 2011-07-16 22:55 Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2011-07-16 22:55 UTC (permalink / raw
To: gentoo-commits
commit: 9e26286fca5adb0583966b4a8f7778c2b451b96d
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 16 22:53:48 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Jul 16 22:53:48 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=9e26286f
Reuse new Atom APIs when transforming atoms.
---
gentoopm/paludispm/atom.py | 6 +++---
gentoopm/portagepm/atom.py | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gentoopm/paludispm/atom.py b/gentoopm/paludispm/atom.py
index 808e8ea..ccdd612 100644
--- a/gentoopm/paludispm/atom.py
+++ b/gentoopm/paludispm/atom.py
@@ -125,14 +125,14 @@ class PaludisAtom(PMAtom):
@property
def slotted(self):
assert(self.associated)
- cp = str(self._atom.package)
- slot = self._pkg.metadata['SLOT']
+ cp = str(self.key)
+ slot = self.slot or self._pkg.metadata['SLOT']
return PaludisAtom('%s:%s' % (cp, slot), self._env)
@property
def unversioned(self):
assert(self.associated)
- return PaludisAtom(str(self._atom.package), self._env)
+ return PaludisAtom(str(self.key), self._env)
@property
def key(self):
diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index 7342d89..0a77f76 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -96,14 +96,14 @@ class CompletePortageAtom(PMAtom):
@property
def slotted(self):
assert(self.associated)
- cp = self._atom.cp
+ cp = str(self.key)
slot = self._pkg.metadata['SLOT']
return PortageAtom('%s:%s' % (cp, slot))
@property
def unversioned(self):
assert(self.associated)
- return PortageAtom(self._atom.cp)
+ return PortageAtom(str(self.key))
@property
def key(self):
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/paludispm/
@ 2011-07-23 9:27 Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2011-07-23 9:27 UTC (permalink / raw
To: gentoo-commits
commit: 749f517175ff0da8325c8b3d7b8eeab78a1f91ca
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 23 09:28:36 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Jul 23 09:28:36 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=749f5171
Reuse key/version comparisons.
---
gentoopm/paludispm/pkg.py | 4 ++--
gentoopm/portagepm/pkg.py | 6 ++----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/gentoopm/paludispm/pkg.py b/gentoopm/paludispm/pkg.py
index 4af56c8..1c3fb6e 100644
--- a/gentoopm/paludispm/pkg.py
+++ b/gentoopm/paludispm/pkg.py
@@ -104,8 +104,8 @@ class PaludisID(PMPackage, PaludisAtom):
if not isinstance(other, PaludisID):
raise TypeError('Unable to compare %s against %s' % \
self, other)
- return str(self.key) < str(other.key) \
- or self._pkg.version < other._pkg.version \
+ return self.key < other.key \
+ or self.version < other.version \
or self._env.more_important_than( \
other.repository, self.repository)
diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 49e4b8e..a26bb45 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -124,8 +124,7 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
if not isinstance(other, PortageDBCPV):
raise TypeError('Unable to compare %s against %s' % \
(self, other))
- return cpv_getkey(self._cpv) < cpv_getkey(other._cpv) \
- or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) < 0
+ return self.key < other.key or self.version < other.version
class PortageCPV(PortageDBCPV, PMInstallablePackage):
def __init__(self, cpv, dbapi, tree, repo_prio):
@@ -156,8 +155,7 @@ class PortageCPV(PortageDBCPV, PMInstallablePackage):
if not isinstance(other, PortageCPV):
raise TypeError('Unable to compare %s against %s' % \
(self, other))
- return cpv_getkey(self._cpv) < cpv_getkey(other._cpv) \
- or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) < 0 \
+ return self.key < other.key or self.version < other.version \
or self._repo_prio < other._repo_prio
class PortageVDBCPV(PortageDBCPV, PMInstalledPackage):
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/paludispm/
@ 2011-08-13 9:17 Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2011-08-13 9:17 UTC (permalink / raw
To: gentoo-commits
commit: ccd70d30b9d2e685bdef12c4bdf5e8959050ded2
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 13 09:16:44 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 13 09:18:06 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=ccd70d30
Use itertools whenever feasible.
---
gentoopm/paludispm/pkg.py | 5 +++--
gentoopm/portagepm/pkg.py | 12 ++++++------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/gentoopm/paludispm/pkg.py b/gentoopm/paludispm/pkg.py
index a3a988c..5acf362 100644
--- a/gentoopm/paludispm/pkg.py
+++ b/gentoopm/paludispm/pkg.py
@@ -3,6 +3,7 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
+import itertools
import paludis
from ..basepm.depend import PMRequiredUseAtom
@@ -137,12 +138,12 @@ class PaludisID(PMPackage, PaludisAtom):
@property
def homepages(self):
spec = self._get_meta(self._pkg.homepage_key())
- return SpaceSepTuple([str(x) for x in spec])
+ return SpaceSepTuple(itertools.imap(str, spec))
@property
def keywords(self):
kws = self._get_meta(self._pkg.keywords_key())
- return SpaceSepFrozenSet([str(x) for x in kws])
+ return SpaceSepFrozenSet(itertools.imap(str, kws))
@property
def slot(self):
diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 5992ae2..dbdf77e 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -3,6 +3,7 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
+import itertools
from portage.versions import cpv_getkey, cpv_getversion, vercmp
from ..basepm.depend import PMRequiredUseAtom
@@ -105,10 +106,9 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
return PortagePackageVersion(self._cpv)
def _aux_get(self, *keys):
- val = [str(x) for x
- in self._dbapi.aux_get(self._cpv, keys)]
+ val = itertools.imap(str, self._dbapi.aux_get(self._cpv, keys))
if len(keys) == 1:
- return val[0]
+ return next(iter(val))
else:
return tuple(val)
@@ -236,10 +236,10 @@ class PortageCPV(PortageDBCPV, PMInstallablePackage):
return self._dbapi.getRepositoryName(self._tree)
def _aux_get(self, *keys):
- val = [str(x) for x in self._dbapi.aux_get
- (self._cpv, keys, mytree = self._tree)]
+ val = itertools.imap(str, self._dbapi.aux_get(self._cpv,
+ keys, mytree = self._tree))
if len(keys) == 1:
- return val[0]
+ return next(iter(val))
else:
return tuple(val)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/paludispm/
@ 2011-08-13 10:54 Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2011-08-13 10:54 UTC (permalink / raw
To: gentoo-commits
commit: 4e862d470e99c990243f9ef91a76528c81f691e7
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 13 10:53:52 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 13 10:53:52 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=4e862d47
Python3: replace itertools.imap() with map().
---
gentoopm/paludispm/pkg.py | 5 ++---
gentoopm/portagepm/pkg.py | 7 +++----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/gentoopm/paludispm/pkg.py b/gentoopm/paludispm/pkg.py
index 5acf362..4f9e874 100644
--- a/gentoopm/paludispm/pkg.py
+++ b/gentoopm/paludispm/pkg.py
@@ -3,7 +3,6 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
-import itertools
import paludis
from ..basepm.depend import PMRequiredUseAtom
@@ -138,12 +137,12 @@ class PaludisID(PMPackage, PaludisAtom):
@property
def homepages(self):
spec = self._get_meta(self._pkg.homepage_key())
- return SpaceSepTuple(itertools.imap(str, spec))
+ return SpaceSepTuple(map(str, spec))
@property
def keywords(self):
kws = self._get_meta(self._pkg.keywords_key())
- return SpaceSepFrozenSet(itertools.imap(str, kws))
+ return SpaceSepFrozenSet(map(str, kws))
@property
def slot(self):
diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index dbdf77e..0a1399d 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -3,7 +3,6 @@
# (c) 2011 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
-import itertools
from portage.versions import cpv_getkey, cpv_getversion, vercmp
from ..basepm.depend import PMRequiredUseAtom
@@ -106,7 +105,7 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
return PortagePackageVersion(self._cpv)
def _aux_get(self, *keys):
- val = itertools.imap(str, self._dbapi.aux_get(self._cpv, keys))
+ val = map(str, self._dbapi.aux_get(self._cpv, keys))
if len(keys) == 1:
return next(iter(val))
else:
@@ -236,8 +235,8 @@ class PortageCPV(PortageDBCPV, PMInstallablePackage):
return self._dbapi.getRepositoryName(self._tree)
def _aux_get(self, *keys):
- val = itertools.imap(str, self._dbapi.aux_get(self._cpv,
- keys, mytree = self._tree))
+ val = map(str, self._dbapi.aux_get(self._cpv, keys,
+ mytree = self._tree))
if len(keys) == 1:
return next(iter(val))
else:
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-08-13 10:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-13 10:54 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/, gentoopm/paludispm/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2011-08-13 9:17 Michał Górny
2011-07-23 9:27 Michał Górny
2011-07-16 22:55 Michał Górny
2011-07-07 15:55 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