DAMASK_EICMD/installation/symlink_Processing.py

31 lines
757 B
Python
Raw Normal View History

#!/usr/bin/env python3
2019-09-04 04:11:41 +05:30
# Makes postprocessing routines accessible from everywhere.
import sys
2020-06-03 17:02:47 +05:30
from pathlib import Path
2019-09-04 04:11:41 +05:30
import damask
2020-06-03 17:02:47 +05:30
env = damask.Environment()
bin_dir = env.root_dir/Path('bin')
2020-06-03 17:02:47 +05:30
if not bin_dir.exists():
bin_dir.mkdir()
sys.stdout.write('\nsymbolic linking...\n')
2020-06-03 17:02:47 +05:30
for sub_dir in ['pre','post']:
the_dir = env.root_dir/Path('processing')/Path(sub_dir)
2020-06-03 17:02:47 +05:30
for the_file in the_dir.glob('*.py'):
src = the_dir/the_file
dst = bin_dir/Path(the_file.with_suffix('').name)
2020-06-03 17:33:39 +05:30
if dst.is_file(): dst.unlink() # dst.unlink(True) for Python >3.8
2020-06-03 17:02:47 +05:30
dst.symlink_to(src)
sys.stdout.write('\npruning broken links...\n')
2020-06-03 17:02:47 +05:30
for filename in bin_dir.glob('*'):
if not filename.is_file():
2020-12-02 22:59:35 +05:30
filename.unlink()