From d71432b3d9c9f4066885c1493108cc91b5be1298 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Thu, 5 Apr 2007 16:34:03 -0400 Subject: [PATCH] make the output listPackages() consistent regardless of with_dups --- cli/koji | 22 +++++++--------------- hub/kojihub.py | 13 +++++++++++-- www/kojiweb/index.py | 6 +++--- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/cli/koji b/cli/koji index 7095858b..1605dfcd 100755 --- a/cli/koji +++ b/cli/koji @@ -1676,23 +1676,20 @@ def anon_handle_list_pkgs(options, session, args): print "%-23s %-23s %-16s %-16s" % ('Package','Tag','Extra Arches','Owner') print "%s %s %s %s" % ('-'*23,'-'*23,'-'*16,'-'*16) for pkg in data: - if options.tag: - pkg = [pkg[0]] if allpkgs: print pkg['package_name'] - continue - for tagged_pkg in pkg: - if not options.show_blocked and tagged_pkg.get('blocked',False): + else: + if not options.show_blocked and pkg.get('blocked',False): continue - if tagged_pkg.has_key('tag_id'): - if tagged_pkg['extra_arches'] is None: - tagged_pkg['extra_arches'] = "" + if pkg.has_key('tag_id'): + if pkg['extra_arches'] is None: + pkg['extra_arches'] = "" fmt = "%(package_name)-23s %(tag_name)-23s %(extra_arches)-16s %(owner_name)-16s" - if tagged_pkg.get('blocked',False): + if pkg.get('blocked',False): fmt += " [BLOCKED]" else: fmt = "%(package_name)s" - print fmt % tagged_pkg + print fmt % pkg def anon_handle_rpminfo(options, session, args): "Print basic information about an RPM" @@ -2816,11 +2813,6 @@ def handle_set_pkg_owner_global(options, session, args): if not entries: print "No data for package %s" % package continue - elif len(entries) > 1: - # since we specified exactly one package, the list should - # only have one entry - raise koji.GenericError, "Unexpected return format" - entries = entries[0] for entry in entries: if user['id'] == entry['owner_id']: if options.verbose: diff --git a/hub/kojihub.py b/hub/kojihub.py index 9b88f9f0..353dcd48 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -4679,10 +4679,19 @@ class RootExports(object): userID = get_user(userID,strict=True)['id'] if pkgID is not None: pkgID = get_package_id(pkgID,strict=True) - results = readPackageList(tagID=tagID, userID=userID, pkgID=pkgID, - inherit=inherited, with_dups=with_dups).values() + result_list = readPackageList(tagID=tagID, userID=userID, pkgID=pkgID, + inherit=inherited, with_dups=with_dups).values() + if with_dups: + # when with_dups=True, readPackageList returns a list of list of dicts + # convert it to a list of dicts for consistency + results = [] + for result in result_list: + results.extend(result) + else: + results = result_list if prefix: + prefix = prefix.lower() results = [package for package in results if package['package_name'].lower().startswith(prefix)] return results diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index 414bcbeb..dc83d865 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -181,7 +181,7 @@ def index(req, packageOrder='package_name', packageStart=None, buildOrder='-comp start=taskStart, dataName='tasks', prefix='task', order=taskOrder, pageSize=10) if user: - packages = kojiweb.util.paginateResults(server, values, 'listPackages', kw={'userID': user['id']}, + packages = kojiweb.util.paginateResults(server, values, 'listPackages', kw={'userID': user['id'], 'with_dups': True}, start=packageStart, dataName='packages', prefix='package', order=packageOrder, pageSize=10) notifs = server.getBuildNotifications(user['id']) @@ -896,7 +896,7 @@ def userinfo(req, userID, packageOrder='package_name', packageStart=None, buildO values['user'] = user values['userID'] = user['id'] - packages = kojiweb.util.paginateResults(server, values, 'listPackages', kw={'userID': user['id']}, + packages = kojiweb.util.paginateResults(server, values, 'listPackages', kw={'userID': user['id'], 'with_dups': True}, start=packageStart, dataName='packages', prefix='package', order=packageOrder, pageSize=10) builds = kojiweb.util.paginateMethod(server, values, 'listBuilds', kw={'userID': user['id']}, @@ -1315,7 +1315,7 @@ def packagesbyuser(req, start=None, order=None): server.multicall = True for user in users: - server.count('listPackages', userID=user['id']) + server.count('listPackages', userID=user['id'], with_dups=True) packageCounts = server.multiCall() for user, [numPackages] in zip(users, packageCounts):