diff --git a/Framework/PythonInterface/plugins/algorithms/LoadCIF.py b/Framework/PythonInterface/plugins/algorithms/LoadCIF.py index 5632f82daf4dc60374131894562daf1236f14532..19384df7cb95e938bb78b843cddb26dad03dc67d 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadCIF.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadCIF.py @@ -232,14 +232,21 @@ class LoadCIF(PythonAlgorithm): doc='Load UB-matrix from CIF file if available.') def PyExec(self): + try: + self._loadFromCif() + except ImportError: + raise RuntimeError('This algorithm requires an additional Python package: PyCifRW' \ + ' (https://pypi.python.org/pypi/PyCifRW/4.1)') + + def _loadFromCif(self): cifFileName = self.getProperty('InputFile').value workspace = self.getProperty('Workspace').value # Try to parse cif file using PyCifRW - parsedCifFile = ReadCif(cifFileName) + from CifFile import ReadCif + parsedCifFile = ReadCif(cifFileName) self._setCrystalStructureFromCifFile(workspace, parsedCifFile) - ubOption = self.getProperty('LoadUBMatrix').value if ubOption: self._setUBMatrixFromCifFile(workspace, parsedCifFile) @@ -277,10 +284,4 @@ class LoadCIF(PythonAlgorithm): return builder.getUBMatrix() -try: - from CifFile import ReadCif - - AlgorithmFactory.subscribe(LoadCIF) -except ImportError: - logger.debug('Failed to subscribe algorithm LoadCIF; Python package PyCifRW' \ - 'may be missing (https://pypi.python.org/pypi/PyCifRW/4.1)') +AlgorithmFactory.subscribe(LoadCIF)