public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] search: fix addCP so only the specified results are displayed (bug 547736)
@ 2015-04-25 22:47 Zac Medico
  2015-04-28 20:54 ` Brian Dolbec
  0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2015-04-25 22:47 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

Since commit 4938b8a8a72e719b394a5c5b0c5030c160091d57, the search.addCP
method has not worked as intended.

Fixes: 4938b8a8a72e ("Display emerge search results incrementally (412471)")
X-Gentoo-Bug: 547736
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=547736
---
 pym/_emerge/search.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
index 5a8143c..41c182d 100644
--- a/pym/_emerge/search.py
+++ b/pym/_emerge/search.py
@@ -36,6 +36,7 @@ class search(object):
 		self.verbose = verbose
 		self.searchdesc = searchdesc
 		self.searchkey = None
+		self._results_specified = False
 		# Disable the spinner since search results are displayed
 		# incrementally.
 		self.spinner = None
@@ -295,6 +296,12 @@ class search(object):
 					yield ("set", setname)
 
 	def addCP(self, cp):
+		"""
+		Add a specific cp to the search results. This modifies the
+		behavior of the output method, so that it only displays specific
+		packages added via this method.
+		"""
+		self._results_specified = True
 		if not self._xmatch("match-all", cp):
 			return
 		self.matches["pkg"].append(cp)
@@ -315,11 +322,12 @@ class search(object):
 		metadata_keys.update(["DESCRIPTION", "HOMEPAGE", "LICENSE", "SRC_URI"])
 		metadata_keys = tuple(metadata_keys)
 
-		if self.searchkey is None:
+		if self._results_specified:
 			# Handle results added via addCP
 			addCP_matches = []
-			for mytype, match in self.matches.items():
-				addCP_matches.append(mytype, match)
+			for mytype, matches in self.matches.items():
+				for match in matches:
+					addCP_matches.append((mytype, match))
 			iterator = iter(addCP_matches)
 
 		else:
-- 
2.3.5



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

* Re: [gentoo-portage-dev] [PATCH] search: fix addCP so only the specified results are displayed (bug 547736)
  2015-04-25 22:47 [gentoo-portage-dev] [PATCH] search: fix addCP so only the specified results are displayed (bug 547736) Zac Medico
@ 2015-04-28 20:54 ` Brian Dolbec
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2015-04-28 20:54 UTC (permalink / raw
  To: gentoo-portage-dev

On Sat, 25 Apr 2015 15:47:20 -0700
Zac Medico <zmedico@gentoo.org> wrote:

> Since commit 4938b8a8a72e719b394a5c5b0c5030c160091d57, the
> search.addCP method has not worked as intended.
> 
> Fixes: 4938b8a8a72e ("Display emerge search results incrementally
> (412471)") X-Gentoo-Bug: 547736
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=547736
> ---
>  pym/_emerge/search.py | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
> index 5a8143c..41c182d 100644
> --- a/pym/_emerge/search.py
> +++ b/pym/_emerge/search.py
> @@ -36,6 +36,7 @@ class search(object):
>  		self.verbose = verbose
>  		self.searchdesc = searchdesc
>  		self.searchkey = None
> +		self._results_specified = False
>  		# Disable the spinner since search results are
> displayed # incrementally.
>  		self.spinner = None
> @@ -295,6 +296,12 @@ class search(object):
>  					yield ("set", setname)
>  
>  	def addCP(self, cp):
> +		"""
> +		Add a specific cp to the search results. This
> modifies the
> +		behavior of the output method, so that it only
> displays specific
> +		packages added via this method.
> +		"""
> +		self._results_specified = True
>  		if not self._xmatch("match-all", cp):
>  			return
>  		self.matches["pkg"].append(cp)
> @@ -315,11 +322,12 @@ class search(object):
>  		metadata_keys.update(["DESCRIPTION", "HOMEPAGE",
> "LICENSE", "SRC_URI"]) metadata_keys = tuple(metadata_keys)
>  
> -		if self.searchkey is None:
> +		if self._results_specified:
>  			# Handle results added via addCP
>  			addCP_matches = []
> -			for mytype, match in self.matches.items():
> -				addCP_matches.append(mytype, match)
> +			for mytype, matches in self.matches.items():
> +				for match in matches:
> +
> addCP_matches.append((mytype, match)) iterator = iter(addCP_matches)
>  
>  		else:

Looks good

-- 
Brian Dolbec <dolsen>



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

end of thread, other threads:[~2015-04-28 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-25 22:47 [gentoo-portage-dev] [PATCH] search: fix addCP so only the specified results are displayed (bug 547736) Zac Medico
2015-04-28 20:54 ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox