def get_repo_data(repo_ids): """ Find, open, and return the gdbm database file associated with each repo plus that repo's publish protocol :param repo_ids: list of repository IDs. :type repo_ids: list :return: dictionary where keys are repo IDs, and values are dicts that contain an open gdbm database under key "db", and a protocol under key "protocol". :rtype: dict """ ret = {} for distributor in RepoDistributorManager.find_by_repo_list(repo_ids): publish_protocol = _get_protocol_from_distributor(distributor) protocol_key, protocol_default_value = PROTOCOL_CONFIG_KEYS[ publish_protocol] repo_path = distributor['config'].get(protocol_key, protocol_default_value) repo_id = distributor['repo_id'] db_path = os.path.join(repo_path, repo_id, constants.REPO_DEPDATA_FILENAME) try: ret[repo_id] = { 'db': gdbm.open(db_path, 'r'), 'protocol': publish_protocol } except gdbm.error: _LOGGER.error( 'failed to find dependency database for repo %s. re-publish to fix.' % repo_id) return ret
def get_repo_data(repo_ids): """ Find, open, and return the gdbm database file associated with each repo plus that repo's publish protocol :param repo_ids: list of repository IDs. :type repo_ids: list :return: dictionary where keys are repo IDs, and values are dicts that contain an open gdbm database under key "db", and a protocol under key "protocol". :rtype: dict """ ret = {} for distributor in RepoDistributorManager.find_by_repo_list(repo_ids): publish_protocol = _get_protocol_from_distributor(distributor) protocol_key, protocol_default_value = PROTOCOL_CONFIG_KEYS[publish_protocol] repo_path = distributor['config'].get(protocol_key, protocol_default_value) repo_id = distributor['repo_id'] db_path = os.path.join(repo_path, repo_id, constants.REPO_DEPDATA_FILENAME) try: ret[repo_id] = {'db': gdbm.open(db_path, 'r'), 'protocol': publish_protocol} except gdbm.error: _LOGGER.error('failed to find dependency database for repo %s. re-publish to fix.' % repo_id) return ret