Improve conditions and refactor dataset classes (#475)
* Reimplement conditions * Refactor datasets and implement LabelBatch --------- Co-authored-by: Dario Coscia <dariocos99@gmail.com>
This commit is contained in:
committed by
Nicola Demo
parent
bdad144461
commit
a0cbf1c44a
@@ -2,51 +2,19 @@
|
||||
|
||||
#######################################
|
||||
|
||||
required_command="yapf unexpand"
|
||||
code_directories="pina tests"
|
||||
required_command="black"
|
||||
code_directories=("pina" "tests")
|
||||
|
||||
#######################################
|
||||
|
||||
usage() {
|
||||
echo
|
||||
echo -e "\tUsage: $0 [files]"
|
||||
echo
|
||||
echo -e "\tIf not files are specified, script formats all ".py" files"
|
||||
echo -e "\tin code directories ($code_directories); otherwise, formats"
|
||||
echo -e "\tall given files"
|
||||
echo
|
||||
echo -e "\tRequired command: $required_command"
|
||||
echo
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
[[ $1 == "-h" ]] && usage
|
||||
|
||||
# Test for required program
|
||||
for comm in $required_command; do
|
||||
command -v $comm >/dev/null 2>&1 || {
|
||||
echo "I require $comm but it's not installed. Aborting." >&2;
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
if ! command -v $required_command >/dev/null 2>&1; then
|
||||
echo "I require $required_command but it's not installed. Install dev dependencies."
|
||||
echo "Aborting." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find all python files in code directories
|
||||
python_files=""
|
||||
for dir in $code_directories; do
|
||||
python_files="$python_files $(find $dir -name '*.py')"
|
||||
done
|
||||
[[ $# != 0 ]] && python_files=$@
|
||||
|
||||
|
||||
# Here the important part: yapf format the files.
|
||||
for file in $python_files; do
|
||||
echo "Making beatiful $file..."
|
||||
[[ ! -f $file ]] && echo "$file does not exist; $0 -h for more info" && exit
|
||||
|
||||
yapf --style='{
|
||||
based_on_style: pep8,
|
||||
indent_width: 4,
|
||||
column_limit: 80
|
||||
}' -i $file
|
||||
done
|
||||
# Run black formatter
|
||||
for dir in "${code_directories[@]}"; do
|
||||
python -m black --line-length 80 "$dir"
|
||||
done
|
||||
Reference in New Issue
Block a user