Last active
March 14, 2018 05:42
-
-
Save wolfy1339/40d37fa9dd2b476d3714c282026ae8d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
blacklist = ['.exe', '.pyc', '.ico', '.png', '.icns', '.o', '.obj', '.lib', '.dll', '.idb', '.pdb', '.db', '.sconsign.dblite', '.tlog', '.dblite', '.res', '.vcxproj', '.fliter', '.user', '.sln', '.gz', '.1'] | |
def strip_whitespace_from_cwdir(): | |
for (root, directories, files) in os.walk("."): | |
for f in files: | |
if not ('.git' in root or '.vs' in root or '__pycache__' in root or '.sconf_temp' in root or '.tlog' in root or 'build' in root or os.path.splitext(f)[1] in blacklist): | |
strip_whitespace_from_file(os.path.join(root, f)) | |
def strip_whitespace_from_file(path): | |
print(path) | |
text = [] | |
with open(path, 'r') as f: | |
for line in f.readlines(): | |
text.append(line.rstrip()) | |
with open(path, 'w') as f: | |
f.write("\n".join(text)) | |
f.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment