LoginSignup
0
1

More than 3 years have passed since last update.

特定のディレクトリを除外して、pythonファイルのオートフォーマットする

Posted at
find . -type d -name [除外するディレクトリ] -prune -o -type f -name '*.py' -print | xargs autopep8 --in-place --aggressive --aggressive

例えば仮想環境とか作って

.
├── __init__.py
├── __pycache__
├── a.py
├── b.py
├── c.py
├── d.py
└── venv
    ├── bin
    ├── include
    ├── lib
    └──ここにめちゃめちゃpythonファイルある!!
    ├── pyvenv.cfg
    └── share

仮想環境下のファイルは別にフォーマットしなくてよくて、

a,b,c,d.pyだけフォーマットしたい
みたいなときに役立つコマンド

具体例としては

find . -type d -name venv -prune -o -type f -name '*.py' -print | xargs autopep8 --in-place --aggressive --aggressive
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1