diff --git a/CHANGES b/CHANGES index 9c8bf0dcba..2f2832f725 100644 --- a/CHANGES +++ b/CHANGES @@ -1,11 +1,15 @@ Upcoming release ================ + 0.14.0 () ============== ###### [Full changelog](https://github.com/nipy/nipype/milestone/13) +* ENH: Memoize version checks (https://github.com/nipy/nipype/pull/2274, https://github.com/nipy/nipype/pull/2295) + + 0.14.0rc1 (November 21, 2017) ----------------------------- diff --git a/nipype/interfaces/fsl/base.py b/nipype/interfaces/fsl/base.py index 6d16817e09..2bb120e097 100644 --- a/nipype/interfaces/fsl/base.py +++ b/nipype/interfaces/fsl/base.py @@ -26,27 +26,33 @@ """ from __future__ import print_function, division, unicode_literals, absolute_import -from builtins import open, object from glob import glob import os from ... import logging from ...utils.filemanip import fname_presuffix -from ..base import traits, isdefined, CommandLine, CommandLineInputSpec +from ..base import traits, isdefined, CommandLine, CommandLineInputSpec, PackageInfo from ...external.due import BibTeX IFLOGGER = logging.getLogger('interface') -class Info(object): - """Handle fsl output type and version information. - - version refers to the version of fsl on the system +class Info(PackageInfo): + """ + Handle FSL ``output_type`` and version information. output type refers to the type of file fsl defaults to writing eg, NIFTI, NIFTI_GZ + Examples + -------- + + >>> from nipype.interfaces.fsl import Info + >>> Info.version() # doctest: +SKIP + >>> Info.output_type() # doctest: +SKIP + + """ ftypes = {'NIFTI': '.nii', @@ -54,28 +60,13 @@ class Info(object): 'NIFTI_GZ': '.nii.gz', 'NIFTI_PAIR_GZ': '.img.gz'} - @staticmethod - def version(): - """Check for fsl version on system - - Parameters - ---------- - None - - Returns - ------- - version : str - Version number as string or None if FSL not found + if os.getenv('FSLDIR'): + version_file = os.path.join( + os.getenv('FSLDIR'), 'etc', 'fslversion') - """ - # find which fsl being used....and get version from - # /path/to/fsl/etc/fslversion - try: - basedir = os.environ['FSLDIR'] - except KeyError: - return None - out = open('%s/etc/fslversion' % (basedir)).read() - return out.strip('\n') + @staticmethod + def parse_version(raw_info): + return raw_info.splitlines()[0] @classmethod def output_type_to_ext(cls, output_type):