Source code for repoman.common.sources.kojiurl

#!/usr/bin/env python


Handles koji build urls

**TODO**: Improve the second level detections (now filtering buildArch and
    buildSRPM links only)
import logging
import re

import requests

from . import ArtifactSource
from .url import URLSource
from ..utils import split

logger = logging.getLogger(__name__)

[docs]class KojiURLSource(ArtifactSource): __doc__ = __doc__ DEFAULT_CONFIG = { 'koji_host_re': r'koji\.fedoraproject\.org', } CONFIG_SECTION = 'KojiURLSource'
[docs] @classmethod def formats_list(cls): return ( "https?://{KojiURLSource[koji_host_re]}/*",
[docs] def expand(self, source_str): art_list = [] if not re.match('https?://%s/' % self.config.get('koji_host_re'), source_str): return '', art_list # remove filters proto, url = source_str.split('://', 1) url, filters_str = split(url, ':', 1) lvl1_url = '%s://%s' % (proto, url) lvl1_page = requests.get(lvl1_url).text lvl2_reg = re.compile(r'(?<=href=")[^"]+(?=.*(buildArch|buildSRPM))')'Parsing Koji URL: %s', lvl1_url) lvl2_urls = [ URLSource.get_link(lvl1_url, for match in ( for i in lvl1_page.splitlines()) if match ] for url in lvl2_urls:' Got 2nd level URL: %s', url) art_list.extend( URLSource( config=self.config, stores=self.stores ).expand_page(url) ) if not art_list: logger.warn(' No packages found')' Done')
return filters_str, art_list