Ejemplo n.º 1
0
    def load_test_archive(test_file, offset, length):
        path = utils.test_data_dir() + 'warcs/' + test_file

        archive = testloader.load(path, offset, length)
        pprint.pprint((archive.type, archive.rec_headers, archive.status_headers))
Ejemplo n.º 2
0
            self[header] = field

        self.cdxline = cdxline

    def __setitem__(self, key, value):
        OrderedDict.__setitem__(self, key, value)

        # force regen on next __str__ call
        self.cdxline = None


    def __str__(self):
        if self.cdxline:
            return self.cdxline

        li = itertools.imap(lambda (n, val): val, self.items())
        return ' '.join(li)



# Testing

import utils
if __name__ == "__main__" or utils.enable_doctests():
    from pprint import pprint

    test_dir = utils.test_data_dir() + 'cdx/'

    import doctest
    doctest.testmod()
Ejemplo n.º 3
0
 def create_test_cdx(test_file):
     path = utils.test_data_dir() + 'cdx/' + test_file
     return FileReader(path)