Permalink
Browse files

simplify CSS link parsing code in lxml.html

  • Loading branch information...
scoder committed Apr 25, 2014
1 parent df5828d commit 725c1b0cdf095a27c2ee574d9cd48038203462ec
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/lxml/html/__init__.py
View
@@ -416,19 +416,18 @@ def iterlinks(self):
yield (el, 'value', el.get('value'), 0)
if tag == 'style' and el.text:
urls = [
- _unquote_match(match.group(1), match.start(1))
+ # (start_pos, url)
+ _unquote_match(match.group(1), match.start(1))[::-1]
for match in _iter_css_urls(el.text)
] + [
- (match.group(1), match.start(1))
+ (match.start(1), match.group(1))
for match in _iter_css_imports(el.text)
]
if urls:
# sort by start pos to bring both match sets back into order
- urls = [ (start, url) for (url, start) in urls ]
- urls.sort()
- # reverse the list to report correct positions despite
+ # and reverse the list to report correct positions despite
# modifications
- urls.reverse()
+ urls.sort(reverse=True)
for start, url in urls:
yield (el, None, url, start)
if 'style' in attribs:

0 comments on commit 725c1b0

Please sign in to comment.