public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/paludispm/
Date: Fri,  8 Jul 2011 16:37:37 +0000 (UTC)	[thread overview]
Message-ID: <b0572d4b95f033e6f1d9c360e8d60fa0828e5d8a.mgorny@gentoo> (raw)

commit:     b0572d4b95f033e6f1d9c360e8d60fa0828e5d8a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  8 16:38:07 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul  8 16:38:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=b0572d4b

Paludis: don't sort if sorted already.

---
 gentoopm/paludispm/pkg.py  |   26 +++++++++++++++++++++++++-
 gentoopm/paludispm/repo.py |    3 ++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gentoopm/paludispm/pkg.py b/gentoopm/paludispm/pkg.py
index 923376e..5f40984 100644
--- a/gentoopm/paludispm/pkg.py
+++ b/gentoopm/paludispm/pkg.py
@@ -10,11 +10,35 @@ from gentoopm.basepm.pkg import PMPackageSet, PMPackage, \
 		PMFilteredPackageSet
 
 class PaludisPackageSet(PMPackageSet):
+	_sorted = False
+
 	def filter(self, *args, **kwargs):
 		return PaludisFilteredPackageSet(self, args, kwargs)
 
+	@property
+	def best(self):
+		if self._sorted:
+			it = iter(self)
+
+			try:
+				f = next(it)
+			except StopIteration:
+				raise TypeError('.best called on an empty set')
+			for p in it:
+				if p.key != f.key:
+					raise KeyError('.best called on a set of differently-named packages')
+
+			try:
+				return p
+			except NameError:
+				return f
+		else:
+			return PMPackageSet.best.fget(self)
+
 class PaludisFilteredPackageSet(PMFilteredPackageSet, PaludisPackageSet):
-	pass
+	def __init__(self, pset, args, kwargs):
+		self._sorted = pset._sorted
+		PMFilteredPackageSet.__init__(self, pset, args, kwargs)
 
 class PaludisID(PMPackage):
 	def __init__(self, pkg, num = 0, enum_id = None):

diff --git a/gentoopm/paludispm/repo.py b/gentoopm/paludispm/repo.py
index 217242f..0a884fd 100644
--- a/gentoopm/paludispm/repo.py
+++ b/gentoopm/paludispm/repo.py
@@ -24,6 +24,7 @@ class PaludisEnumID(object):
 class PaludisRepository(PMRepository, PaludisPackageSet):
 	def __init__(self, env):
 		self._env = env
+		self._sorted = True
 
 	def __iter__(self):
 		enum = PaludisEnumID()
@@ -44,7 +45,7 @@ class PaludisStackRepo(PaludisRepository):
 
 class PaludisLivefsRepository(PaludisRepository, PMEbuildRepository):
 	def __init__(self, repo_obj, env):
-		self._env = env
+		PaludisRepository.__init__(self, env)
 		self._repo = repo_obj
 
 	@property



             reply	other threads:[~2011-07-08 16:37 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-08 16:37 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-10-10 13:35 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/paludispm/ Michał Górny
2012-01-03 18:18 Michał Górny
2011-12-09 15:09 Michał Górny
2011-07-29  6:38 Michał Górny
2011-07-28 19:54 Michał Górny
2011-07-28 19:54 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-25 17:06 Michał Górny
2011-07-23 20:14 Michał Górny
2011-07-23 20:14 Michał Górny
2011-07-23 20:14 Michał Górny
2011-07-23  9:27 Michał Górny
2011-07-22  6:18 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-21  8:47 Michał Górny
2011-07-16 22:55 Michał Górny
2011-07-16 22:55 Michał Górny
2011-07-16  9:40 Michał Górny
2011-07-16  9:08 Michał Górny
2011-07-16  8:34 Michał Górny
2011-07-15 13:32 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15  9:52 Michał Górny
2011-07-15  9:52 Michał Górny
2011-07-15  9:52 Michał Górny
2011-07-14 22:51 Michał Górny
2011-07-14 17:10 Michał Górny
2011-07-14 17:10 Michał Górny
2011-07-14 14:05 Michał Górny
2011-07-14 14:05 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-09  7:20 Michał Górny
2011-07-08 21:05 Michał Górny
2011-07-08 21:05 Michał Górny
2011-07-08 16:37 Michał Górny
2011-07-08  7:18 Michał Górny
2011-07-06 20:54 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0572d4b95f033e6f1d9c360e8d60fa0828e5d8a.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox