(path: str)
Based on path, choose appropriate backend and fetch the file contents.
Based on path, choose appropriate backend and fetch the file contents.
Based on path choose appropriate backend and fetch the file contents .
def get_web_archive_index(path: str) -> str:
    """
    Based on path, choose appropriate backend and fetch the file contents.
    """

    # TODO right now, every backend is just a function which returns contents
    #   of a CDXJ file as string. In the future, however, backends will be
    #   probably represented as classes with much more sophisticated methods
    #   of manipulating the archive index records.
    # TODO also, it will be possible to choose a backend and configure it;
    #   whereas right now we choose a backend automatically based on the given
    #   path itself.

    # Maybe it is an IPFS address?
    response = fetch_ipfs_index(path)
    if response is not None:
        return response

    # Or a traditional Web address?
    response = fetch_web_index(path)
    if response is not None:
        return response

    # Okay, this is probably a file on local disk
    response = fetch_local_index(path)
    if response is not None:
        return response

    raise ValueError((
        f'Unknown format of index file location: {path}. Please provide '
        f'a valid local path, HTTP or FTP URL, or an IPFS QmHash.'
    ))
def get_web_archive_index ( path : str ) -> str : # TODO right now, every backend is just a function which returns contents #   of a CDXJ file as string. In the future, however, backends will be #   probably represented as classes with much more sophisticated methods #   of manipulating the archive index records. # TODO also, it will be possible to choose a backend and configure it; #   whereas right now we choose a backend automatically based on the given #   path itself. # Maybe it is an IPFS address? response = fetch_ipfs_index ( path ) if response is not None : return response # Or a traditional Web address? response = fetch_web_index ( path ) if response is not None : return response # Okay, this is probably a file on local disk response = fetch_local_index ( path ) if response is not None : return response raise ValueError ( ( f'Unknown format of index file location: {path}. Please provide ' f'a valid local path, HTTP or FTP URL, or an IPFS QmHash.' ) )