Skip to content

Commit 319d6e3

Browse files
committed
Edit for changes suggested by oesteban
1 parent b84f217 commit 319d6e3

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

nipype/interfaces/niftyreg/base.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from builtins import property, super
2323
from distutils.version import StrictVersion
2424
import os
25+
import shutil
2526
import subprocess
2627
from warnings import warn
2728

@@ -30,20 +31,17 @@
3031

3132

3233
def get_custom_path(command):
33-
try:
34-
specific_dir = os.environ['NIFTYREGDIR']
35-
command = os.path.join(specific_dir, command)
36-
return command
37-
except KeyError:
38-
return command
34+
return os.path.join(os.getenv('NIFTYREGDIR', ''), command)
3935

4036

4137
def no_niftyreg(cmd='reg_f3d'):
42-
if True in [os.path.isfile(os.path.join(path, cmd)) and
43-
os.access(os.path.join(path, cmd), os.X_OK)
44-
for path in os.environ["PATH"].split(os.pathsep)]:
45-
return False
46-
return True
38+
try:
39+
return shutil.which(cmd) is None
40+
except AttributeError: # Python < 3.3
41+
return not any(
42+
[os.path.isfile(os.path.join(path, cmd)) and
43+
os.access(os.path.join(path, cmd), os.X_OK)
44+
for path in os.environ["PATH"].split(os.pathsep)])
4745

4846

4947
class NiftyRegCommandInputSpec(CommandLineInputSpec):
@@ -101,9 +99,7 @@ def version(self):
10199
return self.get_version()
102100

103101
def exists(self):
104-
if self.get_version() is None:
105-
return False
106-
return True
102+
return not self.get_version() is None
107103

108104
def _run_interface(self, runtime):
109105
# Update num threads estimate from OMP_NUM_THREADS env var

0 commit comments

Comments
 (0)