Guest User

Untitled

a guest
Nov 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. #whatever filter you would like to apply
  5. os.system('find * -type f | egrep -v ".svn" | egrep "\.(js|mustache|css|html|txt|less|sass|as|cfml|mxml)$" > /tmp/sourcefiles.txt')
  6.  
  7. with open('/tmp/sourcefiles.txt') as f:
  8. files = f.read().strip().split("\n")
  9.  
  10. for file in files:
  11. print "Processing", file
  12.  
  13. with open(file, 'r') as f: #read the file
  14. lines = f.read().split("\n")
  15.  
  16. for i,line in enumerate(lines):
  17. if re.search("^\s+", line): #if white space is detected at start of line replace it
  18. lines[i] = line.replace(" ","\t")
  19.  
  20. with open(file, 'w') as f:
  21. str = "\n".join(lines)
  22. f.write(str)
  23. #print str
Add Comment
Please, Sign In to add comment