File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 88import mimetypes
99import os
1010from collections import OrderedDict
11- from functools import lru_cache
11+
12+ try :
13+ from functools import lru_cache
14+ except ImportError :
15+ # Only works for single-argument functions.
16+ def lru_cache (* args , ** kwargs ):
17+ cache = {}
18+ def wrapper (fn ):
19+ def wrapped (arg ):
20+ value = cache .get (arg , None )
21+ if value is not None :
22+ return value
23+ value = fn (arg )
24+ cache [arg ] = value
25+ return value
26+ return wrapped
27+ return wrapper
1228
1329from pip ._vendor import html5lib , requests
1430from pip ._vendor .distlib .compat import unescape
@@ -273,7 +289,6 @@ def parse_links(page):
273289 """
274290 Parse an HTML document, and yield its anchor elements as Link objects.
275291 """
276-
277292 document = html5lib .parse (
278293 page .content ,
279294 transport_encoding = page .encoding ,
@@ -282,7 +297,6 @@ def parse_links(page):
282297
283298 url = page .url
284299 base_url = _determine_base_url (document , url )
285- all_links = []
286300 for anchor in document .findall (".//a" ):
287301 link = _create_link_from_element (
288302 anchor ,
Original file line number Diff line number Diff line change @@ -290,12 +290,12 @@ def test_parse_links_caches_same_page():
290290 page_1 = HTMLPage (
291291 html_bytes ,
292292 encoding = None ,
293- url = 'https://example.com/simple /' ,
293+ url = 'https://example.com/some-find-links-url /' ,
294294 )
295295 page_2 = HTMLPage (
296296 html_bytes ,
297297 encoding = None ,
298- url = 'https://example.com/simple /' ,
298+ url = 'https://example.com/some-find-links-url /' ,
299299 )
300300
301301 with mock .patch ("pip._internal.index.collector.html5lib.parse" ) as mock_parse :
You can’t perform that action at this time.
0 commit comments