forked from atlarge-research/continuum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_setup.py
More file actions
44 lines (34 loc) · 1.07 KB
/
Copy pathdev_setup.py
File metadata and controls
44 lines (34 loc) · 1.07 KB
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
41
42
43
44
"""Create a pre-commit hook for this repo,
which runs code linters and formatters automatically before commits"""
import os
import stat
def main():
"""Generate the content of the pre-commit file, and create the file"""
content = """\
#!/bin/sh
echo "-------------------------------"
echo "Black"
echo "-------------------------------"
black --line-length 100 ./
echo "-------------------------------"
echo "Pylint"
echo "-------------------------------"
for i in $(find ./ -type f -name "*.py"); do
pylint --rcfile=./sysconfig/pylintrc $i
done
echo "-------------------------------"
echo "Yamllint"
echo "-------------------------------"
yamllint --strict -c ./sysconfig/yamllint.yml ./
echo "-------------------------------"
echo "Ansible-lint"
echo "-------------------------------"
ansible-lint --profile production --strict"""
target = ".git/hooks/pre-commit"
with open(target, mode="w", encoding="utf-8") as f:
f.write(content)
f.close()
st = os.stat(target)
os.chmod(target, st.st_mode | stat.S_IEXEC)
if __name__ == "__main__":
main()