public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-06 16:03 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-06 16:03 UTC (permalink / raw
  To: gentoo-commits

commit:     1289b60a321e7b0fa507ee22e9a92d4baef2234c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul  6 15:59:59 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul  6 15:59:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=1289b60a

Portage: cleanup class inheritance.

---
 gentoopm/portagepm/__init__.py |    3 +-
 gentoopm/portagepm/db.py       |   65 ----------------------------------------
 gentoopm/portagepm/pkg.py      |   36 ++++++++++++++++++----
 gentoopm/portagepm/repo.py     |   15 ++++++++-
 4 files changed, 43 insertions(+), 76 deletions(-)

diff --git a/gentoopm/portagepm/__init__.py b/gentoopm/portagepm/__init__.py
index 15a9bec..0919916 100644
--- a/gentoopm/portagepm/__init__.py
+++ b/gentoopm/portagepm/__init__.py
@@ -7,8 +7,7 @@ import os
 from portage import create_trees
 
 from gentoopm.basepm import PackageManager
-from gentoopm.portagepm.repo import PortageRepoDict
-from gentoopm.portagepm.db import VDBRepository
+from gentoopm.portagepm.repo import PortageRepoDict, VDBRepository
 
 class PortagePM(PackageManager):
 	name = 'portage'

diff --git a/gentoopm/portagepm/db.py b/gentoopm/portagepm/db.py
deleted file mode 100644
index 3eae39a..0000000
--- a/gentoopm/portagepm/db.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/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 portage.versions
-
-from gentoopm.basepm.metadata import PMPackageMetadata
-from gentoopm.basepm.repo import PMRepository
-from gentoopm.portagepm.pkg import PortageCPV
-
-# XXX: cleanup all this mess!
-
-class PortageDBCPV(PortageCPV):
-	def __init__(self, cpv, dbapi):
-		self._cpv = cpv
-		self._dbapi = dbapi
-
-	@property
-	def metadata(self):
-		return PortageDBMetadata(self._cpv, self._dbapi)
-
-	@property
-	def path(self):
-		# .findname() gives .ebuild path
-		return self._dbapi.getpath(self._cpv)
-
-class PortageDBMetadata(PMPackageMetadata):
-	def __init__(self, cpv, dbapi):
-		self._cpv = cpv
-		self._dbapi = dbapi
-
-	def __getattr__(self, key):
-		return self._dbapi.aux_get(self._cpv, [key])[0]
-
-	@property
-	def CATEGORY(self):
-		return portage.versions.catsplit(self._cpv)[0]
-
-	@property
-	def PN(self):
-		return portage.versions.catpkgsplit(self._cpv)[1]
-
-	@property
-	def PV(self):
-		return portage.versions.pkgsplit(self._cpv)[1]
-
-	@property
-	def PR(self):
-		return portage.versions.pkgsplit(self._cpv)[2]
-
-	@property
-	def PVR(self):
-		return portage.versions.cpv_getversion(self._cpv)
-
-class PortDBRepository(PMRepository):
-	def __init__(self, dbapi):
-		self._dbapi = dbapi
-
-	def __iter__(self):
-		for p in self._dbapi.cpv_all(): # XXX
-			yield PortageDBCPV(p, self._dbapi)
-
-class VDBRepository(PortDBRepository):
-	pass

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 8696706..a92af4e 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -10,10 +10,23 @@ from gentoopm.basepm.pkg import PMPackage
 
 # XXX: cleanup all this mess!
 
-class PortageCPV(PMPackage):
-	def __init__(self, cpv, dbapi, tree):
+class PortageDBCPV(PMPackage):
+	def __init__(self, cpv, dbapi):
 		self._cpv = cpv
 		self._dbapi = dbapi
+
+	@property
+	def metadata(self):
+		return PortageDBMetadata(self._cpv, self._dbapi)
+
+	@property
+	def path(self):
+		# .findname() gives .ebuild path
+		return self._dbapi.getpath(self._cpv)
+
+class PortageCPV(PortageDBCPV):
+	def __init__(self, cpv, dbapi, tree = None):
+		PortageDBCPV.__init__(self, cpv, dbapi)
 		self._tree = tree
 
 	@property
@@ -35,17 +48,15 @@ class PortageCPV(PMPackage):
 				portage.versions.cpv_getversion(self._cpv),
 				portage.versions.cpv_getversion(other._cpv))
 
-class PortageMetadata(PMPackageMetadata):
-	def __init__(self, cpv, dbapi, tree):
+class PortageDBMetadata(PMPackageMetadata):
+	def __init__(self, cpv, dbapi):
 		self._cpv = cpv
 		self._dbapi = dbapi
-		self._tree = tree
 
 	def __getattr__(self, key):
 		if key not in self:
 			raise AttributeError('Unsupported metadata key: %s' % key)
-		return self._dbapi.aux_get(self._cpv, [key],
-				mytree = self._tree)[0]
+		return self._dbapi.aux_get(self._cpv, [key])[0]
 
 	@property
 	def CATEGORY(self):
@@ -66,3 +77,14 @@ class PortageMetadata(PMPackageMetadata):
 	@property
 	def PVR(self):
 		return portage.versions.cpv_getversion(self._cpv)
+
+class PortageMetadata(PortageDBMetadata):
+	def __init__(self, cpv, dbapi, tree):
+		PortageDBMetadata.__init__(self, cpv, dbapi)
+		self._tree = tree
+
+	def __getattr__(self, key):
+		if key not in self:
+			raise AttributeError('Unsupported metadata key: %s' % key)
+		return self._dbapi.aux_get(self._cpv, [key],
+				mytree = self._tree)[0]

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index 8203f92..aece5f6 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -5,8 +5,8 @@
 
 import os.path
 
-from gentoopm.basepm.repo import PMRepositoryDict, PMEbuildRepository
-from gentoopm.portagepm.db import PortDBRepository
+from gentoopm.basepm.repo import PMRepositoryDict, PMEbuildRepository, \
+		PMRepository
 from gentoopm.portagepm.pkg import PortageCPV
 
 class PortageRepoDict(PMRepositoryDict):
@@ -29,6 +29,14 @@ class PortageRepoDict(PMRepositoryDict):
 	def __init__(self, portdbapi):
 		self._dbapi = portdbapi
 
+class PortDBRepository(PMRepository):
+	def __init__(self, dbapi):
+		self._dbapi = dbapi
+
+	def __iter__(self):
+		for p in self._dbapi.cpv_all(): # XXX
+			yield PortageCPV(p, self._dbapi)
+
 class PortageRepository(PortDBRepository, PMEbuildRepository):
 	def __init__(self, repo_obj, portdbapi):
 		self._repo = repo_obj
@@ -50,3 +58,6 @@ class PortageRepository(PortDBRepository, PMEbuildRepository):
 
 	def __cmp__(self, other):
 		return cmp(self._repo.priority, other._repo.priority)
+
+class VDBRepository(PortDBRepository):
+	pass



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-06 20:54 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-06 20:54 UTC (permalink / raw
  To: gentoo-commits

commit:     12de332e8e4c16255a8353fce52e58a309c9847e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul  6 18:15:47 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul  6 18:15:47 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=12de332e

portage: reimplement complete package sorting.

---
 gentoopm/portagepm/pkg.py  |   27 ++++++++++++---------------
 gentoopm/portagepm/repo.py |    3 ++-
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index a92af4e..e5e9469 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -3,13 +3,12 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-import portage.versions
+from portage.versions import cpv_getkey, cpv_getversion, vercmp, \
+		catsplit, catpkgsplit, pkgsplit
 
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage
 
-# XXX: cleanup all this mess!
-
 class PortageDBCPV(PMPackage):
 	def __init__(self, cpv, dbapi):
 		self._cpv = cpv
@@ -25,9 +24,10 @@ class PortageDBCPV(PMPackage):
 		return self._dbapi.getpath(self._cpv)
 
 class PortageCPV(PortageDBCPV):
-	def __init__(self, cpv, dbapi, tree = None):
+	def __init__(self, cpv, dbapi, tree, repo_prio):
 		PortageDBCPV.__init__(self, cpv, dbapi)
 		self._tree = tree
+		self._repo_prio = repo_prio
 
 	@property
 	def metadata(self):
@@ -41,12 +41,9 @@ class PortageCPV(PortageDBCPV):
 		if not isinstance(other, PortageCPV):
 			raise TypeError('Unable to compare %s against %s' % \
 					self, other)
-		if portage.versions.cpv_getkey(self._cpv) != \
-				portage.versions.cpv_getkey(other._cpv):
-			raise TypeError('Unable to compare CPVs with different PNs')
-		return portage.versions.vercmp(
-				portage.versions.cpv_getversion(self._cpv),
-				portage.versions.cpv_getversion(other._cpv))
+		return cmp(cpv_getkey(self._cpv), cpv_getkey(other._cpv)) \
+				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) \
+				or cmp(self._repo_prio, other._repo_prio)
 
 class PortageDBMetadata(PMPackageMetadata):
 	def __init__(self, cpv, dbapi):
@@ -60,23 +57,23 @@ class PortageDBMetadata(PMPackageMetadata):
 
 	@property
 	def CATEGORY(self):
-		return portage.versions.catsplit(self._cpv)[0]
+		return catsplit(self._cpv)[0]
 
 	@property
 	def PN(self):
-		return portage.versions.catpkgsplit(self._cpv)[1]
+		return catpkgsplit(self._cpv)[1]
 
 	@property
 	def PV(self):
-		return portage.versions.pkgsplit(self._cpv)[1]
+		return pkgsplit(self._cpv)[1]
 
 	@property
 	def PR(self):
-		return portage.versions.pkgsplit(self._cpv)[2]
+		return pkgsplit(self._cpv)[2]
 
 	@property
 	def PVR(self):
-		return portage.versions.cpv_getversion(self._cpv)
+		return cpv_getversion(self._cpv)
 
 class PortageMetadata(PortageDBMetadata):
 	def __init__(self, cpv, dbapi, tree):

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index aece5f6..7f4590d 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -44,9 +44,10 @@ class PortageRepository(PortDBRepository, PMEbuildRepository):
 
 	def __iter__(self):
 		path = self.path
+		prio = self._repo.priority
 		for cp in self._dbapi.cp_all(trees = (path,)):
 			for p in self._dbapi.cp_list(cp, mytree = path):
-				yield PortageCPV(p, self._dbapi, path)
+				yield PortageCPV(p, self._dbapi, path, prio)
 
 	@property
 	def name(self):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-07  9:51 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-07  9:51 UTC (permalink / raw
  To: gentoo-commits

commit:     efa68f8b8245672705833df3f9255831b066d65b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  7 09:52:02 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul  7 09:52:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=efa68f8b

Fix portage dbapi interface.

---
 gentoopm/portagepm/pkg.py  |    8 ++++----
 gentoopm/portagepm/repo.py |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 0163bee..ca2c054 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -24,6 +24,10 @@ class PortageDBCPV(PMPackage):
 		return self._dbapi.getpath(self._cpv)
 
 	@property
+	def key(self):
+		return cpv_getkey(self._cpv)
+
+	@property
 	def id(self):
 		return self._cpv
 
@@ -42,10 +46,6 @@ class PortageCPV(PortageDBCPV):
 		return self._dbapi.findname(self._cpv, self._tree)
 
 	@property
-	def key(self):
-		return cpv_getkey(self._cpv)
-
-	@property
 	def id(self):
 		return '%s::%s' % (self._cpv, self._dbapi.getRepositoryName(self._tree))
 

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index 7f4590d..e1f6cd9 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -7,7 +7,7 @@ import os.path
 
 from gentoopm.basepm.repo import PMRepositoryDict, PMEbuildRepository, \
 		PMRepository
-from gentoopm.portagepm.pkg import PortageCPV
+from gentoopm.portagepm.pkg import PortageCPV, PortageDBCPV
 
 class PortageRepoDict(PMRepositoryDict):
 	def __iter__(self):
@@ -35,7 +35,7 @@ class PortDBRepository(PMRepository):
 
 	def __iter__(self):
 		for p in self._dbapi.cpv_all(): # XXX
-			yield PortageCPV(p, self._dbapi)
+			yield PortageDBCPV(p, self._dbapi)
 
 class PortageRepository(PortDBRepository, PMEbuildRepository):
 	def __init__(self, repo_obj, portdbapi):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-08  7:18 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-08  7:18 UTC (permalink / raw
  To: gentoo-commits

commit:     437025a128f7b79e4fa2e1ef4cf4991dcc4ceb7b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  8 06:48:53 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul  8 06:48:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=437025a1

Portage: use unevaluated atoms.

Instead of expanding atoms to categories, just don't match on category.

---
 gentoopm/portagepm/atom.py |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index 5c5ca69..ccd272f 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -10,18 +10,20 @@ from portage.versions import catsplit
 
 from gentoopm.basepm.atom import PMAtom
 
-class PortageAtom(PMAtom):
-	def __init__(self, s, pm):
+class PortageAtom(object):
+	def __new__(self, s, pm):
 		try:
-			a = dep_expand(s, mydb = pm._portdb,
-					settings = pm._portdb.settings)
-		except pe.AmbiguousPackageName:
-			raise KeyError('Ambiguous atom: %s' % s)
+			a = dep_expand(s, settings = pm._portdb.settings)
 		except pe.InvalidAtom:
 			raise ValueError('Incorrect atom: %s' % s)
 
 		if catsplit(a.cp)[0] == 'null':
-			raise KeyError('Unable to expand atom: %s' % s)
+			return UnexpandedPortageAtom(a)
+		else:
+			return CompletePortageAtom(a)
+
+class CompletePortageAtom(PMAtom):
+	def __init__(self, a):
 		self._atom = a
 
 	def __contains__(self, pkg):
@@ -30,3 +32,21 @@ class PortageAtom(PMAtom):
 			return False
 		return not self._atom.slot \
 				or self._atom.slot == pkg.metadata.SLOT
+
+class UncategorisedPackageWrapper(object):
+	def __init__(self, pkg):
+		self._pkg = pkg
+
+	@property
+	def id(self):
+		cpv = self._pkg.id
+		return 'null/%s' % catsplit(cpv)[1]
+				
+class UnexpandedPortageAtom(CompletePortageAtom):
+	"""
+	An atom without a category specified.
+	"""
+
+	def __contains__(self, pkg):
+		return CompletePortageAtom.__contains__(self,
+				UncategorisedPackageWrapper(pkg))



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-10 22:17 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-10 22:17 UTC (permalink / raw
  To: gentoo-commits

commit:     f0aa995bc1ce334da4ec5674ea947ceb87d378dd
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 10 21:50:57 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 21:50:57 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=f0aa995b

Portage: support overriding PMPackageSet.

---
 gentoopm/portagepm/pkg.py  |   10 +++++++++-
 gentoopm/portagepm/repo.py |    4 ++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index d2ea1ad..938d4a9 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -7,7 +7,15 @@ from portage.versions import cpv_getkey, cpv_getversion, vercmp, \
 		catsplit, catpkgsplit, pkgsplit
 
 from gentoopm.basepm.metadata import PMPackageMetadata
-from gentoopm.basepm.pkg import PMPackage
+from gentoopm.basepm.pkg import PMPackage, PMPackageSet, \
+		PMFilteredPackageSet
+
+class PortagePackageSet(PMPackageSet):
+	def filter(self, *args, **kwargs):
+		return PortageFilteredPackageSet(self, args, kwargs)
+
+class PortageFilteredPackageSet(PortagePackageSet, PMFilteredPackageSet):
+	pass
 
 class PortageDBCPV(PMPackage):
 	def __init__(self, cpv, dbapi):

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index e1f6cd9..87d8edc 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -7,7 +7,7 @@ import os.path
 
 from gentoopm.basepm.repo import PMRepositoryDict, PMEbuildRepository, \
 		PMRepository
-from gentoopm.portagepm.pkg import PortageCPV, PortageDBCPV
+from gentoopm.portagepm.pkg import PortageCPV, PortageDBCPV, PortagePackageSet
 
 class PortageRepoDict(PMRepositoryDict):
 	def __iter__(self):
@@ -29,7 +29,7 @@ class PortageRepoDict(PMRepositoryDict):
 	def __init__(self, portdbapi):
 		self._dbapi = portdbapi
 
-class PortDBRepository(PMRepository):
+class PortDBRepository(PortagePackageSet, PMRepository):
 	def __init__(self, dbapi):
 		self._dbapi = dbapi
 



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-10 22:17 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-10 22:17 UTC (permalink / raw
  To: gentoo-commits

commit:     3e8b0067791e55c4a28c6a0a275e55f0eb7d21a9
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 10 21:53:44 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 22:16:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=3e8b0067

Portage: Pass FakeSettings to instantiate atoms without dbapi.

---
 gentoopm/portagepm/__init__.py |    2 +-
 gentoopm/portagepm/atom.py     |   14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gentoopm/portagepm/__init__.py b/gentoopm/portagepm/__init__.py
index 4b1887a..6bade14 100644
--- a/gentoopm/portagepm/__init__.py
+++ b/gentoopm/portagepm/__init__.py
@@ -32,4 +32,4 @@ class PortagePM(PackageManager):
 
 	@property
 	def Atom(self):
-		return functools.partial(PortageAtom, pm = self)
+		return PortageAtom

diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index 121e3b1..7614298 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -3,6 +3,8 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+import collections
+
 import portage.exception as pe
 from portage.dbapi.dep_expand import dep_expand
 from portage.dep import match_from_list
@@ -11,10 +13,18 @@ from portage.versions import catsplit
 from gentoopm.basepm.atom import PMAtom
 from gentoopm.exceptions import InvalidAtomStringError
 
+class FakeSettings(object):
+	"""
+	Fake settings object, to satisfy cpv_expand().
+	"""
+
+	def __getattr__(self, key):
+		return lambda: collections.defaultdict(lambda: '')
+
 class PortageAtom(object):
-	def __new__(self, s, pm):
+	def __new__(self, s):
 		try:
-			a = dep_expand(s, settings = pm._portdb.settings)
+			a = dep_expand(s, settings = FakeSettings())
 		except pe.InvalidAtom:
 			raise InvalidAtomStringError('Incorrect atom: %s' % s)
 



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-10 22:17 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-10 22:17 UTC (permalink / raw
  To: gentoo-commits

commit:     437218ffb7a8315e13f322305504f3bfdc1c7a06
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 10 22:05:12 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 22:17:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=437218ff

Portage: support transforming filter strings to atoms.

---
 gentoopm/portagepm/pkg.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 938d4a9..406ded4 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -9,10 +9,14 @@ from portage.versions import cpv_getkey, cpv_getversion, vercmp, \
 from gentoopm.basepm.metadata import PMPackageMetadata
 from gentoopm.basepm.pkg import PMPackage, PMPackageSet, \
 		PMFilteredPackageSet
+from gentoopm.portagepm.atom import PortageAtom
 
 class PortagePackageSet(PMPackageSet):
 	def filter(self, *args, **kwargs):
-		return PortageFilteredPackageSet(self, args, kwargs)
+		newargs = [(a if not isinstance(a, basestring)
+			else PortageAtom(a)) for a in args]
+
+		return PortageFilteredPackageSet(self, newargs, kwargs)
 
 class PortageFilteredPackageSet(PortagePackageSet, PMFilteredPackageSet):
 	pass



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-14 13:31 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-14 13:31 UTC (permalink / raw
  To: gentoo-commits

commit:     f11045c9630fe5519a414c13268646abaf03dc62
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 12:43:59 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 12:43:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=f11045c9

Portage: disallow incomplete yet associated atoms.

---
 gentoopm/portagepm/atom.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index fbd42d3..e98de4d 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -29,7 +29,8 @@ class PortageAtom(object):
 			raise InvalidAtomStringError('Incorrect atom: %s' % s)
 
 		if catsplit(a.cp)[0] == 'null':
-			return UnexpandedPortageAtom(a, pkg)
+			assert(pkg is None)
+			return UnexpandedPortageAtom(a)
 		else:
 			return CompletePortageAtom(a, pkg)
 



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-14 14:05 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-14 14:05 UTC (permalink / raw
  To: gentoo-commits

commit:     a561d3cff13fb1ee090fc57c5c7db131b203274d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 13:58:08 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 13:59:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=a561d3cf

Portage: fix getting package atom.

---
 gentoopm/portagepm/atom.py |    2 +-
 gentoopm/portagepm/pkg.py  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index 6e28d3c..f68d136 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -35,7 +35,7 @@ class PortageAtom(object):
 			return CompletePortageAtom(a, pkg)
 
 class CompletePortageAtom(PMAtom):
-	def __init__(self, a, pkg):
+	def __init__(self, a, pkg = None):
 		self._atom = a
 		self._pkg = pkg
 

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index ff80ae5..c7212f9 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -45,7 +45,7 @@ class PortageDBCPV(PMPackage):
 
 	@property
 	def atom(self):
-		return PkgCoreAtom('=%s' % self.id, self)
+		return PortageAtom('=%s' % self.id, self)
 
 class PortageCPV(PortageDBCPV):
 	def __init__(self, cpv, dbapi, tree, repo_prio):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-15  8:39 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-15  8:39 UTC (permalink / raw
  To: gentoo-commits

commit:     d96f83f3a431c47a8c025e8978d07b5970ecf0ee
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 07:11:20 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 08:37:33 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=d96f83f3

Portage: use match() / xmatch() for faster Atom matching.

---
 gentoopm/portagepm/repo.py |  112 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 111 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index 87d8edc..c8e55f5 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -5,9 +5,14 @@
 
 import os.path
 
+import portage.exception as pe
+from portage.versions import catsplit
+
 from gentoopm.basepm.repo import PMRepositoryDict, PMEbuildRepository, \
 		PMRepository
-from gentoopm.portagepm.pkg import PortageCPV, PortageDBCPV, PortagePackageSet
+from gentoopm.portagepm.atom import PortageAtom, CompletePortageAtom
+from gentoopm.portagepm.pkg import PortageCPV, PortageDBCPV, PortagePackageSet, \
+		PortageFilteredPackageSet
 
 class PortageRepoDict(PMRepositoryDict):
 	def __iter__(self):
@@ -29,6 +34,38 @@ class PortageRepoDict(PMRepositoryDict):
 	def __init__(self, portdbapi):
 		self._dbapi = portdbapi
 
+class PortageFilteredDBRepo(PortageFilteredPackageSet):
+	def __init__(self, repo, atom):
+		self._dbapi = repo._dbapi
+		self._atom = atom._atom
+
+	@property
+	def _stringified_atom(self):
+		a = str(self._atom)
+		return a.replace('null/', '')
+
+	def __iter__(self):
+		a = self._stringified_atom
+		try:
+			it = self._dbapi.match(a)
+		except pe.AmbiguousPackageName as e:
+			for pkgcand in e.args[0]:
+				for p in PortageHackedFilteredDBRepo(self, pkgcand):
+					yield p
+		else:
+			for p in it:
+				yield PortageDBCPV(p, self._dbapi)
+
+class PortageHackedFilteredDBRepo(PortageFilteredDBRepo):
+	def __init__(self, repo, pkgcand):
+		cat = catsplit(pkgcand)[0]
+		self._atom = str(repo._atom).replace('null/', '%s/' % cat)
+		self._dbapi = repo._dbapi
+
+	@property
+	def _stringified_atom(self):
+		return self._atom
+
 class PortDBRepository(PortagePackageSet, PMRepository):
 	def __init__(self, dbapi):
 		self._dbapi = dbapi
@@ -37,6 +74,77 @@ class PortDBRepository(PortagePackageSet, PMRepository):
 		for p in self._dbapi.cpv_all(): # XXX
 			yield PortageDBCPV(p, self._dbapi)
 
+	_filtered_subclass = PortageFilteredDBRepo
+	def filter(self, *args, **kwargs):
+		newargs = []
+		filt = None
+		for a in args:
+			if isinstance(a, basestring):
+				a = PortageAtom(a)
+			if isinstance(a, CompletePortageAtom) and filt is None:
+				filt = a
+			else:
+				newargs.append(a)
+
+		pset = self
+		if filt:
+			pset = self._filtered_subclass(pset, filt)
+		if newargs or kwargs:
+			pset = PortageFilteredPackageSet(pset, newargs, kwargs)
+		return pset
+
+class PortageFilteredRepo(PortageFilteredDBRepo):
+	def __init__(self, repo, atom):
+		PortageFilteredDBRepo.__init__(self, repo, atom)
+		self._name = repo.name
+		self._path = repo.path
+		self._prio = repo._repo.priority
+
+	def __iter__(self):
+		if self._atom.repo is not None:
+			if self._atom.repo != self._name:
+				return
+			a = self._stringified_atom
+		else:
+			a = '%s::%s' % (self._stringified_atom, self._name)
+
+		try:
+			it = self._dbapi.xmatch("match-all", a)
+		except pe.AmbiguousPackageName as e:
+			for pkgcand in e.args[0]:
+				for p in PortageHackedFilteredRepo(self, pkgcand):
+					yield p
+		else:
+			for p in it:
+				yield PortageCPV(p, self._dbapi, self._path, self._prio)
+
+class PortageHackedAtom(object):
+	def __init__(self, s, repo):
+		self._s = s
+		self._repo = repo
+
+	@property
+	def repo(self):
+		return self._repo
+
+	def __str__(self):
+		return self._s
+
+class PortageHackedFilteredRepo(PortageFilteredRepo):
+	def __init__(self, repo, pkgcand):
+		cat = catsplit(pkgcand)[0]
+		self._atom = PortageHackedAtom(
+				str(repo._atom).replace('null/', '%s/' % cat),
+				repo._atom.repo)
+		self._dbapi = repo._dbapi
+		self._path = repo._path
+		self._prio = repo._prio
+		self._name = repo._name
+
+	@property
+	def _stringified_atom(self):
+		return str(self._atom)
+
 class PortageRepository(PortDBRepository, PMEbuildRepository):
 	def __init__(self, repo_obj, portdbapi):
 		self._repo = repo_obj
@@ -49,6 +157,8 @@ class PortageRepository(PortDBRepository, PMEbuildRepository):
 			for p in self._dbapi.cp_list(cp, mytree = path):
 				yield PortageCPV(p, self._dbapi, path, prio)
 
+	_filtered_subclass = PortageFilteredRepo
+
 	@property
 	def name(self):
 		return self._repo.name



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-15 12:34 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-15 12:34 UTC (permalink / raw
  To: gentoo-commits

commit:     5926e3961f86e2047749579e2db8522ba3b94d11
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 11:21:30 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 11:21:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=5926e396

Portage: support atom comparison in vardb.

---
 gentoopm/portagepm/pkg.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index b4ae7a6..67f4c55 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -47,6 +47,13 @@ class PortageDBCPV(PMPackage):
 	def atom(self):
 		return PortageAtom('=%s' % self.id, self)
 
+	def __cmp__(self, other):
+		if not isinstance(other, PortageDBCPV):
+			raise TypeError('Unable to compare %s against %s' % \
+					(self, other))
+		return cmp(cpv_getkey(self._cpv), cpv_getkey(other._cpv)) \
+				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv))
+
 class PortageCPV(PortageDBCPV):
 	def __init__(self, cpv, dbapi, tree, repo_prio):
 		PortageDBCPV.__init__(self, cpv, dbapi)



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-15 13:32 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-15 13:32 UTC (permalink / raw
  To: gentoo-commits

commit:     6fe4e2093009d6e50a542fb4b1e6547ddca01bba
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 15 13:18:53 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 15 13:18:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=6fe4e209

Portage: use rich comparisons.

---
 gentoopm/portagepm/pkg.py  |   14 +++++++-------
 gentoopm/portagepm/repo.py |    4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 67f4c55..90db650 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -47,12 +47,12 @@ class PortageDBCPV(PMPackage):
 	def atom(self):
 		return PortageAtom('=%s' % self.id, self)
 
-	def __cmp__(self, other):
+	def __lt__(self, other):
 		if not isinstance(other, PortageDBCPV):
 			raise TypeError('Unable to compare %s against %s' % \
 					(self, other))
-		return cmp(cpv_getkey(self._cpv), cpv_getkey(other._cpv)) \
-				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv))
+		return cpv_getkey(self._cpv) < cpv_getkey(other._cpv) \
+				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) < 0
 
 class PortageCPV(PortageDBCPV):
 	def __init__(self, cpv, dbapi, tree, repo_prio):
@@ -72,13 +72,13 @@ class PortageCPV(PortageDBCPV):
 	def id(self):
 		return '%s::%s' % (self._cpv, self._dbapi.getRepositoryName(self._tree))
 
-	def __cmp__(self, other):
+	def __lt__(self, other):
 		if not isinstance(other, PortageCPV):
 			raise TypeError('Unable to compare %s against %s' % \
 					(self, other))
-		return cmp(cpv_getkey(self._cpv), cpv_getkey(other._cpv)) \
-				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) \
-				or cmp(self._repo_prio, other._repo_prio)
+		return cpv_getkey(self._cpv) < cpv_getkey(other._cpv) \
+				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) < 0 \
+				or self._repo_prio < other._repo_prio
 
 class PortageDBMetadata(PMPackageMetadata):
 	def __init__(self, cpv, dbapi):

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index d3cd9c6..ecfaf30 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -167,8 +167,8 @@ class PortageRepository(PortDBRepository, PMEbuildRepository):
 	def path(self):
 		return self._repo.location
 
-	def __cmp__(self, other):
-		return cmp(self._repo.priority, other._repo.priority)
+	def __lt__(self, other):
+		return self._repo.priority < other._repo.priority
 
 class VDBRepository(PortDBRepository):
 	pass



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-19 20:53 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-19 20:53 UTC (permalink / raw
  To: gentoo-commits

commit:     37d1d97fa2a85b2901043921e51ee70db19921b3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 19 20:51:18 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 19 20:51:18 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=37d1d97f

Portage: return tuple in _aux_get() only when necessary.

---
 gentoopm/portagepm/pkg.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index e8bf6b5..9f3748e 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -63,7 +63,11 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 		return PortagePackageVersion(self._cpv)
 
 	def _aux_get(self, *keys):
-		return self._dbapi.aux_get(self._cpv, keys)
+		val = self._dbapi.aux_get(self._cpv, keys)
+		if len(keys) == 1:
+			return val[0]
+		else:
+			return tuple(val)
 
 	@property
 	def description(self):
@@ -116,8 +120,12 @@ class PortageCPV(PortageDBCPV):
 		return StringWrapper(self._dbapi.getRepositoryName(self._tree))
 
 	def _aux_get(self, *keys):
-		return self._dbapi.aux_get(self._cpv, keys,
+		val = self._dbapi.aux_get(self._cpv, keys,
 				mytree = self._tree)
+		if len(keys) == 1:
+			return val[0]
+		else:
+			return tuple(val)
 
 	def __str__(self):
 		return '=%s::%s' % (self._cpv, self.repository)
@@ -137,4 +145,4 @@ class PortageMetadata(PMPackageMetadata):
 	def __getattr__(self, key):
 		if key not in self:
 			raise AttributeError('Unsupported metadata key: %s' % key)
-		return self._pkg._aux_get(key)[0]
+		return self._pkg._aux_get(key)



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-19 20:53 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-19 20:53 UTC (permalink / raw
  To: gentoo-commits

commit:     e6df986948b56087b4ab23375079c92796d36dc2
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 19 20:53:06 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 19 20:53:06 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e6df9869

Portage: use _aux_get(), not metadata in new properties.

---
 gentoopm/portagepm/pkg.py |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 9f3748e..135a271 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -23,12 +23,12 @@ class PortageFilteredPackageSet(PortagePackageSet, PMFilteredPackageSet):
 	pass
 
 class PortagePackageDescription(PMPackageDescription):
-	def __init__(self, meta):
-		self._meta = meta
+	def __init__(self, pkg):
+		self._pkg = pkg
 
 	@property
 	def short(self):
-		return StringWrapper(self._meta['DESCRIPTION'])
+		return StringWrapper(self._pkg._aux_get['DESCRIPTION'])
 
 	@property
 	def long(self):
@@ -71,11 +71,11 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 
 	@property
 	def description(self):
-		return PortagePackageDescription(self.metadata) # XXX
+		return PortagePackageDescription(self)
 
 	@property
 	def slot(self):
-		return StringWrapper(self.metadata['SLOT']) # XXX
+		return StringWrapper(self._aux_get('SLOT'))
 
 	@property
 	def repository(self):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-19 20:53 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-19 20:53 UTC (permalink / raw
  To: gentoo-commits

commit:     6dcdf3633237cd1d98d064a4df0d1fc8e83c5af5
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 19 20:53:23 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 19 20:53:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=6dcdf363

Portage: return None as repository for installed pkgs.

---
 gentoopm/portagepm/pkg.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 135a271..e3e9c38 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -79,7 +79,7 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 
 	@property
 	def repository(self):
-		raise NotImplementedError() # XXX
+		raise None
 
 	@property
 	def slotted(self):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-19 20:53 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-19 20:53 UTC (permalink / raw
  To: gentoo-commits

commit:     eb76b8c4e201184e51e4cdf169b971e6cb3ddae4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 19 20:35:26 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 19 20:35:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=eb76b8c4

Portage: move _aux_get() wrapper directly to Portage{,DB}CPV.

---
 gentoopm/portagepm/pkg.py |   33 ++++++++++++---------------------
 1 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index b421596..e8bf6b5 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -47,7 +47,7 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 
 	@property
 	def metadata(self):
-		return PortageDBMetadata(self._cpv, self._dbapi)
+		return PortageMetadata(self)
 
 	@property
 	def path(self):
@@ -62,6 +62,9 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 	def version(self):
 		return PortagePackageVersion(self._cpv)
 
+	def _aux_get(self, *keys):
+		return self._dbapi.aux_get(self._cpv, keys)
+
 	@property
 	def description(self):
 		return PortagePackageDescription(self.metadata) # XXX
@@ -105,10 +108,6 @@ class PortageCPV(PortageDBCPV):
 		self._repo_prio = repo_prio
 
 	@property
-	def metadata(self):
-		return PortageMetadata(self._cpv, self._dbapi, self._tree)
-
-	@property
 	def path(self):
 		return StringWrapper(self._dbapi.findname(self._cpv, self._tree))
 
@@ -116,6 +115,10 @@ class PortageCPV(PortageDBCPV):
 	def repository(self):
 		return StringWrapper(self._dbapi.getRepositoryName(self._tree))
 
+	def _aux_get(self, *keys):
+		return self._dbapi.aux_get(self._cpv, keys,
+				mytree = self._tree)
+
 	def __str__(self):
 		return '=%s::%s' % (self._cpv, self.repository)
 
@@ -127,23 +130,11 @@ class PortageCPV(PortageDBCPV):
 				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) < 0 \
 				or self._repo_prio < other._repo_prio
 
-class PortageDBMetadata(PMPackageMetadata):
-	def __init__(self, cpv, dbapi):
-		self._cpv = cpv
-		self._dbapi = dbapi
-
-	def __getattr__(self, key):
-		if key not in self:
-			raise AttributeError('Unsupported metadata key: %s' % key)
-		return self._dbapi.aux_get(self._cpv, [key])[0]
-
-class PortageMetadata(PortageDBMetadata):
-	def __init__(self, cpv, dbapi, tree):
-		PortageDBMetadata.__init__(self, cpv, dbapi)
-		self._tree = tree
+class PortageMetadata(PMPackageMetadata):
+	def __init__(self, pkg):
+		self._pkg = pkg
 
 	def __getattr__(self, key):
 		if key not in self:
 			raise AttributeError('Unsupported metadata key: %s' % key)
-		return self._dbapi.aux_get(self._cpv, [key],
-				mytree = self._tree)[0]
+		return self._pkg._aux_get(key)[0]



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-20  9:41 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-20  9:41 UTC (permalink / raw
  To: gentoo-commits

commit:     e205838a220bbc41143e4a8c012f0c9b5da9007e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 20 09:21:21 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 20 09:21:21 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e205838a

Portage: fix getting DESCRIPTION.

---
 gentoopm/portagepm/pkg.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 2c40611..88d3104 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -28,7 +28,7 @@ class PortagePackageDescription(PMPackageDescription):
 
 	@property
 	def short(self):
-		return StringWrapper(self._pkg._aux_get['DESCRIPTION'])
+		return StringWrapper(self._pkg._aux_get('DESCRIPTION'))
 
 	@property
 	def long(self):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-21  8:47 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-21  8:47 UTC (permalink / raw
  To: gentoo-commits

commit:     8f5be684faba3da99038b41148a85eaaf81d3f3e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 21 07:21:24 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 07:21:24 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=8f5be684

Portage: don't hardcode CPV classes in repo code.

---
 gentoopm/portagepm/repo.py |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index 19f4e85..b4c3fa6 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -4,6 +4,7 @@
 # Released under the terms of the 2-clause BSD license.
 
 import os.path
+from abc import abstractproperty
 
 import portage.exception as pe
 from portage.versions import catsplit
@@ -38,6 +39,7 @@ class PortageRepoDict(PMRepositoryDict):
 class PortageFilteredDBRepo(PortageFilteredPackageSet):
 	def __init__(self, repo, atom):
 		self._dbapi = repo._dbapi
+		self._pkg_class = repo._pkg_class
 		self._atom = atom._atom
 
 	@property
@@ -55,13 +57,14 @@ class PortageFilteredDBRepo(PortageFilteredPackageSet):
 					yield p
 		else:
 			for p in it:
-				yield PortageDBCPV(p, self._dbapi)
+				yield self._pkg_class(p, self._dbapi)
 
 class PortageHackedFilteredDBRepo(PortageFilteredDBRepo):
 	def __init__(self, repo, pkgcand):
 		cat = catsplit(pkgcand)[0]
 		self._atom = str(repo._atom).replace('null/', '%s/' % cat)
 		self._dbapi = repo._dbapi
+		self._pkg_class = repo._pkg_class
 
 	@property
 	def _stringified_atom(self):
@@ -71,9 +74,13 @@ class PortDBRepository(PortagePackageSet, PMRepository):
 	def __init__(self, dbapi):
 		self._dbapi = dbapi
 
+	@abstractproperty
+	def _pkg_class(self):
+		pass
+
 	def __iter__(self):
 		for p in self._dbapi.cpv_all(): # XXX
-			yield PortageDBCPV(p, self._dbapi)
+			yield self._pkg_class(p, self._dbapi)
 
 	_filtered_subclass = PortageFilteredDBRepo
 	def filter(self, *args, **kwargs):
@@ -117,7 +124,7 @@ class PortageFilteredRepo(PortageFilteredDBRepo):
 					yield p
 		else:
 			for p in it:
-				yield PortageCPV(p, self._dbapi, self._path, self._prio)
+				yield self._pkg_class(p, self._dbapi, self._path, self._prio)
 
 class PortageHackedAtom(object):
 	def __init__(self, s, repo):
@@ -139,6 +146,7 @@ class PortageHackedFilteredRepo(PortageFilteredRepo):
 				repo._atom.repo)
 		self._dbapi = repo._dbapi
 		self._path = repo._path
+		self._pkg_class = repo._pkg_class
 		self._prio = repo._prio
 		self._name = repo._name
 
@@ -153,12 +161,13 @@ class PortageRepository(PortDBRepository, PMEbuildRepository,
 		self._repo = repo_obj
 		PortDBRepository.__init__(self, portdbapi)
 
+	_pkg_class = PortageCPV
 	def __iter__(self):
 		path = self.path
 		prio = self._repo.priority
 		for cp in self._dbapi.cp_all(trees = (path,)):
 			for p in self._dbapi.cp_list(cp, mytree = path):
-				yield PortageCPV(p, self._dbapi, path, prio)
+				yield self._pkg_class(p, self._dbapi, path, prio)
 
 	_filtered_subclass = PortageFilteredRepo
 
@@ -174,4 +183,4 @@ class PortageRepository(PortDBRepository, PMEbuildRepository,
 		return self._repo.priority < other._repo.priority
 
 class VDBRepository(PortDBRepository):
-	pass
+	_pkg_class = PortageDBCPV



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-21  8:47 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-21  8:47 UTC (permalink / raw
  To: gentoo-commits

commit:     38eccacf7cab5507f59ca5347a7d88b5e44fe857
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 21 07:23:45 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 07:23:45 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=38eccacf

Portage: introduce PortageVDBCPV, as a PMInstalledPackage subclass.

---
 gentoopm/portagepm/pkg.py  |    6 +++++-
 gentoopm/portagepm/repo.py |    4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 9874d07..e82b232 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -6,7 +6,8 @@
 from portage.versions import cpv_getkey, cpv_getversion, vercmp
 
 from gentoopm.basepm.metadata import PMPackageMetadata
-from gentoopm.basepm.pkg import PMPackage, PMPackageDescription
+from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
+		PMInstalledPackage
 from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.portagepm.atom import PortageAtom, CompletePortageAtom, \
 		PortagePackageKey, PortagePackageVersion, _get_atom
@@ -147,6 +148,9 @@ class PortageCPV(PortageDBCPV):
 				or vercmp(cpv_getversion(self._cpv), cpv_getversion(other._cpv)) < 0 \
 				or self._repo_prio < other._repo_prio
 
+class PortageVDBCPV(PortageDBCPV, PMInstalledPackage):
+	pass
+
 class PortageMetadata(PMPackageMetadata):
 	def __init__(self, pkg):
 		self._pkg = pkg

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index b4c3fa6..2486514 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -12,7 +12,7 @@ from portage.versions import catsplit
 from gentoopm.basepm.repo import PMRepositoryDict, PMEbuildRepository, \
 		PMRepository
 from gentoopm.portagepm.atom import PortageAtom, CompletePortageAtom
-from gentoopm.portagepm.pkg import PortageCPV, PortageDBCPV, PortagePackageSet, \
+from gentoopm.portagepm.pkg import PortageCPV, PortageVDBCPV, PortagePackageSet, \
 		PortageFilteredPackageSet
 from gentoopm.util import FillMissingComparisons
 
@@ -183,4 +183,4 @@ class PortageRepository(PortDBRepository, PMEbuildRepository,
 		return self._repo.priority < other._repo.priority
 
 class VDBRepository(PortDBRepository):
-	_pkg_class = PortageDBCPV
+	_pkg_class = PortageVDBCPV



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-25 17:06 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-25 17:06 UTC (permalink / raw
  To: gentoo-commits

commit:     bbe19987fc4d033ed60d0696ec3c88f1d183ca76
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 17:03:17 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=bbe19987

Portage: support getting package contents.

---
 gentoopm/portagepm/contents.py |   15 +++++++++++++++
 gentoopm/portagepm/pkg.py      |    5 ++++-
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/contents.py b/gentoopm/portagepm/contents.py
new file mode 100644
index 0000000..dcdecbe
--- /dev/null
+++ b/gentoopm/portagepm/contents.py
@@ -0,0 +1,15 @@
+#!/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, \
+		PMContentObj
+
+class PortagePackageContents(PMPackageContents):
+	def __init__(self, dblink):
+		self._dblink = dblink
+
+	def __iter__(self):
+		for f, details in self._dblink.getcontents().items():
+			yield PMContentObj(str(f))

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index a26bb45..d2ee87b 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -12,6 +12,7 @@ from gentoopm.basepm.pkg import PMPackage, PMPackageDescription, \
 from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.portagepm.atom import PortageAtom, CompletePortageAtom, \
 		PortagePackageKey, PortagePackageVersion, _get_atom
+from gentoopm.portagepm.contents import PortagePackageContents
 from gentoopm.util import SpaceSepTuple
 
 class PortagePackageSet(PMPackageSet):
@@ -159,7 +160,9 @@ class PortageCPV(PortageDBCPV, PMInstallablePackage):
 				or self._repo_prio < other._repo_prio
 
 class PortageVDBCPV(PortageDBCPV, PMInstalledPackage):
-	pass
+	@property
+	def contents(self):
+		return PortagePackageContents(self._dbapi._dblink(self._cpv))
 
 class PortageMetadata(PMPackageMetadata):
 	def __init__(self, pkg):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-26 17:18 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-26 17:18 UTC (permalink / raw
  To: gentoo-commits

commit:     3760928e4d4c083bba6539f628ea37a8d3c99729
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 17:19:10 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 17:19:10 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=3760928e

Portage: support a subset of dependency parsing.

---
 gentoopm/portagepm/depend.py |   42 ++++++++++++++++++++++++++++++++++++++++++
 gentoopm/portagepm/pkg.py    |   13 +++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
new file mode 100644
index 0000000..6c06693
--- /dev/null
+++ b/gentoopm/portagepm/depend.py
@@ -0,0 +1,42 @@
+#!/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 portage.dep import paren_reduce
+
+from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
+	PMOneOfDep, PMAllOfDep, PMBaseDep
+from gentoopm.portagepm.atom import CompletePortageAtom
+
+class PortageBaseDep(PMBaseDep):
+	def __init__(self, deps):
+		self._deps = deps
+
+	def __iter__(self):
+		it = iter(self._deps)
+		for d in it:
+			if d == '||':
+				yield PortageOneOfDep(next(it))
+			elif d == '&&':
+				yield PortageAllOfDep(next(it))
+			elif d.endswith('?'):
+				yield PortageConditionalUseDep(next(it))
+			else:
+				yield CompletePortageAtom(d)
+
+class PortageOneOfDep(PMOneOfDep, PortageBaseDep):
+	pass
+
+class PortageAllOfDep(PMAllOfDep, PortageBaseDep):
+	pass
+
+class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
+	@property
+	def enabled(self):
+		# XXX
+		raise NotImplementedError()
+
+class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
+	def __init__(self, s):
+		self._deps = paren_reduce(s)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index d2ee87b..9922af3 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -13,6 +13,7 @@ from gentoopm.basepm.pkgset import PMPackageSet, PMFilteredPackageSet
 from gentoopm.portagepm.atom import PortageAtom, CompletePortageAtom, \
 		PortagePackageKey, PortagePackageVersion, _get_atom
 from gentoopm.portagepm.contents import PortagePackageContents
+from gentoopm.portagepm.depend import PortagePackageDepSet
 from gentoopm.util import SpaceSepTuple
 
 class PortagePackageSet(PMPackageSet):
@@ -118,6 +119,18 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 	def _atom(self):
 		return _get_atom(str(self))
 
+	@property
+	def build_dependencies(self):
+		return PortagePackageDepSet(self._aux_get('DEPEND'))
+
+	@property
+	def run_dependencies(self):
+		return PortagePackageDepSet(self._aux_get('RDEPEND'))
+
+	@property
+	def post_dependencies(self):
+		return PortagePackageDepSet(self._aux_get('PDEPEND'))
+
 	def __str__(self):
 		return '=%s' % self._cpv
 



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-26 17:30 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-26 17:30 UTC (permalink / raw
  To: gentoo-commits

commit:     24f6819cffef1e48c2da4a8850e1b3944852d6d6
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 17:31:01 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 17:31:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=24f6819c

Portage: fix generating dependency atoms.

---
 gentoopm/portagepm/depend.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
index 6c06693..ac289d4 100644
--- a/gentoopm/portagepm/depend.py
+++ b/gentoopm/portagepm/depend.py
@@ -7,7 +7,7 @@ from portage.dep import paren_reduce
 
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
 	PMOneOfDep, PMAllOfDep, PMBaseDep
-from gentoopm.portagepm.atom import CompletePortageAtom
+from gentoopm.portagepm.atom import PortageAtom
 
 class PortageBaseDep(PMBaseDep):
 	def __init__(self, deps):
@@ -23,7 +23,7 @@ class PortageBaseDep(PMBaseDep):
 			elif d.endswith('?'):
 				yield PortageConditionalUseDep(next(it))
 			else:
-				yield CompletePortageAtom(d)
+				yield PortageAtom(d)
 
 class PortageOneOfDep(PMOneOfDep, PortageBaseDep):
 	pass



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-27  8:26 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-27  8:26 UTC (permalink / raw
  To: gentoo-commits

commit:     e91eb978fa051988af4707ff19b263bd2883f02b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 27 08:27:28 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 27 08:27:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e91eb978

Portage: support simple USE collapsing.

---
 gentoopm/portagepm/depend.py |   21 +++++++++++++--------
 gentoopm/portagepm/pkg.py    |   35 ++++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
index ac289d4..9421099 100644
--- a/gentoopm/portagepm/depend.py
+++ b/gentoopm/portagepm/depend.py
@@ -10,18 +10,20 @@ from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
 from gentoopm.portagepm.atom import PortageAtom
 
 class PortageBaseDep(PMBaseDep):
-	def __init__(self, deps):
+	def __init__(self, deps, puse):
 		self._deps = deps
+		self._puse = puse
 
 	def __iter__(self):
 		it = iter(self._deps)
 		for d in it:
 			if d == '||':
-				yield PortageOneOfDep(next(it))
+				yield PortageOneOfDep(next(it), self._puse)
 			elif d == '&&':
-				yield PortageAllOfDep(next(it))
+				yield PortageAllOfDep(next(it), self._puse)
 			elif d.endswith('?'):
-				yield PortageConditionalUseDep(next(it))
+				yield PortageConditionalUseDep(next(it),
+						self._puse, d.rstrip('?'))
 			else:
 				yield PortageAtom(d)
 
@@ -32,11 +34,14 @@ class PortageAllOfDep(PMAllOfDep, PortageBaseDep):
 	pass
 
 class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
+	def __init__(self, deps, puse, flag):
+		PortageBaseDep.__init__(self, deps, puse)
+		self._flag = flag
+
 	@property
 	def enabled(self):
-		# XXX
-		raise NotImplementedError()
+		return self._flag in self._puse
 
 class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
-	def __init__(self, s):
-		self._deps = paren_reduce(s)
+	def __init__(self, s, puse):
+		PortageBaseDep.__init__(self, paren_reduce(s), puse)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 39e4a59..a85f70d 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -128,16 +128,45 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 		return _get_atom(str(self))
 
 	@property
+	def _applied_use(self):
+		class LazyUseGetter(object):
+			def __init__(self, dbapi, cpv):
+				self._cpv = cpv
+				self._dbapi = dbapi
+				self._settings = dbapi.settings
+				self._use_cache = None
+
+			@property
+			def _use_set(self):
+				if self._use_cache is None:
+					s = self._settings.__class__(clone = self._settings)
+					# XXX: repos? _emerge.Package or compatible API?
+					s.setcpv(self._cpv, mydb = self._dbapi)
+					self._use_cache = frozenset(s['PORTAGE_USE'].split())
+				return self._use_cache
+
+			def __iter__(self):
+				return iter(self._use_set)
+
+			def __contains__(self, k):
+				return k in self._use_set
+
+		return LazyUseGetter(self._dbapi, self._cpv)
+
+	@property
 	def build_dependencies(self):
-		return PortagePackageDepSet(self._aux_get('DEPEND'))
+		return PortagePackageDepSet(self._aux_get('DEPEND'),
+				self._applied_use)
 
 	@property
 	def run_dependencies(self):
-		return PortagePackageDepSet(self._aux_get('RDEPEND'))
+		return PortagePackageDepSet(self._aux_get('RDEPEND'),
+				self._applied_use)
 
 	@property
 	def post_dependencies(self):
-		return PortagePackageDepSet(self._aux_get('PDEPEND'))
+		return PortagePackageDepSet(self._aux_get('PDEPEND'),
+				self._applied_use)
 
 	def __str__(self):
 		return '=%s' % self._cpv



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-27 16:04 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-27 16:04 UTC (permalink / raw
  To: gentoo-commits

commit:     00be1d0f47dbb2ea5e97f753b0356f0755ff2464
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 27 16:05:28 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 27 16:05:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=00be1d0f

Portage: support dropping conditionals using use_reduce().

---
 gentoopm/portagepm/depend.py |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
index 9421099..dd96664 100644
--- a/gentoopm/portagepm/depend.py
+++ b/gentoopm/portagepm/depend.py
@@ -3,7 +3,7 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-from portage.dep import paren_reduce
+from portage.dep import paren_reduce, use_reduce
 
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
 	PMOneOfDep, PMAllOfDep, PMBaseDep
@@ -44,4 +44,42 @@ class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
 
 class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
 	def __init__(self, s, puse):
-		PortageBaseDep.__init__(self, paren_reduce(s), puse)
+		self._depstr = s
+		PortageBaseDep.__init__(self, None, puse)
+
+	def __iter__(self):
+		if self._deps is None:
+			self._deps = paren_reduce(self._depstr)
+		return PortageBaseDep.__iter__(self)
+
+	@property
+	def without_conditionals(self):
+		return PortageUncondPackageDepSet(
+				use_reduce(self._depstr, self._puse))
+
+class PortageUncondDep(PortageBaseDep):
+	def __init__(self, deps):
+		self._deps = deps
+
+	@property
+	def without_conditionals(self):
+		return self
+
+	def __iter__(self):
+		it = iter(self._deps)
+		for d in it:
+			if d == '||':
+				yield PortageUncondOneOfDep(next(it))
+			elif d == '&&':
+				yield PortageUncondAllOfDep(next(it))
+			else:
+				yield PortageAtom(d)
+
+class PortageUncondOneOfDep(PMOneOfDep, PortageUncondDep):
+	pass
+
+class PortageUncondAllOfDep(PMAllOfDep, PortageUncondDep):
+	pass
+
+class PortageUncondPackageDepSet(PortageUncondDep):
+	pass



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-28 16:24 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-28 16:24 UTC (permalink / raw
  To: gentoo-commits

commit:     61f625081294e1948bfa23da71ace43f332cd4ce
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 28 14:53:28 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 28 14:53:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=61f62508

Portage: support '^^' in depstrings (using a hack).

---
 gentoopm/portagepm/depend.py |   22 ++++++++++++++++++----
 gentoopm/portagepm/pkg.py    |    5 +++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
index d4f3c33..f33fd5c 100644
--- a/gentoopm/portagepm/depend.py
+++ b/gentoopm/portagepm/depend.py
@@ -6,7 +6,7 @@
 from portage.dep import paren_reduce, use_reduce
 
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
-	PMAnyOfDep, PMAllOfDep, PMBaseDep
+	PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep
 from gentoopm.portagepm.atom import PortageAtom
 
 class PortageBaseDep(PMBaseDep):
@@ -21,6 +21,8 @@ class PortageBaseDep(PMBaseDep):
 				yield PortageAnyOfDep(next(it), self._puse)
 			elif d == '&&':
 				yield PortageAllOfDep(next(it), self._puse)
+			elif d == '__xor__?':
+				yield PortageExactlyOneOfDep(next(it), self._puse)
 			elif d.endswith('?'):
 				yield PortageConditionalUseDep(next(it),
 						self._puse, d.rstrip('?'))
@@ -33,6 +35,9 @@ class PortageAnyOfDep(PMAnyOfDep, PortageBaseDep):
 class PortageAllOfDep(PMAllOfDep, PortageBaseDep):
 	pass
 
+class PortageExactlyOneOfDep(PMExactlyOneOfDep, PortageBaseDep):
+	pass
+
 class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
 	def __init__(self, deps, puse, flag):
 		PortageBaseDep.__init__(self, deps, puse)
@@ -44,7 +49,11 @@ class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
 
 class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
 	def __init__(self, s, puse):
-		self._depstr = s
+		self._use_reducable = not '^^' in s
+		if not self._use_reducable:
+			# ARGV, paren_reduce() doesn't handle ^^
+			# so we hack it to a __xor__?, UGLY!
+			self._depstr = s.replace('^^', '__xor__?')
 		PortageBaseDep.__init__(self, None, puse)
 
 	def __iter__(self):
@@ -54,8 +63,10 @@ class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
 
 	@property
 	def without_conditionals(self):
-		return PortageUncondAllOfDep(
-				use_reduce(self._depstr, self._puse))
+		if self._use_reducable:
+			return PortageUncondAllOfDep(
+					use_reduce(self._depstr, self._puse))
+		return PMPackageDepSet.without_conditionals.fget(self)
 
 class PortageUncondDep(PortageBaseDep):
 	def __init__(self, deps):
@@ -80,3 +91,6 @@ class PortageUncondAnyOfDep(PMAnyOfDep, PortageUncondDep):
 
 class PortageUncondAllOfDep(PMAllOfDep, PortageUncondDep):
 	pass
+
+class PortageUncondExactlyOneOfDep(PMExactlyOneOfDep, PortageUncondDep):
+	pass

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index ed4c80c..221e728 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -183,6 +183,11 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 		return PortagePackageDepSet(self._aux_get('PDEPEND'),
 				self._applied_use)
 
+	@property
+	def required_use(self):
+		return PortagePackageDepSet(self._aux_get('REQUIRED_USE'),
+				self._applied_use)
+
 	def __str__(self):
 		return '=%s' % self._cpv
 



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-07-28 16:24 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-07-28 16:24 UTC (permalink / raw
  To: gentoo-commits

commit:     5d0ad77204be2449586c1829db33203ffab72f0a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 28 15:06:25 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jul 28 15:06:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=5d0ad772

Portage: support REQUIRED_USE.

---
 gentoopm/portagepm/depend.py |   47 ++++++++++++++++++++---------------------
 gentoopm/portagepm/pkg.py    |    8 +++---
 2 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
index f33fd5c..232a84b 100644
--- a/gentoopm/portagepm/depend.py
+++ b/gentoopm/portagepm/depend.py
@@ -3,31 +3,31 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+from collections import namedtuple
 from portage.dep import paren_reduce, use_reduce
 
 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
 	PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep
-from gentoopm.portagepm.atom import PortageAtom
 
 class PortageBaseDep(PMBaseDep):
-	def __init__(self, deps, puse):
+	def __init__(self, deps, args):
 		self._deps = deps
-		self._puse = puse
+		self._args = args
 
 	def __iter__(self):
 		it = iter(self._deps)
 		for d in it:
 			if d == '||':
-				yield PortageAnyOfDep(next(it), self._puse)
+				yield PortageAnyOfDep(next(it), self._args)
 			elif d == '&&':
-				yield PortageAllOfDep(next(it), self._puse)
+				yield PortageAllOfDep(next(it), self._args)
 			elif d == '__xor__?':
-				yield PortageExactlyOneOfDep(next(it), self._puse)
+				yield PortageExactlyOneOfDep(next(it), self._args)
 			elif d.endswith('?'):
 				yield PortageConditionalUseDep(next(it),
-						self._puse, d.rstrip('?'))
+						self._args, d.rstrip('?'))
 			else:
-				yield PortageAtom(d)
+				yield self._args.cls(d)
 
 class PortageAnyOfDep(PMAnyOfDep, PortageBaseDep):
 	pass
@@ -39,22 +39,23 @@ class PortageExactlyOneOfDep(PMExactlyOneOfDep, PortageBaseDep):
 	pass
 
 class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
-	def __init__(self, deps, puse, flag):
-		PortageBaseDep.__init__(self, deps, puse)
+	def __init__(self, deps, args, flag):
+		PortageBaseDep.__init__(self, deps, args)
 		self._flag = flag
 
 	@property
 	def enabled(self):
-		return self._flag in self._puse
+		return self._flag in self._args.puse
+
+_argtuple = namedtuple('PortageDepArgTuple', ('puse', 'cls'))
 
 class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
-	def __init__(self, s, puse):
+	def __init__(self, s, *args):
 		self._use_reducable = not '^^' in s
-		if not self._use_reducable:
-			# ARGV, paren_reduce() doesn't handle ^^
-			# so we hack it to a __xor__?, UGLY!
-			self._depstr = s.replace('^^', '__xor__?')
-		PortageBaseDep.__init__(self, None, puse)
+		# ARGV, paren_reduce() doesn't handle ^^
+		# so we hack it to a __xor__?, UGLY!
+		self._depstr = s.replace('^^', '__xor__?')
+		PortageBaseDep.__init__(self, None, _argtuple(*args))
 
 	def __iter__(self):
 		if self._deps is None:
@@ -65,13 +66,11 @@ class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
 	def without_conditionals(self):
 		if self._use_reducable:
 			return PortageUncondAllOfDep(
-					use_reduce(self._depstr, self._puse))
+					use_reduce(self._depstr, self._args.puse),
+					self._args)
 		return PMPackageDepSet.without_conditionals.fget(self)
 
 class PortageUncondDep(PortageBaseDep):
-	def __init__(self, deps):
-		self._deps = deps
-
 	@property
 	def without_conditionals(self):
 		return self
@@ -80,11 +79,11 @@ class PortageUncondDep(PortageBaseDep):
 		it = iter(self._deps)
 		for d in it:
 			if d == '||':
-				yield PortageUncondAnyOfDep(next(it))
+				yield PortageUncondAnyOfDep(next(it), self._args)
 			elif d == '&&':
-				yield PortageUncondAllOfDep(next(it))
+				yield PortageUncondAllOfDep(next(it), self._args)
 			else:
-				yield PortageAtom(d)
+				yield self._args.cls(d)
 
 class PortageUncondAnyOfDep(PMAnyOfDep, PortageUncondDep):
 	pass

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 221e728..5af125a 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -171,22 +171,22 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 	@property
 	def build_dependencies(self):
 		return PortagePackageDepSet(self._aux_get('DEPEND'),
-				self._applied_use)
+				self._applied_use, PortageAtom)
 
 	@property
 	def run_dependencies(self):
 		return PortagePackageDepSet(self._aux_get('RDEPEND'),
-				self._applied_use)
+				self._applied_use, PortageAtom)
 
 	@property
 	def post_dependencies(self):
 		return PortagePackageDepSet(self._aux_get('PDEPEND'),
-				self._applied_use)
+				self._applied_use, PortageAtom)
 
 	@property
 	def required_use(self):
 		return PortagePackageDepSet(self._aux_get('REQUIRED_USE'),
-				self._applied_use)
+				self._applied_use, str) # XXX
 
 	def __str__(self):
 		return '=%s' % self._cpv



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-08-12  7:28 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-08-12  7:28 UTC (permalink / raw
  To: gentoo-commits

commit:     a39d818cace9437b122ce1dd5d01d485138e44a0
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 12 07:28:24 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 12 07:28:24 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=a39d818c

Portage: don't use dbapi.repositories[], for 2.1.10.3.

---
 gentoopm/portagepm/repo.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index 2486514..e8f3464 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -27,7 +27,14 @@ class PortageRepoDict(PMRepositoryDict):
 				repo_name = self._dbapi.repositories.get_name_for_location(key)
 			else:
 				repo_name = key
-			r = self._dbapi.repositories[repo_name]
+			try:
+				r = self._dbapi.repositories[repo_name]
+			except TypeError: # older portage doesn't have __getitem__() here
+				for r in self._dbapi.repositories:
+					if r.name == repo_name:
+						break
+				else:
+					raise KeyError(repo_name)
 		except KeyError:
 			raise KeyError('No repository matched key %s' % key)
 		else:



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-08-14 14:22 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-08-14 14:22 UTC (permalink / raw
  To: gentoo-commits

commit:     3d1f5a4701c93aea3082ff84bf5de7ceb4a8ad83
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 14 13:42:04 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Aug 14 13:42:04 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=3d1f5a47

Portage: fix category-less atom matching.

---
 gentoopm/portagepm/atom.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index 2f95888..a6f2296 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -123,10 +123,14 @@ class UncategorisedPackageWrapper(object):
 		self._pkg = pkg
 
 	@property
-	def id(self):
-		cpv = self._pkg.id
+	def _cpv(self):
+		cpv = self._pkg._cpv
 		return 'null/%s' % catsplit(cpv)[1]
 
+	@property
+	def slot(self):
+		return self._pkg.slot
+
 class UnexpandedPortageAtom(CompletePortageAtom):
 	"""
 	An atom without a category specified.



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2011-08-15  7:57 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2011-08-15  7:57 UTC (permalink / raw
  To: gentoo-commits

commit:     61e764b816484e2215ce704e362c34feef050bf8
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 15 07:47:54 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug 15 07:47:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=61e764b8

Portage: fix incomplete package keys.

---
 gentoopm/portagepm/atom.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py
index 48b7e48..0edb241 100644
--- a/gentoopm/portagepm/atom.py
+++ b/gentoopm/portagepm/atom.py
@@ -24,7 +24,8 @@ class PortagePackageKey(PMPackageKey):
 		return catsplit(self)[1]
 
 class PortageIncompletePackageKey(PMIncompletePackageKey, PortagePackageKey):
-	pass
+	def __new__(self, key):
+		return PMIncompletePackageKey.__new__(self, catsplit(key)[1])
 
 class PortagePackageVersion(PMPackageVersion):
 	def __init__(self, cpv):



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2012-12-10 17:52 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2012-12-10 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     3b865a366bb1e2f22c7dc31ae181e3d0cf8a7c76
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 10 17:52:33 2012 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 10 17:52:33 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=3b865a36

Fix compatibility with PyPy.

It seems that exception arguments are held differently for some reason.

---
 gentoopm/portagepm/repo.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py
index 5d68120..6874757 100644
--- a/gentoopm/portagepm/repo.py
+++ b/gentoopm/portagepm/repo.py
@@ -126,7 +126,12 @@ class PortageFilteredRepo(PortageFilteredDBRepo):
 		try:
 			it = self._dbapi.xmatch("match-all", a)
 		except pe.AmbiguousPackageName as e:
-			for pkgcand in e.args[0]:
+			try:
+				candidates = e.args[0]
+			except IndexError: # pypy?
+				candidates = e.value
+
+			for pkgcand in candidates:
 				for p in PortageHackedFilteredRepo(self, pkgcand):
 					yield p
 		else:


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2013-02-03 19:40 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2013-02-03 19:40 UTC (permalink / raw
  To: gentoo-commits

commit:     91c5107fe89fd60caefd0c01cebb1506983ad6c4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  3 19:39:46 2013 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Feb  3 19:39:46 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=91c5107f

Fix all-of-deps handling in portage.

(API change?)

---
 gentoopm/portagepm/depend.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
index ce69cd2..a4614ce 100644
--- a/gentoopm/portagepm/depend.py
+++ b/gentoopm/portagepm/depend.py
@@ -17,7 +17,9 @@ class PortageBaseDep(PMBaseDep):
 	def __iter__(self):
 		it = iter(self._deps)
 		for d in it:
-			if d == '||':
+			if isinstance(d, list):
+				yield PortageAllOfDep(it, self._args)
+			elif d == '||':
 				yield PortageAnyOfDep(next(it), self._args)
 			elif d == '&&':
 				yield PortageAllOfDep(next(it), self._args)


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
@ 2013-02-16 10:13 Michał Górny
  0 siblings, 0 replies; 32+ messages in thread
From: Michał Górny @ 2013-02-16 10:13 UTC (permalink / raw
  To: gentoo-commits

commit:     d34c9cf0230c5b40c3d5837a6722dcce1ec53057
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 16 10:13:05 2013 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb 16 10:13:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=d34c9cf0

Fix package sorting in portage.

---
 gentoopm/portagepm/pkg.py |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 8ab00b4..d821bf8 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -217,7 +217,12 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
 		if not isinstance(other, PortageDBCPV):
 			raise TypeError('Unable to compare %s against %s' % \
 					(self, other))
-		return self.key < other.key or self.version < other.version
+
+		if self.key < other.key:
+			return True
+		if self.key == other.key:
+			return self.version < other.version
+		return False
 
 class PortageCPV(PortageDBCPV, PMInstallablePackage):
 	def __init__(self, cpv, dbapi, tree, repo_prio):
@@ -252,8 +257,15 @@ class PortageCPV(PortageDBCPV, PMInstallablePackage):
 		if not isinstance(other, PortageCPV):
 			raise TypeError('Unable to compare %s against %s' % \
 					(self, other))
-		return self.key < other.key or self.version < other.version \
-				or self._repo_prio < other._repo_prio
+
+		if self.key < other.key:
+			return True
+		if self.key == other.key:
+			if self.version < other.version:
+				return True
+			if self.version == other.version:
+				return self._repo_prio < other._repo_prio
+		return False
 
 class PortageVDBCPV(PortageDBCPV, PMInstalledPackage):
 	@property


^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2013-02-16 10:13 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-26 17:30 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/ Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2013-02-16 10:13 Michał Górny
2013-02-03 19:40 Michał Górny
2012-12-10 17:52 Michał Górny
2011-08-15  7:57 Michał Górny
2011-08-14 14:22 Michał Górny
2011-08-12  7:28 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-27 16:04 Michał Górny
2011-07-27  8:26 Michał Górny
2011-07-26 17:18 Michał Górny
2011-07-25 17:06 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-20  9:41 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-15 13:32 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15  8:39 Michał Górny
2011-07-14 14:05 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-08  7:18 Michał Górny
2011-07-07  9:51 Michał Górny
2011-07-06 20:54 Michał Górny
2011-07-06 16:03 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