forked from github/pelican
Merge pull request #2514 from rask004/fix-2487
Fix pelican-import error regarding wp-attach and Unicode
This commit is contained in:
commit
d9e98a5a39
1 changed files with 7 additions and 1 deletions
|
|
@ -13,7 +13,7 @@ from codecs import open
|
|||
from collections import defaultdict
|
||||
|
||||
from six.moves.urllib.error import URLError
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from six.moves.urllib.parse import quote, urlparse, urlsplit, urlunsplit
|
||||
from six.moves.urllib.request import urlretrieve
|
||||
|
||||
# because logging.setLoggerClass has to be called before logging.getLogger
|
||||
|
|
@ -728,6 +728,12 @@ def download_attachments(output_path, urls):
|
|||
if sys.platform != 'win32' or ':' not in item:
|
||||
localpath = os.path.join(localpath, item)
|
||||
full_path = os.path.join(output_path, localpath)
|
||||
|
||||
# Generate percent-encoded URL
|
||||
scheme, netloc, path, query, fragment = urlsplit(url)
|
||||
path = quote(path)
|
||||
url = urlunsplit((scheme, netloc, path, query, fragment))
|
||||
|
||||
if not os.path.exists(full_path):
|
||||
os.makedirs(full_path)
|
||||
print('downloading {}'.format(filename))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue