Mercurial > hg > cc > cirrus_work
comparison bin/warc.py @ 43:69be1131bcc5
get EOF right, finally
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Wed, 05 Jul 2023 17:49:24 +0100 |
parents | 689a0e311cd2 |
children | 44d3a4f4ea51 |
comparison
equal
deleted
inserted
replaced
42:689a0e311cd2 | 43:69be1131bcc5 |
---|---|
15 while not stream.closed: | 15 while not stream.closed: |
16 bp=0 | 16 bp=0 |
17 while l==b'\r\n': | 17 while l==b'\r\n': |
18 l=stream.readline() | 18 l=stream.readline() |
19 nb+=(ln:=len(l)) | 19 nb+=(ln:=len(l)) |
20 if ln==0: | 20 if ln==0: |
21 break | 21 break |
22 if l!=b'WARC/1.0\r\n': | 22 if l!=b'WARC/1.0\r\n': |
23 raise ValueError("Not a WARC file? At %s: %s[%s]"%(nb-len(l), | 23 raise ValueError("Not a WARC file? At %s: %s[%s]"%(nb-len(l), |
24 l.decode('latin-1'),len(l))) | 24 l.decode('latin-1'),len(l))) |
25 wtype=None | 25 wtype=None |
26 length=None | 26 length=None |