mirror of https://github.com/scrapy/scrapy.git
updated some docstings
This commit is contained in:
parent
41f1972e47
commit
e7e1cba4a8
|
|
@ -136,6 +136,7 @@ class BaseImagesPipeline(MediaPipeline):
|
|||
self.store_image(key, image, buf, info)
|
||||
if first_buf is None:
|
||||
first_buf = buf
|
||||
first_buf.seek(0)
|
||||
return md5sum(first_buf)
|
||||
|
||||
def get_images(self, response, request, info):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import rfc822
|
|||
from scrapy.http import Request
|
||||
from scrapy.core.engine import scrapyengine
|
||||
from scrapy.core.exceptions import NotConfigured
|
||||
from scrapy.contrib.pipeline.images import BaseImagesPipeline, md5sum
|
||||
from scrapy.contrib.pipeline.images import BaseImagesPipeline
|
||||
from scrapy.conf import settings
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,18 +64,17 @@ def extract_regex(regex, text, encoding):
|
|||
else:
|
||||
return [remove_entities(unicode(s, encoding), keep=['lt', 'amp']) for s in strings]
|
||||
|
||||
def md5sum(buffer):
|
||||
"""Calculate the md5 checksum of a file
|
||||
def md5sum(file):
|
||||
"""Calculate the md5 checksum of a file-like object without reading its
|
||||
whole content in memory.
|
||||
|
||||
>>> from StringIO import StringIO
|
||||
>>> md5sum(StringIO('file content to hash'))
|
||||
'784406af91dd5a54fbb9c84c2236595a'
|
||||
|
||||
"""
|
||||
m = hashlib.md5()
|
||||
buffer.seek(0)
|
||||
while 1:
|
||||
d = buffer.read(8096)
|
||||
d = file.read(8096)
|
||||
if not d:
|
||||
break
|
||||
m.update(d)
|
||||
|
|
|
|||
Loading…
Reference in New Issue