| #!/bin/bash |
|
|
| |
| if [ -z "$1" ]; then |
| echo "Usage: $0 <folder_or_file>" |
| exit 1 |
| fi |
|
|
| TARGET=$1 |
|
|
| |
| if [ ! -e "$TARGET" ]; then |
| echo "Error: '$TARGET' does not exist." |
| exit 1 |
| fi |
|
|
| |
| process_file_or_folder() { |
| local ITEM=$1 |
|
|
| if [ -d "$ITEM" ]; then |
| echo "Processing folder: $ITEM" |
|
|
| echo "Fixing import order with isort..." |
| isort "$ITEM" |
|
|
| echo "Running Ruff to auto-fix Pylint issues..." |
| ruff check "$ITEM" --fix |
|
|
| echo "Modernizing Python syntax with Pyupgrade..." |
| find "$ITEM" -name "*.py" -exec pyupgrade --py38-plus {} \; |
|
|
| echo "Formatting code with Black..." |
| black "$ITEM" |
|
|
| elif [ -f "$ITEM" ]; then |
| echo "Processing file: $ITEM" |
|
|
| echo "Fixing import order with isort..." |
| isort "$ITEM" |
|
|
| echo "Running Ruff to auto-fix Pylint issues..." |
| ruff check "$ITEM" --fix |
|
|
| echo "Modernizing Python syntax with Pyupgrade..." |
| pyupgrade --py38-plus "$ITEM" |
|
|
| echo "Formatting code with Black..." |
| black "$ITEM" |
|
|
| else |
| echo "Error: '$ITEM' is not a valid file or folder." |
| exit 1 |
| fi |
| } |
|
|
| |
| process_file_or_folder "$TARGET" |
|
|
| echo "Fixes completed for: $TARGET" |
|
|
|
|