separated by tokens. The 'path' will get added to the list if it
is not already there."""
try:
- paths = string.split(env_dict[key], sep)
+ is_list = 1
+ paths = env_dict[key]
+ if not SCons.Util.is_List(env_dict[key]):
+ paths = string.split(paths, sep)
+ is_list = 0
if not os.path.normcase(path) in map(os.path.normcase, paths):
- env_dict[key] = string.join([ path ] + paths, sep)
+ paths = [ path ] + paths
+ if is_list:
+ env_dict[key] = paths
+ else:
+ env_dict[key] = string.join(paths, sep)
except KeyError:
env_dict[key] = path
env_dict = { 'FOO' : os.path.normpath('/foo/bar') + os.pathsep + \
os.path.normpath('/baz/blat'),
'BAR' : os.path.normpath('/foo/bar') + os.pathsep + \
- os.path.normpath('/baz/blat') }
+ os.path.normpath('/baz/blat'),
+ 'BLAT' : [ os.path.normpath('/foo/bar'),
+ os.path.normpath('/baz/blat') ] }
addPathIfNotExists(env_dict, 'FOO', os.path.normpath('/foo/bar'))
addPathIfNotExists(env_dict, 'BAR', os.path.normpath('/bar/foo'))
addPathIfNotExists(env_dict, 'BAZ', os.path.normpath('/foo/baz'))
+ addPathIfNotExists(env_dict, 'BLAT', os.path.normpath('/baz/blat'))
+ addPathIfNotExists(env_dict, 'BLAT', os.path.normpath('/baz/foo'))
assert env_dict['FOO'] == os.path.normpath('/foo/bar') + os.pathsep + \
os.path.normpath('/baz/blat'), env_dict['FOO']
os.path.normpath('/foo/bar') + os.pathsep + \
os.path.normpath('/baz/blat'), env_dict['BAR']
assert env_dict['BAZ'] == os.path.normpath('/foo/baz'), env_dict['BAZ']
+ assert env_dict['BLAT'] == [ os.path.normpath('/baz/foo'),
+ os.path.normpath('/foo/bar'),
+ os.path.normpath('/baz/blat') ], env_dict['BLAT' ]
if __name__ == "__main__":
suite = unittest.makeSuite(PharLapCommonTestCase, 'test_')