#!/bin/sh

set -e

cd "$(git rev-parse --show-toplevel)"

# pylint3 was replaced with pylint from Ubuntu 19.10
PYLINT=$(command -v pylint3) || true
if [ -z "$PYLINT" ]; then
    PYLINT=$(command -v pylint)
fi

find . -name \*.py \
    -and -not -path ./Pal/lib/crypto/mbedtls/\* \
    -and -not -path ./LibOS/glibc-build/\* \
    -and -not -path ./LibOS/glibc-\?.\?\?/\* \
    -and -not -path ./LibOS/shim/test/ltp/src/\* \
    -and -not -path ./LibOS/shim/test/ltp/build/\* \
    -and -not -path ./LibOS/shim/test/ltp/install/\* \
    -and -not -path ./Examples/pytorch/\* \
| sed 's/./\\&/g' \
| xargs "${PYLINT}" "$@" \
    Pal/src/host/Linux-SGX/signer/pal-sgx-get-token \
    Pal/src/host/Linux-SGX/signer/pal-sgx-sign \
    python/graphene-sgx-get-token \
    python/graphene-sgx-sign
