pycodestyle.py 978 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """
  2. Code style cleanups done after yapf
  3. """
  4. import argparse
  5. import os
  6. from extras import fixdictsformatting
  7. CLEANUPS = [
  8. fixdictsformatting,
  9. ]
  10. def walk_directory(root, dirs, files):
  11. for filename in files:
  12. if filename.lower().endswith('.py'):
  13. with open(os.path.join(root, filename), 'r') as f:
  14. filesource = f.read()
  15. org_source = filesource
  16. if 'migrate_settings_group' not in filesource:
  17. continue
  18. for cleanup in CLEANUPS:
  19. filesource = cleanup.fix_formatting(filesource)
  20. if org_source != filesource:
  21. print '====' * 8
  22. print os.path.join(root, filename)
  23. print ''
  24. print filesource
  25. if __name__ == '__main__':
  26. parser = argparse.ArgumentParser()
  27. parser.add_argument('path', nargs='?', default='./')
  28. for args in os.walk(parser.parse_args().path):
  29. walk_directory(*args)