2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2012-10-12 19:26:40 +02:00
|
|
|
|
2017-07-11 15:25:29 +02:00
|
|
|
# Remove .pyc files without corresponding .py files
|
|
|
|
# to prevent loading stale code.
|
2012-10-12 19:26:40 +02:00
|
|
|
#
|
|
|
|
# You can run it automatically on checkout:
|
|
|
|
#
|
|
|
|
# echo ./tools/clean-repo > .git/hooks/post-checkout
|
|
|
|
# chmod +x .git/hooks/post-checkout
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/.."
|
2017-07-14 21:34:12 +02:00
|
|
|
find . -name "__pycache__" -prune -exec rm -rf {} \;
|
2017-07-11 15:25:29 +02:00
|
|
|
for i in $(find . -name "*.pyc"); do
|
|
|
|
pyfile="${i%.pyc}.py"
|
|
|
|
if [ ! -e "$pyfile" ]; then
|
|
|
|
echo "Removing "$i" because source file ("$pyfile") doesn't exist."
|
|
|
|
rm "$i"
|
|
|
|
fi
|
|
|
|
done
|