|
18 | 18 | cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" || exit |
19 | 19 | cd "$(git rev-parse --show-toplevel)" || exit |
20 | 20 |
|
21 | | -# Check if cirq/check/nbformat exists, if not grab it. |
| 21 | +# Base URL for downloading tools from Cirq. |
| 22 | +declare -r cirq=https://raw.githubusercontent.com/quantumlib/Cirq/main |
| 23 | + |
| 24 | +# Check if cirq/check/nbformat exists; if not, grab it. |
22 | 25 | if [[ ! -f dev_tools/nbformat ]]; then |
23 | | - wget https://raw.githubusercontent.com/quantumlib/Cirq/master/check/nbformat -P dev_tools/ |
| 26 | + wget $cirq/check/nbformat -P dev_tools/ |
24 | 27 | chmod u+x dev_tools/nbformat |
25 | 28 | fi |
26 | 29 |
|
27 | | -# Check if tensorflow-docs.txt requirements file exists, if not grab it. |
| 30 | +# Check if the tensorflow-docs.txt requirements file exists; if not, grab it. |
28 | 31 | if [[ ! -f dev_tools/tensorflow-docs.txt ]]; then |
29 | | - wget https://raw.githubusercontent.com/quantumlib/Cirq/master/dev_tools/requirements/deps/tensorflow-docs.txt -P dev_tools/ |
| 32 | + wget $cirq/dev_tools/requirements/deps/tensorflow-docs.txt -P dev_tools/ |
| 33 | +fi |
| 34 | + |
| 35 | +# Check if the tensorflow-docs package has been installed; if not, install it. |
| 36 | +if ! pip show --quiet tensorflow-docs > /dev/null 2>&1; then |
30 | 37 | pip install -r dev_tools/tensorflow-docs.txt |
31 | 38 | fi |
32 | 39 |
|
33 | 40 | # Run the formatter. |
34 | 41 | result=$(dev_tools/nbformat "$@") |
35 | 42 | status=$? |
36 | 43 |
|
37 | | -# Make sure error message references right file. |
38 | | -result=${result//"check/nbformat"/"dev_tools/nbfmt"} |
| 44 | +# If there is an error message, make sure it references this script. |
| 45 | +# Note: using vars here avoids a problem with subsituting strings containing /. |
| 46 | +check_path="check/" |
| 47 | +devtools_path="dev_tools/" |
| 48 | +result=${result//$check_path/$devtools_path} |
| 49 | +result=${result//"nbformat"/"nbfmt"} |
39 | 50 | printf '%s\n' "${result[@]}" |
40 | 51 | exit $status |
0 commit comments