comparison pylearn/datasets/config.py @ 1492:e7c4d031d333

Fix for Windows paths
author Olivier Delalleau <delallea@iro>
date Tue, 16 Aug 2011 15:44:01 -0400
parents 25985fb3bb4f
children
comparison
equal deleted inserted replaced
1469:c41fdf8c35b8 1492:e7c4d031d333
39 return data_roots.rval 39 return data_roots.rval
40 roots = os.getenv('PYLEARN_DATA_ROOT') 40 roots = os.getenv('PYLEARN_DATA_ROOT')
41 if roots is None: 41 if roots is None:
42 roots = [data_root()] 42 roots = [data_root()]
43 else: 43 else:
44 roots = roots.split(':') 44 # Note that under Windows, we cannot use ':' as a delimiter because
45 roots2 = [] 45 # paths may contain this character. Thus we use ';' instead (similar to
46 #remove directory that don't exist 46 # the PATH environment variable in Windows).
47 for root in roots: 47 if sys.platform == 'win32':
48 if os.path.exists(root): 48 roots = roots.split(';')
49 roots2.append(root) 49 else:
50 data_roots.rval = roots2 50 roots = roots.split(':')
51 return roots2 51 # Remove paths that are not directories.
52 data_roots.rval = [r for r in roots if os.path.isdir(r)]
53 return data_roots.rval
52 54
53 55
54 def get_filepath_in_roots(*names): 56 def get_filepath_in_roots(*names):
55 """Return the full path of name that exist under a directory 57 """Return the full path of name that exist under a directory
56 in the PYLEARN_DATA_ROOT env variable. 58 in the PYLEARN_DATA_ROOT env variable.