コード例 #1
0
def unit_generator(dbs, module_name, hostname):
    """
    Generator to produce all units visible to the API caller

    :param dbs: The list of repo gdm files available to query for data
    :type dbs: dict
    :param module_name: The module name to search for
    :type module_name: str
    :param hostname: The hostname of server serving modules
    :type hostname: str
    """
    for repo_id, data in dbs.iteritems():
        protocol = data['protocol']
        db = data['db']
        try:
            json_data = db[module_name]
        except KeyError:
            _LOGGER.debug('module %s not found in repo %s' %
                          (module_name, repo_id))
            continue
        units = json.loads(json_data)
        for unit in units:
            yield Unit(name=module_name,
                       db=db,
                       repo_id=repo_id,
                       host=hostname,
                       protocol=protocol,
                       **unit)
コード例 #2
0
ファイル: releases.py プロジェクト: W3SS/pulp_puppet
def unit_generator(dbs, module_name, hostname):
    """
    Generator to produce all units visible to the API caller

    :param dbs: The list of repo gdm files available to query for data
    :type dbs: dict
    :param module_name: The module name to search for
    :type module_name: str
    :param hostname: The hostname of server serving modules
    :type hostname: str

    :return: A generator of pulp_puppet.forge.unit.Unit objects
    :rtype: generator
    """
    for repo_id, data in dbs.iteritems():
        protocol = data['protocol']
        db = data['db']
        try:
            json_data = db[module_name]
        except KeyError:
            msg_dict = {'module': module_name, 'repo_id': repo_id}
            msg = _('module %(module)s not found in repo %(repo_id)s')
            _LOGGER.debug(msg, msg_dict)
            continue
        units = json.loads(json_data)
        for unit in units:
            yield Unit(name=module_name,
                       db=db,
                       repo_id=repo_id,
                       host=hostname,
                       protocol=protocol,
                       **unit)