Skip to content

Commit 4385fb7

Browse files
committed
MNT: rename internal utility function
Rename `_fixIfWindowsPath` --> `_quoteLocalPath`
1 parent fc20f0e commit 4385fb7

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/diffpy/structure/parsers/p_cif.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def parseFile(self, filename):
281281
"""
282282
self.ciffile = None
283283
self.filename = filename
284-
fileurl = _fixIfWindowsPath(filename)
284+
fileurl = _quoteLocalPath(filename)
285285
rv = self._parseCifDataSource(fileurl)
286286
# all good here
287287
return rv
@@ -706,8 +706,8 @@ def getSymOp(s):
706706
return rv
707707

708708

709-
def _fixIfWindowsPath(filename):
710-
"""Convert local paths which may confuse urlopen to file URL.
709+
def _quoteLocalPath(filename):
710+
"""Quote local paths to file URL-s.
711711
712712
CifFile reads files with urlopen, which fails for Windows paths or
713713
for paths containing ":".

src/diffpy/structure/tests/testp_cif.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from diffpy.structure.tests.testutils import datafile
2424
from diffpy.structure.parsers.p_cif import P_cif, leading_float, getSymOp
25-
from diffpy.structure.parsers.p_cif import _fixIfWindowsPath
25+
from diffpy.structure.parsers.p_cif import _quoteLocalPath
2626
from diffpy.structure.parsers import getParser
2727
from diffpy.structure import Structure
2828
from diffpy.structure import StructureFormatError
@@ -62,16 +62,15 @@ def test_getSymOp(self):
6262
return
6363

6464

65-
def test__fixIfWindowsPath(self):
66-
"check _fixIfWindowsPath()"
65+
def test__quoteLocalPath(self):
66+
"check _quoteLocalPath()"
6767
from six.moves.urllib.request import pathname2url as p2u
68-
self.assertEqual('/a/b/c.cif', _fixIfWindowsPath('/a/b/c.cif'))
69-
self.assertEqual(p2u('c:\\a.cif'), _fixIfWindowsPath('c:\\a.cif'))
70-
self.assertEqual(p2u('c:/a.cif'), _fixIfWindowsPath('c:/a.cif'))
71-
self.assertEqual(p2u('abc:/a.cif'), _fixIfWindowsPath('abc:/a.cif'))
72-
self.assertEqual('/x:y/c.cif', _fixIfWindowsPath('/x:y/c.cif'))
68+
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'))
71+
self.assertEqual('/x:y/c.cif', _quoteLocalPath('/x:y/c.cif'))
7372
self.assertEqual('http::cif.org/a.cif',
74-
_fixIfWindowsPath('http::cif.org/a.cif'))
73+
_quoteLocalPath('http::cif.org/a.cif'))
7574
return
7675

7776
# End of class TestRoutines

0 commit comments

Comments
 (0)