Example #1
0
def fetch_and_parse_index(http_get_fn, parse_index_fn, pypi_base_url,
                          index_url, package_path):
    try:
        index_html_str = http_get_fn(url=index_url)
    except RequestException:
        raise http_404('Index "{}" cannot be reached'.format(index_url))

    try:
        index_rows = parse_index_fn(base_url=pypi_base_url,
                                    package_path=package_path,
                                    html_str=index_html_str)
    except ParseError:
        raise http_404('Index "{}" failed to be parsed'.format(index_url))

    return index_rows
Example #2
0
def _get_checksum(checksums, checksum_ext, response_headers):
    checksum = getattr(checksums, checksum_ext)

    if not checksum:
        raise http_404('Checksum not available')

    response_headers['Content-Type'] = 'application/x-checksum'

    return checksum
def fetch_and_parse_index(
        http_get_fn,
        parse_index_fn,
        pypi_base_url,
        index_url,
        package_path):
    try:
        index_html_str = http_get_fn(url=index_url)
    except RequestException:
        raise http_404('Index "{}" cannot be reached'.format(index_url))

    try:
        index_rows = parse_index_fn(
            base_url=pypi_base_url,
            package_path=package_path,
            html_str=index_html_str)
    except ParseError:
        raise http_404('Index "{}" failed to be parsed'.format(index_url))

    return index_rows
 def handle(self, path, request, response):
     raise http_404('Invalid path of "{}"'.format('/'.join(path)))
Example #5
0
 def wrapper(self, path, request, response):
     if path[0] != 'python':
         raise http_404('Not under "python/" directory')
     return fn(self, path, request, response)
 def wrapper(self, path, request, response):
     if path[0] != 'python':
         raise http_404('Not under "python/" directory')
     return fn(self, path, request, response)
Example #7
0
def _ensure_file_in_index(filename, index_rows):
    if filename not in index_rows:
        raise http_404('File "{}" does not exist'.format(filename))