From ecbd0c970a2d07dd7df73f0fbfb5c9ae75d557a9 Mon Sep 17 00:00:00 2001 From: jayGattusoNLNZ Date: Tue, 26 Nov 2013 11:49:15 +1300 Subject: [PATCH] Update arc.py ARCv 2 files can contain an XML block that confuses the header parser when the fileobj is presented. This edit skips the XML block and allows the first record header to be properly discovered. --- warc/arc.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/warc/arc.py b/warc/arc.py index 5889587..1d20916 100644 --- a/warc/arc.py +++ b/warc/arc.py @@ -346,6 +346,17 @@ def _read_arc_record(self): header = self.fileobj.readline() while header and header.strip() == "": header = self.fileobj.readline() + + #JG: this block stops the header parser / reader + #from getting caught on the XML lump + #that can appear in ARC files + + if header.startswith("\n"): + header = self.fileobj.readline() + header = self.fileobj.readline() + header = self.fileobj.readline() + if header == "": return None