xref: /aosp_15_r20/external/bcc/scripts/py-style-check.sh (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1#!/bin/bash
2
3set -euo pipefail
4
5# TODO: stop ignoring this. Maybe autopep8 existing stuff?
6find tools -type f -name "*.py" | xargs pycodestyle -r --show-source --ignore=E123,E125,E126,E127,E128,E302 || \
7    echo "pycodestyle run failed, please fix it" >&2
8
9NO_PROPER_SHEBANG="$(find tools examples -type f -executable -name '*.py' | xargs grep -L '#!/usr/bin/python')"
10if [ -n "$NO_PROPER_SHEBANG" ]; then
11    echo "bad shebangs found:"
12    echo "$NO_PROPER_SHEBANG"
13    echo
14    echo "either add proper shebang or remove executable bit" >&2
15
16    exit 1
17fi
18