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

Commitcf564b6

Browse files
committed
RF: git-annex specific handling in to_filename + allow NIBABEL_REMOVE_BEFORE_TO_FILENAME env var
1 parent99af2f4 commitcf564b6

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
@@ -17,6 +17,14 @@
1717
splitext_addext)
1818
from .openersimportImageOpener
1919

20+
# OS-specific path
21+
_GIT_ANNEX_OBJECTS_PATH=os.path.join('.git','annex','objects')
22+
23+
24+
def_is_annex_symlink(path):
25+
"""Return True if file is a symlink to the git-annex objects"""
26+
returnos.path.islink(path)and_GIT_ANNEX_OBJECTS_PATHinos.path.realpath(path)
27+
2028

2129
classImageFileError(Exception):
2230
pass
@@ -349,10 +357,11 @@ def to_filename(self, filename):
349357
None
350358
'''
351359
self.file_map=file_map=self.filespec_to_file_map(filename)
360+
remove_env=os.environ.get('NIBABEL_REMOVE_BEFORE_TO_FILENAME',None)
352361
for_,fhinfile_map.items():
353362
ifnotisinstance(fh,FileHolder):
354363
continue
355-
ifos.path.exists(fh.filename):
364+
ifos.path.lexists(fh.filename)and (remove_envor_is_annex_symlink(fh.filename)):
356365
# Remove previous file where new file would be saved
357366
# Necessary e.g. for cases where file is a symlink pointing
358367
# to some non-writable file (e.g. under git annex control)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp