Hector Dearman | d5c9a51 | 2023-06-27 12:31:17 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # The idea is for a tool named /tools/foo-bar you mv it to |
| 3 | # /python/tools/foo_bar.py then softlink /tools/shim to /tools/foo-bar. |
| 4 | # /tools/foo-bar then continues to work as an alias for |
| 5 | # /python/tools/foo_bar.py but you get the advantage of formatting |
| 6 | # & code sharing. |
| 7 | import os |
| 8 | import sys |
| 9 | ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 10 | NAME = os.path.basename(sys.argv[0]).replace('-', '_') |
| 11 | NAME = NAME if NAME.endswith('.py') else NAME + '.py' |
| 12 | PATH = os.path.join(ROOT_DIR, 'python', 'tools', NAME) |
| 13 | assert os.path.isfile(PATH), f'Shim target {PATH} does not exist.' |
| 14 | os.execv(PATH, sys.argv) |