From fb6020862e1b609f3006584d018221312bfbe581 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 15 Jan 2012 09:59:37 -0800 Subject: [PATCH] create_world_atom: multi-repo portdbapi aux_get This handles a KeyError raised from portdbapi.aux_get() when one of the repositories has a corrupt ebuild. --- pym/_emerge/create_world_atom.py | 35 ++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/pym/_emerge/create_world_atom.py b/pym/_emerge/create_world_atom.py index fa7cffc26..35fb7c4bd 100644 --- a/pym/_emerge/create_world_atom.py +++ b/pym/_emerge/create_world_atom.py @@ -21,8 +21,25 @@ def create_world_atom(pkg, args_set, root_config): sets = root_config.sets portdb = root_config.trees["porttree"].dbapi vardb = root_config.trees["vartree"].dbapi - available_slots = set(portdb.aux_get(cpv, ["SLOT"])[0] \ - for cpv in portdb.match(cp)) + + if arg_atom.repo is not None: + repos = [arg_atom.repo] + else: + # Iterate over portdbapi.porttrees, since it's common to + # tweak this attribute in order to adjust match behavior. + repos = [] + for tree in portdb.porttrees: + repos.append(portdb.repositories.get_name_for_location(tree)) + + available_slots = set() + for cpv in portdb.match(cp): + for repo in repos: + try: + available_slots.add(portdb.aux_get(cpv, ["SLOT"], + myrepo=repo)[0]) + except KeyError: + pass + slotted = len(available_slots) > 1 or \ (len(available_slots) == 1 and "0" not in available_slots) if not slotted: @@ -64,8 +81,18 @@ def create_world_atom(pkg, args_set, root_config): # enough to identify a specific slot. matches = mydb.match(arg_atom) matched_slots = set() - for cpv in matches: - matched_slots.add(mydb.aux_get(cpv, ["SLOT"])[0]) + if mydb is vardb: + for cpv in matches: + matched_slots.add(mydb.aux_get(cpv, ["SLOT"])[0]) + else: + for cpv in matches: + for repo in repos: + try: + matched_slots.add(portdb.aux_get(cpv, ["SLOT"], + myrepo=repo)[0]) + except KeyError: + pass + if len(matched_slots) == 1: new_world_atom = slot_atom if arg_atom.repo: -- 2.26.2