|
22 | 22 | from builtins import property, super
|
23 | 23 | from distutils.version import StrictVersion
|
24 | 24 | import os
|
| 25 | +import shutil |
25 | 26 | import subprocess
|
26 | 27 | from warnings import warn
|
27 | 28 |
|
|
30 | 31 |
|
31 | 32 |
|
32 | 33 | 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) |
39 | 35 |
|
40 | 36 |
|
41 | 37 | 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)]) |
47 | 45 |
|
48 | 46 |
|
49 | 47 | class NiftyRegCommandInputSpec(CommandLineInputSpec):
|
@@ -101,9 +99,7 @@ def version(self):
|
101 | 99 | return self.get_version()
|
102 | 100 |
|
103 | 101 | def exists(self):
|
104 |
| - if self.get_version() is None: |
105 |
| - return False |
106 |
| - return True |
| 102 | + return not self.get_version() is None |
107 | 103 |
|
108 | 104 | def _run_interface(self, runtime):
|
109 | 105 | # Update num threads estimate from OMP_NUM_THREADS env var
|
|
0 commit comments