From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id BB397138CD0 for ; Sun, 31 May 2015 05:03:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B1710E08D1; Sun, 31 May 2015 05:03:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BC265E08C9 for ; Sun, 31 May 2015 05:03:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 16552340C53 for ; Sun, 31 May 2015 05:03:22 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 50D76A25 for ; Sun, 31 May 2015 05:03:19 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1433027930.c3b217c2c8e0402a71e75407e7d37f9639f045f2.dolsen@gentoo> Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/ X-VCS-Repository: proj/gentoo-keys X-VCS-Files: gkeys/gkeys/seedhandler.py X-VCS-Directories: gkeys/gkeys/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: c3b217c2c8e0402a71e75407e7d37f9639f045f2 X-VCS-Branch: master Date: Sun, 31 May 2015 05:03:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 623848f1-e35f-4f74-a0ce-2eeabb0c1e8a X-Archives-Hash: f86cd1f476957f992bf0c9716c4e695a commit: c3b217c2c8e0402a71e75407e7d37f9639f045f2 Author: Brian Dolbec gentoo org> AuthorDate: Sat Mar 21 19:09:03 2015 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sat May 30 23:18:50 2015 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c3b217c2 gkeys/seedhandler.py: Make key_search accept args as a dictionary or argsparse object gkeys/gkeys/seedhandler.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index a905051..8b787d1 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -216,17 +216,27 @@ class SeedHandler(object): def key_search(self, args, search_args): '''Performs a search for all listed args in the seeds''' results = [] - self.logger.debug("_field_search search_args: %s" % str(search_args)) + self.logger.debug("SeedHandler.key_search() search_args: %s" % str(search_args)) found = {} search_args.sort() + if isinstance(args, dict): + exact = args.get('exact', False) + _all = args.get('all', False) + else: + exact = getattr(args, 'exact', False) + _all = getattr(args, 'all', False) for arg in search_args: - seeds = self.seeds.field_search(arg, getattr(args, arg), args.exact) + if isinstance(args, dict): + value = args.get(arg, '') + else: + value = getattr(args, arg) + seeds = self.seeds.field_search(arg, value, exact) for seed in seeds: if seed.nick in found: found[seed.nick]['args'].append(arg) else: found[seed.nick] = {'args': [arg], 'seed': seed} - if args.all: + if _all: for possible in sorted(found): if search_args == found[possible]['args']: results.append(found[possible]['seed'])