stuppid_bot

Исправляем форматирование в исходниках

Jun 24th, 2013
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import os, re
  2. for path, dirs, files in os.walk('.'):
  3.     for file in files:
  4.         if re.match('.+\.(php|css|js)|\.htaccess', file, re.IGNORECASE):
  5.             f = open(path + '\\' + file, 'r+b')
  6.             content = f.read()
  7.             content = content.replace('\r', '')
  8.             content = content.replace('\t', '    ')
  9.             content = re.sub(' +$', '', content, flags=re.MULTILINE)
  10.             content = re.sub('\n+$', '', content)
  11.             f.truncate(0)
  12.             f.seek(0)
  13.             f.write(content)
  14.             f.close()
Advertisement
Add Comment
Please, Sign In to add comment