<commit_before>""" Fedora Notifications pkgdb client """

import json
import logging
import requests

from dogpile.cache import make_region

log = logging.getLogger(__name__)

_cache = make_region()


def get_packages_of_user(config, username):
    """ Retrieve the list of packages where the specified user some acl.

    :arg config: a dict containing the fedmsg config
    :arg username: the fas username of the packager whose packages are of
        interest.
    :return: a set listing all the packages where the specified user has
        some ACL.

    """

    if not hasattr(_cache, 'backend'):
        _cache.configure(**config['fmn.rules.cache'])

    @_cache.cache_on_arguments()
    def _getter(username):
        return _get_pkgdb2_packages_for(config, username)

    return _getter(username)


def _get_pkgdb2_packages_for(config, username):
    log.debug("Requesting pkgdb2 packages for user %r" % username)

    def _get_page(page):
        url = '{0}/packager/acl/{1}'.format(
                    config['fmn.rules.utils.pkgdb_url'], username)
        log.info("hitting url: %r" % url)
        req = requests.get(url, params=dict(page=page))

        if not req.status_code == 200:
            log.debug('URL %s returned code %s', req.url, req.status_code)
            return None

        return req.json()

    # We have to request the first page of data to figure out the total number
    packages = set()
    data = _get_page(1)

    if data is None:
        return packages

    pages = data['page_total']

    for i in range(1, pages + 1):

        # Avoid requesting the data twice the first time around
        if i != 1:
            data = _get_page(i)

        for pkgacl in data['acls']:
            if pkgacl['status'] != 'Approved':
                continue

            packages.add(pkgacl['packagelist']['package']['name'])

    log.debug("done talking with pkgdb2 for now.")
    return packages<commit_msg>Double check we retrieved  data<commit_after>""" Fedora Notifications pkgdb client """

import json
import logging
import requests

from dogpile.cache import make_region

log = logging.getLogger(__name__)

_cache = make_region()


def get_packages_of_user(config, username):
    """ Retrieve the list of packages where the specified user some acl.

    :arg config: a dict containing the fedmsg config
    :arg username: the fas username of the packager whose packages are of
        interest.
    :return: a set listing all the packages where the specified user has
        some ACL.

    """

    if not hasattr(_cache, 'backend'):
        _cache.configure(**config['fmn.rules.cache'])

    @_cache.cache_on_arguments()
    def _getter(username):
        return _get_pkgdb2_packages_for(config, username)

    return _getter(username)


def _get_pkgdb2_packages_for(config, username):
    log.debug("Requesting pkgdb2 packages for user %r" % username)

    def _get_page(page):
        url = '{0}/packager/acl/{1}'.format(
                    config['fmn.rules.utils.pkgdb_url'], username)
        log.info("hitting url: %r" % url)
        req = requests.get(url, params=dict(page=page))

        if not req.status_code == 200:
            log.debug('URL %s returned code %s', req.url, req.status_code)
            return None

        return req.json()

    # We have to request the first page of data to figure out the total number
    packages = set()
    data = _get_page(1)

    if data is None:
        return packages

    pages = data['page_total']

    for i in range(1, pages + 1):

        # Avoid requesting the data twice the first time around
        if i != 1:
            data = _get_page(i)

        if data is None:
            continue

        for pkgacl in data['acls']:
            if pkgacl['status'] != 'Approved':
                continue

            packages.add(pkgacl['packagelist']['package']['name'])

    log.debug("done talking with pkgdb2 for now.")
    return packages
{'fraction_non_alphanumeric': 0.0991128010139417, 'fraction_numerical': 0.006590621039290241, 'mean_word_length': 2.6268382352941178, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2179298', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1119, 'n_words': 374}