Skip to content

Commit bfd0b0f

Browse files
committed
add pathlib conditional
1 parent bd4c27f commit bfd0b0f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/diffpy/structure/parsers/p_cif.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
from contextlib import contextmanager
2424
import numpy
2525
import six
26+
try:
27+
import pathlib
28+
has_pathlib = True
29+
except ImportError:
30+
has_pathlib = False
2631

2732
from diffpy.structure import Structure, Lattice, Atom
2833
from diffpy.structure import StructureFormatError
@@ -281,7 +286,11 @@ def parseFile(self, filename):
281286
"""
282287
self.ciffile = None
283288
self.filename = filename
284-
rv = self._parseCifDataSource(filename)
289+
if has_pathlib:
290+
rv = self._parseCifDataSource(filename)
291+
else:
292+
fileurl = _quoteLocalPath(filename)
293+
rv = self._parseCifDataSource(fileurl)
285294
# all good here
286295
return rv
287296

0 commit comments

Comments
 (0)