-
Notifications
You must be signed in to change notification settings - Fork 13
/
utils
executable file
·39 lines (34 loc) · 948 Bytes
/
utils
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
#!/bin/bash
set -e
set -u
setup_dir() {
# check the location of setup.py or pyproject.toml
ref_files=("setup.py" "pyproject.toml")
directory="./"
values=()
for key in "${!ref_files[@]}"
do
values=()
ref_file=${ref_files[$key]}
values=$(find "$(pwd -P)" -name $ref_file)
# length is always 1 even if no value is found
if [ ${#values[@]} == 1 ]; then
if [ -n "${values[0]}" ]; then
directory=$(dirname ${values[0]})
fi
fi
done
echo $directory
}
get_app_name() {
# convert the directory name into the app name
echo $(echo $(basename $PWD) | tr - _)
}
get_project_name() {
echo $(get_app_name | tr -cd '[[:alnum:]]' | tr /A-Z/ /a-z/)
}
if [ ! -z ${VIRTUAL_ENV:-} ]; then
# see https://github.com/pypa/virtualenv/issues/1029
PS=${PS:-}
VIRTUAL_ENV_DISABLE_PROMPT=true source $VIRTUAL_ENV/bin/activate
fi