2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2014-01-11 18:16:30 +05:30
|
|
|
|
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
|
2021-01-15 01:42:29 +05:30
|
|
|
import os
|
2019-09-04 04:11:41 +05:30
|
|
|
|
2021-01-15 01:42:29 +05:30
|
|
|
bin_dir = Path(os.environ['DAMASK_ROOT'])/'bin'
|
2014-02-28 13:17:11 +05:30
|
|
|
|
2020-06-03 17:02:47 +05:30
|
|
|
if not bin_dir.exists():
|
|
|
|
bin_dir.mkdir()
|
2014-01-11 18:16:30 +05:30
|
|
|
|
2016-08-25 21:38:19 +05:30
|
|
|
|
|
|
|
sys.stdout.write('\nsymbolic linking...\n')
|
2020-06-03 17:02:47 +05:30
|
|
|
for sub_dir in ['pre','post']:
|
2021-01-15 01:42:29 +05:30
|
|
|
the_dir = Path(os.environ['DAMASK_ROOT'])/'processing'/sub_dir
|
2016-08-25 21:38:19 +05:30
|
|
|
|
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)
|
2016-08-25 21:38:19 +05:30
|
|
|
|
|
|
|
|
|
|
|
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()
|