Created
March 6, 2013 23:05
-
-
Save Rembane/5104051 to your computer and use it in GitHub Desktop.
Ugliest script ever to remove the BOM from all Python files! :D
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
#!/usr/bin/env python | |
import os | |
for (path, dirs, files) in os.walk(os.getcwd()): | |
for f in [os.path.join(path, f) for f in files if f.endswith('.py')]: | |
fh_in = open(f) | |
if '\xEF\xBB\xBF' in fh_in.read(10): | |
fh_in.seek(0) | |
s = fh_in.read().replace('\xEF\xBB\xBF', '') | |
fh_in.close() | |
fh_out = open(f, 'w') | |
fh_out.write(s) | |
fh_out.close() | |
else: | |
fh_in.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment