From 9948db89162b12bd94971dbad4b0f765dd1b47f5 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sat, 11 May 2013 06:18:34 +0200 Subject: [PATCH] Added clen attribute to imgstreams. --- manga/lib.py | 4 +++- manga/mangafox.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manga/lib.py b/manga/lib.py index 8ec9c2e..d901e9f 100644 --- a/manga/lib.py +++ b/manga/lib.py @@ -115,7 +115,9 @@ class imgstream(object): when exiting the with-scope. All imgstreams should contain an attribute `ctype', being the - Content-Type of the image being read by the stream.""" + Content-Type of the image being read by the stream, and `clen`, + being either an int describing the total number of bytes in the + stream, or None if the value is not known in advance.""" def __enter__(self): return self diff --git a/manga/mangafox.py b/manga/mangafox.py index 339ed5e..572853c 100644 --- a/manga/mangafox.py +++ b/manga/mangafox.py @@ -7,6 +7,7 @@ class imgstream(lib.imgstream): def __init__(self, url): self.bk = urllib.urlopen(url) self.ctype = self.bk.info()["Content-Type"] + self.clen = int(self.bk.info()["Content-Length"]) def fileno(self): return self.bk.fileno() -- 2.11.0