internetarchive/warc — Issue #3: Bug in WARCRecord.__repr__()
Author: petri
Created: 2012-03-02 11:58:26+00:00
State: open

The line in __repr__:

return "" % (self['type'], self['record_id'])

results in an error. I don't know if the above line is wrong or whether there's a bug in how the attribute lookup chain is supposed to work. Changing the above line to this works though:

return "" % (self.header.type, self.header.record_id)

Traceback below.

--------

>>> h=WARCHeader({"WARC-Type": "response"}, defaults=True)
>>> r = WARCRecord(h)
>>> r
Traceback (most recent call last):
File "", line 1, in
File "__init__.py", line 186, in __repr__
return "" % (self['type'], self['record_id'])
File "__init__.py", line 172, in __getitem__
return self.header[name]
File "__init__.py", line 40, in __getitem__
return self._d[name.lower()]
KeyError: 'type'