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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

"""Helper functions for scrapy.http objects (Request, Response)""" 

 

import weakref 

 

from urlparse import urlparse 

 

_urlparse_cache = weakref.WeakKeyDictionary() 

def urlparse_cached(request_or_response): 

    """Return urlparse.urlparse caching the result, where the argument can be a 

    Request or Response object 

    """ 

    if request_or_response not in _urlparse_cache: 

        _urlparse_cache[request_or_response] = urlparse(request_or_response.url) 

    return _urlparse_cache[request_or_response]