Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
Date: Sun, 31 May 2015 05:03:27
Message-Id: 1433027930.c3b217c2c8e0402a71e75407e7d37f9639f045f2.dolsen@gentoo
1 commit: c3b217c2c8e0402a71e75407e7d37f9639f045f2
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 21 19:09:03 2015 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Sat May 30 23:18:50 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c3b217c2
7
8 gkeys/seedhandler.py: Make key_search accept args as a dictionary or argsparse object
9
10 gkeys/gkeys/seedhandler.py | 16 +++++++++++++---
11 1 file changed, 13 insertions(+), 3 deletions(-)
12
13 diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
14 index a905051..8b787d1 100644
15 --- a/gkeys/gkeys/seedhandler.py
16 +++ b/gkeys/gkeys/seedhandler.py
17 @@ -216,17 +216,27 @@ class SeedHandler(object):
18 def key_search(self, args, search_args):
19 '''Performs a search for all listed args in the seeds'''
20 results = []
21 - self.logger.debug("_field_search search_args: %s" % str(search_args))
22 + self.logger.debug("SeedHandler.key_search() search_args: %s" % str(search_args))
23 found = {}
24 search_args.sort()
25 + if isinstance(args, dict):
26 + exact = args.get('exact', False)
27 + _all = args.get('all', False)
28 + else:
29 + exact = getattr(args, 'exact', False)
30 + _all = getattr(args, 'all', False)
31 for arg in search_args:
32 - seeds = self.seeds.field_search(arg, getattr(args, arg), args.exact)
33 + if isinstance(args, dict):
34 + value = args.get(arg, '')
35 + else:
36 + value = getattr(args, arg)
37 + seeds = self.seeds.field_search(arg, value, exact)
38 for seed in seeds:
39 if seed.nick in found:
40 found[seed.nick]['args'].append(arg)
41 else:
42 found[seed.nick] = {'args': [arg], 'seed': seed}
43 - if args.all:
44 + if _all:
45 for possible in sorted(found):
46 if search_args == found[possible]['args']:
47 results.append(found[possible]['seed'])