Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArcParser raises exception instead of returning error info as WarcParser does #3

Open
kngenie opened this issue Oct 2, 2013 · 1 comment

Comments

@kngenie
Copy link
Member

kngenie commented Oct 2, 2013

ArcParser raises exception when it encounters malformatted record:

Traceback (most recent call last):
  File "../../fixarc.py", line 30, in <module>
    offset, record, errors = a._read_record(True)
  File "/home/kenji/projects/wbm/hanzo/warctools/stream.py", line 125, in _read_record
    self.record_parser.parse(self.gz, offset=None)
  File "/home/kenji/projects/wbm/hanzo/warctools/arc.py", line 140, in parse
    headers = self.parse_header_list(line)
  File "/home/kenji/projects/wbm/hanzo/warctools/arc.py", line 185, in parse_header_list
    raise StandardError('missing headers %s %s'%(",".join(values), ",".join(self.headers)))
StandardError: missing headers http://rservicespb.ru/robots.txt,91.218.228.14,20130908181048,08Sep201318:10-1:47GMT URL,IP-address,Archive-date,Content-type,Archive-length

on the other hand, WarcParser returns tuple with error info in second element and record offset in 3rd, which is useful for locating the troubling record (and possibly automating repair process).

It'd be useful if ArcParser behaves the same way as WarcParser on error.

@tef
Copy link
Collaborator

tef commented Oct 3, 2013

Yep, it would be!

However one of the problems in the current arcparser code is that missing headers break the parser. I need to change the parser to assume the last field is always the length and hope for the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants