diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | scripts/check_crlf.py | 33 |
2 files changed, 34 insertions, 0 deletions
@@ -19,6 +19,7 @@ export PYTHONPATH = $(shell echo "$$PYTHONPATH"):$(shell python -c 'import os; p all: clean-pyc check test check: + @$(PYTHON) scripts/check_crlf.py pygments build external @$(PYTHON) scripts/detect_missing_analyse_text.py || true @pyflakes pygments | grep -v 'but unused' || true @$(PYTHON) scripts/check_sources.py -i build -i dist -i pygments/lexers/_mapping.py \ diff --git a/scripts/check_crlf.py b/scripts/check_crlf.py new file mode 100644 index 00000000..14442d0e --- /dev/null +++ b/scripts/check_crlf.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + Checker for line endings + ~~~~~~~~~~~~~~~~~~~~~~~~ + + Make sure Python (.py) and Bash completition (.bashcomp) files do not + contain CR/LF newlines. + + :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import sys +import os + +if __name__ == '__main__': + for directory in sys.argv[1:]: + if not os.path.exists(directory): + continue + + for root, dirs, files in os.walk(directory): + for filename in files: + if not filename.endswith('.py') and not filename.endswith('.bashcomp'): + continue + + full_path = os.path.join(root, filename) + with open(full_path, 'rb') as f: + if b'\r\n' in f.read(): + print('CR/LF found in', full_path) + sys.exit(1) + + sys.exit(0) |