Skip to content
Snippets Groups Projects
Commit 6b627345 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

addAtlas method does duplicate check

parent 8e62e716
No related branches found
No related tags found
No related merge requests found
......@@ -206,12 +206,21 @@ class AtlasRegistry(notifier.Notifier):
is given a unique id.
"""
filename = op.abspath(filename)
if atlasID is None:
atlasIDBase = op.splitext(op.basename(filename))[0].lower()
atlasID = atlasIDBase
else:
atlasIDBase = atlasID
# If an atlas with the same ID/path
# already exists, raise an error
atlasDesc = self.__atlasDescs.get(atlasID, None)
if atlasDesc is not None and atlasDesc.specPath == filename:
raise KeyError('{} is already in the atlas '
'registry'.format(filename))
# Find a unique atlas ID
i = 0
while atlasID in self.__atlasDescs:
......@@ -227,8 +236,7 @@ class AtlasRegistry(notifier.Notifier):
self.__atlasDescs[desc.atlasID] = desc
fsldir = op.join(os.environ.get('FSLDIR', None), 'data', 'atlases')
if not op.abspath(filename).startswith(fsldir):
if not filename.startswith(fsldir):
self.__updateExtraAtlases()
self.notify(value=desc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment