我想知道是否有一种方法可以在除迁移之外的所有python文件上运行autopep8命令?修复所有pep8错误。
而不是执行命令
autopep8 --in-place --aggressive --aggressive <filename>
您可以让find
先查找文件,然后在这些文件上使用autopep8
:
-exec autopep8——in-place——aggressive——aggressive '{}' ;这里find
查找匹配*.py
glob模式的文件,但是不满足*/migrations/*
模式的路径。
您可以编写一个脚本来自动执行:
#!/usr/bin/env bash
echo "Running autopep..."
find -type f -name '*.py' ! -path '*/migrations/*' -exec autopep8 --in-place --aggressive --aggressive '{}' ;
echo "Running pycodestyle..."
find -type f -name '*.py' ! -path '*/migrations/*' -exec pycodestyle --first '{}' ;
只需使用autopep8.exe --exclude='*/migrations/*' --in-place --recursive .
在当前目录下的所有文件上运行autopep8,不包括迁移。