Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99af2f4

Browse files
committed
RF/ENH: remove file prior writing in to_filename
Closes#465
1 parent82a261c commit99af2f4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎nibabel/filebasedimages.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
''' Common interface for any image format--volume or surface, binary or xml.'''
1010

11+
importos
1112
importwarnings
1213

1314
from .externals.siximportstring_types
@@ -347,7 +348,15 @@ def to_filename(self, filename):
347348
-------
348349
None
349350
'''
350-
self.file_map=self.filespec_to_file_map(filename)
351+
self.file_map=file_map=self.filespec_to_file_map(filename)
352+
for_,fhinfile_map.items():
353+
ifnotisinstance(fh,FileHolder):
354+
continue
355+
ifos.path.exists(fh.filename):
356+
# Remove previous file where new file would be saved
357+
# Necessary e.g. for cases where file is a symlink pointing
358+
# to some non-writable file (e.g. under git annex control)
359+
os.unlink(fh.filename)
351360
self.to_file_map()
352361

353362
defto_filespec(self,filename):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp