/
find-python-files
executable file
·49 lines (45 loc) · 1.28 KB
/
find-python-files
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Find and print the absolute paths of all python source code files
set -e
REPO_PATH=$(dirname $(dirname $(realpath "$0")))
cd "$REPO_PATH"
SEARCH=
SEARCH+=" active_checks"
SEARCH+=" agents"
SEARCH+=" bin"
SEARCH+=" checks"
SEARCH+=" cmk"
SEARCH+=" cmk_base"
SEARCH+=" doc"
if [ -d "$REPO_PATH/enterprise" ]; then
SEARCH+=" enterprise"
fi
SEARCH+=" inventory"
SEARCH+=" livestatus"
if [ -d "$REPO_PATH/managed" ]; then
SEARCH+=" managed"
fi
SEARCH+=" notifications"
# Do not search whole omd/ because it may contain unpacked sub-packages
SEARCH+=" omd/packages/appliance"
SEARCH+=" omd/packages/maintenance"
SEARCH+=" omd/packages/omd"
SEARCH+=" scripts"
SEARCH+=" tests"
SEARCH+=" web/app"
SEARCH+=" werk"
# Resolve search paths to real paths before the search for performance reasons
REAL_SEARCH=$(realpath $SEARCH)
# while read F is used to deal with files containing whitespaces
find $REAL_SEARCH \
-name .mypy_cache -prune -o \
-name .venv -prune -o \
-name test_docker_parse_node_images.py -prune -o \
-name typeshed -prune -o \
-name run-clang-tidy.py -prune -o \
-name chroot -prune -o \
-type f -print | sort | while read F; do
if [[ "$F" == *.py ]] || head -n 1 "$F" | grep -q '^#!.*python$' >/dev/null 2>&1; then
echo "$F"
fi
done