Skip to content

Commit

Permalink
Use urllib.request.url2pathname to get the correct path on windows wh…
Browse files Browse the repository at this point in the history
…en the url scheme is file
  • Loading branch information
Samir OUCHENE committed Nov 15, 2022
1 parent 0e24621 commit 46ff763
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions imagePerspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'''

import os
import sys
import urllib
import urllib.parse as urlparse

import io
Expand Down Expand Up @@ -66,7 +66,9 @@ def extract_image(self, node):
# FIXME: redundancy
if starts_with_file:
path = urlparse.urlparse(xlink).path
path = os.path.abspath(path)
# On windows it is important to use urllib.request.url2pathname
# see: https://stackoverflow.com/a/43925228/5920411
path = urllib.request.url2pathname(path)
if os.path.isfile(path):
# open the file and encode it
# I know, this is a horrible workaround (to b64 encode the image), but
Expand Down

0 comments on commit 46ff763

Please sign in to comment.