1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Run tools to maintain the coding style.
|
4 | #
|
5 | # Usage:
|
6 | # devtools/repo.sh <function name>
|
7 |
|
8 | find-prune() {
|
9 | ### Filter out big dirs for speed
|
10 |
|
11 | find . \
|
12 | '(' -type d -a -name '_*' \
|
13 | -o -name testdata \
|
14 | -o -name Python-2.7.13 \
|
15 | ')' -a -prune \
|
16 | "$@"
|
17 | }
|
18 |
|
19 | find-src-files() {
|
20 | ### Find real source files
|
21 |
|
22 | # TODO: Add .R and .js
|
23 |
|
24 | find-prune \
|
25 | -o -type f -a \
|
26 | '(' -name '*.py' \
|
27 | -o -name '*.sh' \
|
28 | -o -name '*.asdl' \
|
29 | -o -name '*.[ch]' \
|
30 | -o -name '*.cc' \
|
31 | ')' -a -print
|
32 | }
|
33 |
|
34 | # Similar to test/unit.sh
|
35 | py-files() {
|
36 | find-prune -o -name '*.py' -a -printf '%P\n' | sort
|
37 | }
|
38 |
|
39 | py-manifest() {
|
40 | py-files | while read path; do
|
41 | read -r first_line < $path
|
42 | #echo $first_line
|
43 | if [[ $first_line == *python3* ]]; then
|
44 | kind=py3
|
45 | #py_path_more=: # no-op
|
46 | else
|
47 | kind=py2
|
48 | #py_path_more=:vendor/ # for vendor/typing.py
|
49 | fi
|
50 |
|
51 | echo "$kind $path"
|
52 | done
|
53 | }
|
54 |
|
55 | "$@"
|