Exemplo n.º 1
0
    def test_resolver_list(self):
        paths = [to_file_url(os.path.realpath(__file__)),
                 'http://myhost.example.com/warcs/',
                 'redis://localhost:1234/0']

        res = DefaultResolverMixin.make_resolvers(paths)
        assert isinstance(res[0], PathIndexResolver)
        assert isinstance(res[1], PrefixResolver)
        assert isinstance(res[2], RedisResolver)
Exemplo n.º 2
0
    def test_resolver_list(self):
        paths = [to_file_url(os.path.realpath(__file__)),
                 'http://myhost.example.com/warcs/',
                 'redis://localhost:1234/0']

        res = DefaultResolverMixin.make_resolvers(paths)
        assert isinstance(res[0], PathIndexResolver)
        assert isinstance(res[1], PrefixResolver)
        assert isinstance(res[2], RedisResolver)
Exemplo n.º 3
0
def load_from_cdx_test(cdx, revisit_func=load_orig_cdx, reraise=False,
                       failed_files=None):
    resolve_loader = ResolvingLoader(DefaultResolverMixin.make_resolvers(test_warc_dir))
    cdx = CDXObject(cdx.encode('utf-8'))

    try:
        (headers, stream) = resolve_loader(cdx, failed_files, revisit_func)
        print(repr_format(headers))
        sys.stdout.write(stream.readline().decode('utf-8'))
        sys.stdout.write(stream.readline().decode('utf-8'))
    except ArchiveLoadFailed as e:
        if reraise:
            raise
        else:
            print('Exception: ' + e.__class__.__name__)
Exemplo n.º 4
0
def load_from_cdx_test(cdx,
                       revisit_func=load_orig_cdx,
                       reraise=False,
                       failed_files=None):
    resolve_loader = ResolvingLoader(
        DefaultResolverMixin.make_resolvers(test_warc_dir))
    cdx = CDXObject(cdx.encode('utf-8'))

    try:
        (headers, stream) = resolve_loader(cdx, failed_files, revisit_func)
        print(repr_format(headers))
        sys.stdout.write(stream.readline().decode('utf-8'))
        sys.stdout.write(stream.readline().decode('utf-8'))
    except ArchiveLoadFailed as e:
        if reraise:
            raise
        else:
            print('Exception: ' + e.__class__.__name__)