Skip to content

Commit aa6db8b

Browse files
committed
add file prefix to uri
1 parent fe4b46b commit aa6db8b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/diffpy/structure/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def loadStructure(filename, fmt='auto', **kw):
6666
"""
6767
from diffpy.structure.parsers import getParser
6868
p = getParser(fmt, **kw)
69-
rv = p.parseFile(filename)
69+
rv = p.parseFile(str(filename))
7070
return rv
7171

7272
# silence pyflakes checker

src/diffpy/structure/parsers/p_cif.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ def _quoteLocalPath(filename):
731731
if cnvflag:
732732
from six.moves.urllib.request import pathname2url
733733
rv = pathname2url(filename)
734+
if rv.startswith("///"):
735+
rv = "file:" + rv
734736
return rv
735737

736738

src/diffpy/structure/tests/testp_cif.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def test__quoteLocalPath(self):
6666
"check _quoteLocalPath()"
6767
from six.moves.urllib.request import pathname2url as p2u
6868
self.assertEqual('/a/b/c.cif', _quoteLocalPath('/a/b/c.cif'))
69-
self.assertEqual(p2u('c:\\a.cif'), _quoteLocalPath('c:\\a.cif'))
70-
self.assertEqual(p2u('c:/a.cif'), _quoteLocalPath('c:/a.cif'))
69+
self.assertEqual('file:' + p2u('c:\\a.cif'), _quoteLocalPath('c:\\a.cif'))
70+
self.assertEqual('file:' + p2u('c:/a.cif'), _quoteLocalPath('c:/a.cif'))
7171
self.assertEqual('/x:y/c.cif', _quoteLocalPath('/x:y/c.cif'))
7272
self.assertEqual('http::cif.org/a.cif',
7373
_quoteLocalPath('http::cif.org/a.cif'))

0 commit comments

Comments
 (0)