-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_gdsdiff.py
40 lines (30 loc) · 1.15 KB
/
install_gdsdiff.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
34
35
36
37
38
39
40
import pathlib
import configparser
home = pathlib.Path.home()
git_config_path = home / ".gitconfig"
git_attributes_path = home / ".gitattributes"
if git_config_path.exists():
git_config_str = open(git_config_path).read()
else:
git_config_str = "empty"
if git_attributes_path.exists():
git_attributes_str = open(git_attributes_path).read()
else:
git_attributes_str = "empty"
if "gds_diff" not in git_config_str:
print("gdsdiff shows boolean differences in Klayout")
print("git diff FILE.GDS")
print("Appending the gdsdiff command to your ~/.gitconfig")
config = configparser.RawConfigParser()
config.read(git_config_path)
key = 'diff "gds_diff"'
if key not in config.sections():
config.add_section(key)
config.set(key, "command", "python -m gdsdiff.gds_diff_git")
config.set(key, "binary", "True")
with open(git_config_path, "w+") as f:
config.write(f, space_around_delimiters=True)
if "gds_diff" not in git_attributes_str:
print("Appending the gdsdiff command to your ~/.gitattributes")
with open(git_attributes_path, "a") as f:
f.write("*.gds diff=gds_diff\n")