forked from esa-tu-darmstadt/BSVTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsvAdd.py
executable file
·33 lines (25 loc) · 896 Bytes
/
bsvAdd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
import argparse, os, sys
def dir_path(string):
if os.path.isdir(string):
return string
else:
raise NotADirectoryError(string)
machine_temp = """BSV_TOOLS?={0}
"""
def create_machine_file(path):
print("Creating local BSV_TOOLS path file .bsv_tools (Add to your .gitignore)")
with open("{}/.bsv_tools".format(path), "w") as f:
f.write(machine_temp.format(os.path.abspath(os.path.dirname(__file__))))
def main():
parser = argparse.ArgumentParser(description="Adds machine specific info in .bsv_tools")
parser.add_argument('--path', type=dir_path, default='./')
args = None
try:
args = parser.parse_args()
except NotADirectoryError as e:
print("Path has to be a valid directory, got: {}.".format(e))
sys.exit(1)
create_machine_file(args.path)
if __name__ == "__main__":
main()