projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
57f7e3c
)
[utils] Use compat_xpath
author
Sergey M․
<dstftw@gmail.com>
Thu, 17 Mar 2016 20:52:23 +0000
(
02:52
+0600)
committer
Sergey M․
<dstftw@gmail.com>
Thu, 17 Mar 2016 20:52:23 +0000
(
02:52
+0600)
youtube_dl/utils.py
patch
|
blob
|
history
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index 8ec1bd469925e08b7dccef374ab592a3b58464ac..ef6e7c7cb104a9087637490a7067d2dc92b26f00 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-50,6
+50,7
@@
from .compat import (
compat_urllib_parse_urlparse,
compat_urllib_request,
compat_urlparse,
compat_urllib_parse_urlparse,
compat_urllib_request,
compat_urlparse,
+ compat_xpath,
shlex_quote,
)
shlex_quote,
)
@@
-165,12
+166,7
@@
if sys.version_info >= (2, 7):
return node.find(expr)
else:
def find_xpath_attr(node, xpath, key, val=None):
return node.find(expr)
else:
def find_xpath_attr(node, xpath, key, val=None):
- # Here comes the crazy part: In 2.6, if the xpath is a unicode,
- # .//node does not match if a node is a direct child of . !
- if isinstance(xpath, compat_str):
- xpath = xpath.encode('ascii')
-
- for f in node.findall(xpath):
+ for f in node.findall(compat_xpath(xpath)):
if key not in f.attrib:
continue
if val is None or f.attrib.get(key) == val:
if key not in f.attrib:
continue
if val is None or f.attrib.get(key) == val:
@@
-195,9
+191,7
@@
def xpath_with_ns(path, ns_map):
def xpath_element(node, xpath, name=None, fatal=False, default=NO_DEFAULT):
def _find_xpath(xpath):
def xpath_element(node, xpath, name=None, fatal=False, default=NO_DEFAULT):
def _find_xpath(xpath):
- if sys.version_info < (2, 7): # Crazy 2.6
- xpath = xpath.encode('ascii')
- return node.find(xpath)
+ return node.find(compat_xpath(xpath))
if isinstance(xpath, (str, compat_str)):
n = _find_xpath(xpath)
if isinstance(xpath, (str, compat_str)):
n = _find_xpath(xpath)