From 57c3bcdb916f225e5d1ceaae7e07718b0ee43610 Mon Sep 17 00:00:00 2001 From: Jeff Casavant Date: Fri, 10 Jun 2016 11:02:23 -0400 Subject: [PATCH 1/3] Add len function to FilePart --- warc/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/warc/utils.py b/warc/utils.py index 8620e8e..c29f3a0 100644 --- a/warc/utils.py +++ b/warc/utils.py @@ -94,3 +94,6 @@ def __iter__(self): while line: yield line line = self.readline() + + def __len__(self): + return self.length From 26663d14679daa4ca27faae9000b51a39991a1d1 Mon Sep 17 00:00:00 2001 From: Jeff Casavant Date: Fri, 10 Jun 2016 11:31:14 -0400 Subject: [PATCH 2/3] Write buf rather than payload instance --- warc/warc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warc/warc.py b/warc/warc.py index 0c762a6..d10f8f3 100644 --- a/warc/warc.py +++ b/warc/warc.py @@ -158,7 +158,7 @@ def _compute_digest(self, payload): def write_to(self, f): self.header.write_to(f) - f.write(self.payload) + f.write(self.payload.buf) f.write("\r\n") f.write("\r\n") f.flush() From 271c42140876188e5f399fd4f2ab7b6723cd7e16 Mon Sep 17 00:00:00 2001 From: Jeff Casavant Date: Fri, 10 Jun 2016 11:32:20 -0400 Subject: [PATCH 3/3] Remove length function to test if this isn't required --- warc/utils.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/warc/utils.py b/warc/utils.py index c29f3a0..8620e8e 100644 --- a/warc/utils.py +++ b/warc/utils.py @@ -94,6 +94,3 @@ def __iter__(self): while line: yield line line = self.readline() - - def __len__(self): - return self.length