|
10 | 10 | import warnings |
11 | 11 |
|
12 | 12 | from .pandoc_download import DEFAULT_TARGET_FOLDER, download_pandoc |
13 | | -from .py3compat import cast_bytes, cast_unicode, string_types, urlparse |
| 13 | +from .py3compat import cast_bytes, cast_unicode, string_types, url2path, urlparse |
14 | 14 |
|
15 | 15 | __author__ = u'Juho Vepsäläinen' |
16 | 16 | __version__ = '1.4' |
@@ -143,29 +143,27 @@ def _identify_path(source): |
143 | 143 | if source is None or not isinstance(source, string_types): |
144 | 144 | return False |
145 | 145 |
|
146 | | - path = False |
| 146 | + is_path = False |
147 | 147 | try: |
148 | | - path = os.path.exists(source) |
| 148 | + is_path = os.path.exists(source) |
149 | 149 | except UnicodeEncodeError: |
150 | | - path = os.path.exists(source.encode('utf-8')) |
| 150 | + is_path = os.path.exists(source.encode('utf-8')) |
151 | 151 | except: # noqa |
152 | 152 | # still false |
153 | 153 | pass |
154 | 154 |
|
155 | | - if not path: |
| 155 | + if not is_path: |
156 | 156 | # check if it's an URL |
157 | 157 | result = urlparse(source) |
158 | 158 | if result.scheme in ["http", "https"]: |
159 | | - path = True |
160 | | - # unfortunately, pandoc currently doesn't support anything else currently |
161 | | - # https://github.com/jgm/pandoc/issues/319 |
162 | | - # elif result.scheme and result.netloc and result.path: |
163 | | - # # complete uri including one with a network path |
164 | | - # path = True |
165 | | - # elif result.scheme == "file" and result.path: |
166 | | - # path = path = os.path.exists(url2path(source)) |
167 | | - |
168 | | - return path |
| 159 | + is_path = True |
| 160 | + elif result.scheme and result.netloc and result.path: |
| 161 | + # complete uri including one with a network path |
| 162 | + is_path = True |
| 163 | + elif result.scheme == "file" and result.path: |
| 164 | + is_path = os.path.exists(url2path(source)) |
| 165 | + |
| 166 | + return is_path |
169 | 167 |
|
170 | 168 |
|
171 | 169 | def _identify_format_from_path(sourcefile, format): |
|
0 commit comments