changeset 27:7e74ceedaa26

More readable way of determining number of blocks needed, though I think I'm missing something...
author Atul Varma <varmaa@toolness.com>
date Mon, 27 Apr 2009 08:44:36 -0700
parents 4a4b66f5229b
children 91c47c54b666
files openwebchat.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/openwebchat.py	Mon Apr 27 08:42:47 2009 -0700
+++ b/openwebchat.py	Mon Apr 27 08:44:36 2009 -0700
@@ -39,7 +39,9 @@
         mimetype = self.MIME_TYPES[filename.split('.')[-1]]
 
         length = os.stat(filename).st_size
-        num_blocks = int(math.ceil(float(length) / self.BLOCK_SIZE))
+        num_blocks = length / self.BLOCK_SIZE
+        if length % self.BLOCK_SIZE:
+            num_blocks += 1
         infile = open(filename, 'r')
 
         yield until_sent(self._make_http_response(mimetype = mimetype,