Skip to content

Commit b5d83d4

Browse files
authored
Merge pull request #2076 from satra/fix/remove-config-creation
fix: do not create a nipype folder in the home directory by default
2 parents 07ddd0f + 2f23f44 commit b5d83d4

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

nipype/utils/config.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,11 @@ class NipypeConfig(object):
8888
def __init__(self, *args, **kwargs):
8989
self._config = configparser.ConfigParser()
9090
config_dir = os.path.expanduser('~/.nipype')
91-
mkdir_p(config_dir)
92-
old_config_file = os.path.expanduser('~/.nipype.cfg')
93-
new_config_file = os.path.join(config_dir, 'nipype.cfg')
94-
# To be deprecated in two releases
95-
if os.path.exists(old_config_file):
96-
if os.path.exists(new_config_file):
97-
msg = ("Detected presence of both old (%s, used by versions "
98-
"< 0.5.2) and new (%s) config files. This version will "
99-
"proceed with the new one. We advise to merge settings "
100-
"and remove old config file if you are not planning to "
101-
"use previous releases of nipype.") % (old_config_file,
102-
new_config_file)
103-
warn(msg)
104-
else:
105-
warn("Moving old config file from: %s to %s" % (old_config_file,
106-
new_config_file))
107-
shutil.move(old_config_file, new_config_file)
91+
config_file = os.path.join(config_dir, 'nipype.cfg')
10892
self.data_file = os.path.join(config_dir, 'nipype.json')
10993
self._config.readfp(StringIO(default_cfg))
110-
self._config.read([new_config_file, old_config_file, 'nipype.cfg'])
94+
if os.path.exists(config_dir):
95+
self._config.read([config_file, 'nipype.cfg'])
11196

11297
def set_default_config(self):
11398
self._config.readfp(StringIO(default_cfg))
@@ -164,6 +149,10 @@ def save_data(self, key, value):
164149
with open(self.data_file, 'rt') as file:
165150
portalocker.lock(file, portalocker.LOCK_EX)
166151
datadict = load(file)
152+
else:
153+
dirname = os.path.dirname(self.data_file)
154+
if not os.path.exists(dirname):
155+
mkdir_p(dirname)
167156
with open(self.data_file, 'wt') as file:
168157
portalocker.lock(file, portalocker.LOCK_EX)
169158
datadict[key] = value

0 commit comments

Comments
 (0)