We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 586c0e0 commit 6af67cbCopy full SHA for 6af67cb
nibabel/filename_parser.py
@@ -264,9 +264,14 @@ def splitext_addext(filename,
264
for ext in addexts:
265
if endswith(filename, ext):
266
extpos = -len(ext)
267
- addext = filename[extpos:]
268
- filename = filename[:extpos]
+ filename, addext = filename[:extpos], filename[extpos:]
269
break
270
else:
271
addext = ''
272
- return os.path.splitext(filename) + (addext,)
+ # os.path.splitext() behaves unexpectedly when filename starts with '.'
+ extpos = filename.rfind('.')
273
+ if extpos < 0 or filename == '.':
274
+ root, ext = filename, ''
275
+ else:
276
+ root, ext = filename[:extpos], filename[extpos:]
277
+ return (root, ext, addext)
0 commit comments