Skip to content
Snippets Groups Projects
Commit 71d1d1a3 authored by Michael Wedel's avatar Michael Wedel
Browse files

Refs #15117. Convert windows path to URL

parent 3ee4faed
No related branches found
No related tags found
No related merge requests found
......@@ -239,18 +239,28 @@ class LoadCIF(PythonAlgorithm):
' (https://pypi.python.org/pypi/PyCifRW/4.1)')
def _loadFromCif(self):
cifFileName = self.getProperty('InputFile').value
from CifFile import ReadCif
cifFileUrl = self._getFileUrl()
workspace = self.getProperty('Workspace').value
# Try to parse cif file using PyCifRW
from CifFile import ReadCif
parsedCifFile = ReadCif(cifFileUrl)
parsedCifFile = ReadCif(cifFileName)
self._setCrystalStructureFromCifFile(workspace, parsedCifFile)
ubOption = self.getProperty('LoadUBMatrix').value
if ubOption:
self._setUBMatrixFromCifFile(workspace, parsedCifFile)
def _getFileUrl(self):
# ReadCif requires a URL, windows path specs seem to confuse urllib,
# so the pathname is converted to a URL before passing it to ReadCif.
from urllib import pathname2url
cifFileName = self.getProperty('InputFile').value
return pathname2url(cifFileName)
def _setCrystalStructureFromCifFile(self, workspace, cifFile):
crystalStructure = self._getCrystalStructureFromCifFile(cifFile)
workspace.sample().setCrystalStructure(crystalStructure)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment