summaryrefslogtreecommitdiff
path: root/.arc-linters/check-binaries.py
blob: 017b89bff0917aff1b7ca07a56aff89f43cec7e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python3

# A linter to warn when binary files are added to the repository

import sys
import os
import json

path = sys.argv[1]
warnings = []
if os.path.isfile(path):
    with open(path, 'rb') as f:
        if b'\0' in f.read(8000):
            warning = {
                'severity': 'warning',
                'message': 'This file appears to be a binary file; does it really belong in the repository?'
            }
            warnings.append(warning)

print(json.dumps(warnings))