@@ -88,26 +88,11 @@ class NipypeConfig(object):
88
88
def __init__ (self , * args , ** kwargs ):
89
89
self ._config = configparser .ConfigParser ()
90
90
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' )
108
92
self .data_file = os .path .join (config_dir , 'nipype.json' )
109
93
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' ])
111
96
112
97
def set_default_config (self ):
113
98
self ._config .readfp (StringIO (default_cfg ))
@@ -164,6 +149,10 @@ def save_data(self, key, value):
164
149
with open (self .data_file , 'rt' ) as file :
165
150
portalocker .lock (file , portalocker .LOCK_EX )
166
151
datadict = load (file )
152
+ else :
153
+ dirname = os .path .dirname (self .data_file )
154
+ if not os .path .exists (dirname ):
155
+ mkdir_p (dirname )
167
156
with open (self .data_file , 'wt' ) as file :
168
157
portalocker .lock (file , portalocker .LOCK_EX )
169
158
datadict [key ] = value
0 commit comments