Coverage for scrapy/utils/misc : 95%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
"""Helper functions which doesn't fit anywhere else"""
"""Convert an argument to an iterable. The argument can be a None, single value, or an iterable.
Exception: if arg is a dict, [arg] will be returned """ else:
"""Load an object given its absolute object path, and return it.
object can be a class, function, variable o instance. path ie: 'scrapy.contrib.downloadermiddelware.redirect.RedirectMiddleware' """
except ValueError: raise ValueError, "Error loading object '%s': not a full path" % path
"""Loads a module and all its submodules from a the given module path and returns them. If *any* module throws an exception while importing, that exception is thrown back.
For example: walk_modules('scrapy.utils') """
else:
"""Extract a list of unicode strings from the given text/encoding using the following policies:
* if the regex contains a named group called "extract" that will be returned * if the regex contains multiple numbered groups, all those will be returned (flattened) * if the regex doesn't contain any group the entire regex matching is returned """
else: return [remove_entities(unicode(s, encoding), keep=['lt', 'amp']) for s in strings]
"""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' """
|