improved subtitution/deletion handling
This commit is contained in:
parent
9abf5a110d
commit
7827364908
|
@ -10,13 +10,13 @@ validShells = {\
|
||||||
|
|
||||||
env_order = ['DAMASK_ROOT','DAMASK_BIN','PATH','PYTHONPATH','LD_LIBRARY_PATH']
|
env_order = ['DAMASK_ROOT','DAMASK_BIN','PATH','PYTHONPATH','LD_LIBRARY_PATH']
|
||||||
environment = { 'DAMASK_ROOT':
|
environment = { 'DAMASK_ROOT':
|
||||||
[{'delete':'DamaskRoot',
|
[{'delete':'',
|
||||||
'substitute':'[DamaskRoot]',
|
'substitute':'[DamaskRoot]',
|
||||||
'append': False,
|
'append': False,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'DAMASK_BIN':
|
'DAMASK_BIN':
|
||||||
[{'delete':'os.path.join(DamaskRoot,"bin")',
|
[{'delete':'',
|
||||||
'substitute':'[os.path.join(DamaskRoot,"bin")]',
|
'substitute':'[os.path.join(DamaskRoot,"bin")]',
|
||||||
'append': False,
|
'append': False,
|
||||||
},
|
},
|
||||||
|
@ -35,17 +35,20 @@ environment = { 'DAMASK_ROOT':
|
||||||
],
|
],
|
||||||
'LD_LIBRARY_PATH':
|
'LD_LIBRARY_PATH':
|
||||||
[{'activate': 'pathInfo["acml"]',
|
[{'activate': 'pathInfo["acml"]',
|
||||||
'delete':'"acml"', # what keywords trigger item deletion from existing path
|
'delete': '"acml"', # what keywords trigger item deletion from existing path
|
||||||
'substitute':'[os.path.join(pathInfo["acml"],"ifort64_mp/lib"),\
|
'substitute':'[os.path.join(pathInfo["acml"],"ifort64_mp/lib"),\
|
||||||
os.path.join(pathInfo["acml"],"ifort64/lib")]', # what to substitute for deleted path items
|
os.path.join(pathInfo["acml"],"ifort64/lib")]', # what to substitute for deleted path items
|
||||||
'append': True, # whether new entries append to existing ${env}
|
'append': True, # whether new entries append to existing ${env}
|
||||||
},
|
},
|
||||||
{'activate': 'pathInfo["lapack"]',
|
{'activate': 'pathInfo["lapack"]',
|
||||||
|
'delete': '[os.path.join(pathInfo["lapack"],"lib"),\
|
||||||
|
os.path.join(pathInfo["lapack"],"lib64")]', # deleted current (same) entry
|
||||||
'substitute':'[os.path.join(pathInfo["lapack"],"lib"),\
|
'substitute':'[os.path.join(pathInfo["lapack"],"lib"),\
|
||||||
os.path.join(pathInfo["lapack"],"lib64")]', # what to substitute for deleted path
|
os.path.join(pathInfo["lapack"],"lib64")]', # what to substitute for deleted path
|
||||||
'append': True, # whether new entries append to existing ${env}
|
'append': True, # whether new entries append to existing ${env}
|
||||||
},
|
},
|
||||||
{'activate': 'pathInfo["fftw"]',
|
{'activate': 'pathInfo["fftw"]',
|
||||||
|
'delete': '[os.path.join(pathInfo["fftw"],"lib")]', # deleted current (same) entry
|
||||||
'substitute':'[os.path.join(pathInfo["fftw"],"lib")]', # what to substitute for deleted path items
|
'substitute':'[os.path.join(pathInfo["fftw"],"lib")]', # what to substitute for deleted path items
|
||||||
'append': True, # whether new entries append to existing ${env}
|
'append': True, # whether new entries append to existing ${env}
|
||||||
},
|
},
|
||||||
|
@ -74,7 +77,9 @@ try: # check for user-defined pathinfo
|
||||||
file.close()
|
file.close()
|
||||||
for line in content:
|
for line in content:
|
||||||
if not (line.startswith('#') or line == ''):
|
if not (line.startswith('#') or line == ''):
|
||||||
pathInfo[line.split()[0].lower()] = os.path.normpath(line.split()[1])
|
items = line.split() + ['','']
|
||||||
|
pathInfo[items[0].lower()] = {False: os.path.normpath(os.path.join(DamaskRoot,'lib/',items[1])),
|
||||||
|
True: items[1]}[items[1] == '']
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -103,8 +108,16 @@ if theShell == 'bash':
|
||||||
for piece in environment[var]:
|
for piece in environment[var]:
|
||||||
try:
|
try:
|
||||||
if 'activate' not in piece or eval(piece['activate']) != '':
|
if 'activate' not in piece or eval(piece['activate']) != '':
|
||||||
items = [path for path in items if 'delete' not in piece or eval(piece['delete']) not in path] + \
|
if piece['append']:
|
||||||
eval(piece['substitute'])
|
if 'delete' in piece:
|
||||||
|
killer = eval(piece['delete'])
|
||||||
|
if type(killer) == str:
|
||||||
|
items = [path for path in items if killer not in path]
|
||||||
|
if type(killer) == list:
|
||||||
|
items = [path for path in items if path not in killer]
|
||||||
|
items += eval(piece['substitute'])
|
||||||
|
else:
|
||||||
|
items = eval(piece['substitute'])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
line = m.group(1)+':'.join(items)+m.group(3)
|
line = m.group(1)+':'.join(items)+m.group(3)
|
||||||
|
|
Loading…
Reference in New Issue